diff options
author | Andres Freund | 2022-02-25 18:30:05 +0000 |
---|---|---|
committer | Andres Freund | 2022-02-25 18:30:05 +0000 |
commit | cd83cb953606b94966981056e79dbb6c48751055 (patch) | |
tree | ad69b11e6a78f2d120cac0e5c4533c7b43a5869a | |
parent | 73c61a50a1555007001d29844dcdb10b4f982a73 (diff) |
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 <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Backpatch: 11-, the bug was introducedin fc49e24fa
-rw-r--r-- | src/bin/pg_waldump/pg_waldump.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index a6251e1a961..2340dc247b0 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -222,15 +222,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 %d", - fname, r, XLOG_BLCKSZ); - } + fatal_error("could not read file \"%s\": read %d of %d", + fname, r, XLOG_BLCKSZ); close(fd); return true; } |