diff options
-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 527ce760e49..5d845a81789 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4258,6 +4258,7 @@ ReadControlFile(void) { pg_crc32c crc; int fd; + int r; /* * Read data... @@ -4271,10 +4272,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); |