aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2018-05-18 17:52:18 +0200
committerMagnus Hagander <magnus@hagander.net>2018-05-18 17:54:18 +0200
commitcfb758b6d9c1df58fb1dfd5d3f6e70393fb17869 (patch)
tree1e022ed9469e1c576e1ca7c36ee4c39fbffaa784 /src/backend/access/transam/xlog.c
parenta194106c1b4468c74dbf6e83d845be86239844aa (diff)
downloadpostgresql-cfb758b6d9c1df58fb1dfd5d3f6e70393fb17869.tar.gz
postgresql-cfb758b6d9c1df58fb1dfd5d3f6e70393fb17869.zip
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.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 04bfac74858..adbd6a21264 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4486,6 +4486,7 @@ ReadControlFile(void)
pg_crc32c crc;
int fd;
static char wal_segsz_str[20];
+ int r;
/*
* Read data...
@@ -4499,10 +4500,17 @@ ReadControlFile(void)
XLOG_CONTROL_FILE)));
pgstat_report_wait_start(WAIT_EVENT_CONTROL_FILE_READ);
- 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))));
+ }
pgstat_report_wait_end();
close(fd);