postgres.git / summary / log / commit / refs
commit 048caa5560da33d63bbcbb2063c8ecd48994c99b
Author: Magnus Hagander <magnus@hagander.net>
Date: Fri May 18 15:53:20 2018 +0000
First released in: 11.0, 9.3.24, 9.4.19, 9.5.14, 9.6.10, 10.5
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.
src/backend/access/transam/xlog.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 218f98d29fd..618d4273772 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -3582,6 +3582,7 @@ ReadControlFile(void)
{
pg_crc32 crc;
int fd;
+ int r;
/*
* Read data...
@@ -3595,10 +3596,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);
[parent: bc711befd6ce]