diff options
author | Magnus Hagander <magnus@hagander.net> | 2018-05-18 17:53:15 +0200 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2018-05-18 17:53:15 +0200 |
commit | 830e8e3609d003e320b963a7fa7c1432e10d8766 (patch) | |
tree | 2e4cb80a0de16744535f789aead8385e9eac1712 /src/backend/access/transam/xlog.c | |
parent | 4a9b44d3c075fe73661d0407faf6f048075a00f9 (diff) |
Fix error message on short read of pg_control
Instead of saying "error: success", indicate that we got a working read
but it was too short.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 61061e52570..98abc4961f0 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4311,6 +4311,7 @@ ReadControlFile(void) { pg_crc32c crc; int fd; + int r; /* * Read data... @@ -4324,10 +4325,17 @@ ReadControlFile(void) errmsg("could not open control file \"%s\": %m", XLOG_CONTROL_FILE))); - if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData)) - ereport(PANIC, - (errcode_for_file_access(), - errmsg("could not read from control file: %m"))); + r = read(fd, ControlFile, sizeof(ControlFileData)); + if (r != sizeof(ControlFileData)) + { + if (r < 0) + ereport(PANIC, + (errcode_for_file_access(), + errmsg("could not read from control file: %m"))); + else + ereport(PANIC, + (errmsg("could not read from control file: read %d bytes, expected %d", r, (int) sizeof(ControlFileData)))); + } close(fd); |