mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
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.
This commit is contained in:
@ -3582,6 +3582,7 @@ ReadControlFile(void)
|
|||||||
{
|
{
|
||||||
pg_crc32 crc;
|
pg_crc32 crc;
|
||||||
int fd;
|
int fd;
|
||||||
|
int r;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read data...
|
* Read data...
|
||||||
@ -3595,10 +3596,17 @@ ReadControlFile(void)
|
|||||||
errmsg("could not open control file \"%s\": %m",
|
errmsg("could not open control file \"%s\": %m",
|
||||||
XLOG_CONTROL_FILE)));
|
XLOG_CONTROL_FILE)));
|
||||||
|
|
||||||
if (read(fd, ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
|
r = read(fd, ControlFile, sizeof(ControlFileData));
|
||||||
|
if (r != sizeof(ControlFileData))
|
||||||
|
{
|
||||||
|
if (r < 0)
|
||||||
ereport(PANIC,
|
ereport(PANIC,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not read from control file: %m")));
|
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);
|
close(fd);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user