Skip to content

Commit 5407241

Browse files
committed
pg_waldump: Fix error message for WAL files smaller than XLOG_BLCKSZ.
When opening a WAL file smaller than XLOG_BLCKSZ (e.g. 0 bytes long) while determining the wal_segment_size, pg_waldump checked errno, despite errno not being set by the short read. Resulting in a bogus error message. Author: Kyotaro Horiguchi <horikyota.ntt@gmail.com> Discussion: https://postgr.es/m/20220214.181847.775024684568733277.horikyota.ntt@gmail.com Backpatch: 11-, the bug was introducedin fc49e24
1 parent 0033fc6 commit 5407241

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/bin/pg_waldump/pg_waldump.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,12 @@ search_directory(const char *directory, const char *fname)
207207
WalSegSz),
208208
fname, WalSegSz);
209209
}
210+
else if (r < 0)
211+
fatal_error("could not read file \"%s\": %s",
212+
fname, strerror(errno));
210213
else
211-
{
212-
if (errno != 0)
213-
fatal_error("could not read file \"%s\": %s",
214-
fname, strerror(errno));
215-
else
216-
fatal_error("could not read file \"%s\": read %d of %zu",
217-
fname, r, (Size) XLOG_BLCKSZ);
218-
}
214+
fatal_error("could not read file \"%s\": read %d of %zu",
215+
fname, r, (Size) XLOG_BLCKSZ);
219216
close(fd);
220217
return true;
221218
}

0 commit comments

Comments
 (0)