diff options
author | Magnus Hagander <magnus@hagander.net> | 2018-05-18 17:53:19 +0200 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2018-05-18 17:53:19 +0200 |
commit | b5f096d50bee5c20023ed05390fdc52aa44a1404 (patch) | |
tree | ca51a8f07f94207a98eb6d4c31afdb5c8e3328ac /src | |
parent | 62e0020ad4914899d416edaa7d676499afcdc113 (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')
-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 1517f78aec5..bf51a697f7d 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4471,6 +4471,7 @@ ReadControlFile(void) { pg_crc32 crc; int fd; + int r; /* * Read data... @@ -4484,10 +4485,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); |