diff options
Diffstat (limited to 'src/bin/pg_waldump/pg_waldump.c')
-rw-r--r-- | src/bin/pg_waldump/pg_waldump.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index d41b831b180..2a557b37e5d 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -210,8 +210,10 @@ search_directory(const char *directory, const char *fname) if (fd >= 0) { char buf[XLOG_BLCKSZ]; + int r; - if (read(fd, buf, XLOG_BLCKSZ) == XLOG_BLCKSZ) + r = read(fd, buf, XLOG_BLCKSZ); + if (r == XLOG_BLCKSZ) { XLogLongPageHeader longhdr = (XLogLongPageHeader) buf; @@ -229,7 +231,8 @@ search_directory(const char *directory, const char *fname) fatal_error("could not read file \"%s\": %s", fname, strerror(errno)); else - fatal_error("not enough data in file \"%s\"", fname); + fatal_error("could not read file \"%s\": read %d of %zu", + fname, r, (Size) XLOG_BLCKSZ); } close(fd); return true; @@ -411,11 +414,17 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id, { int err = errno; char fname[MAXPGPATH]; + int save_errno = errno; XLogFileName(fname, timeline_id, sendSegNo, WalSegSz); - - fatal_error("could not read from log file %s, offset %u, length %d: %s", - fname, sendOff, segbytes, strerror(err)); + errno = save_errno; + + if (readbytes < 0) + fatal_error("could not read from log file %s, offset %u, length %d: %s", + fname, sendOff, segbytes, strerror(err)); + else if (readbytes == 0) + fatal_error("could not read from log file %s, offset %u: read %d of %zu", + fname, sendOff, readbytes, (Size) segbytes); } /* Update state for read */ |