Skip to content

Commit b5f096d

Browse files
committed
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.
1 parent 62e0020 commit b5f096d

File tree

1 file changed

+12
-4
lines changed
  • src/backend/access/transam

1 file changed

+12
-4
lines changed

src/backend/access/transam/xlog.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4471,6 +4471,7 @@ ReadControlFile(void)
44714471
{
44724472
pg_crc32 crc;
44734473
int fd;
4474+
int r;
44744475

44754476
/*
44764477
* Read data...
@@ -4484,10 +4485,17 @@ ReadControlFile(void)
44844485
errmsg("could not open control file \"%s\": %m",
44854486
XLOG_CONTROL_FILE)));
44864487

4487-
if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
4488-
ereport(PANIC,
4489-
(errcode_for_file_access(),
4490-
errmsg("could not read from control file: %m")));
4488+
r = read(fd, ControlFile, sizeof(ControlFileData));
4489+
if (r != sizeof(ControlFileData))
4490+
{
4491+
if (r < 0)
4492+
ereport(PANIC,
4493+
(errcode_for_file_access(),
4494+
errmsg("could not read from control file: %m")));
4495+
else
4496+
ereport(PANIC,
4497+
(errmsg("could not read from control file: read %d bytes, expected %d", r, (int) sizeof(ControlFileData))));
4498+
}
44914499

44924500
close(fd);
44934501

0 commit comments

Comments
 (0)