postgres.git / summary / log / commit / refs
commit 9ff7fd9063ce918e458a643b53eda1cf95f7d115
Author: Andres Freund <andres@anarazel.de>
Date: Fri Feb 25 18:30:05 2022 +0000
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 fc49e24fa
src/bin/pg_waldump/pg_waldump.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index f8b8afe4a7b..a8cf58e35f5 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -204,15 +204,12 @@ search_directory(const char *directory, const char *fname)
WalSegSz),
fname, WalSegSz);
}
+ else if (r < 0)
+ fatal_error("could not read file \"%s\": %m",
+ fname);
else
- {
- if (errno != 0)
- fatal_error("could not read file \"%s\": %m",
- fname);
- else
- fatal_error("could not read file \"%s\": read %d of %zu",
- fname, r, (Size) XLOG_BLCKSZ);
- }
+ fatal_error("could not read file \"%s\": read %d of %zu",
+ fname, r, (Size) XLOG_BLCKSZ);
close(fd);
return true;
}
[parent: 7d80e93fb1f1]