diff options
author | Michael Paquier <michael@paquier.xyz> | 2018-07-23 09:37:36 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2018-07-23 09:37:36 +0900 |
commit | e41d0a1090b75fed4c033c2e404643382348f88e (patch) | |
tree | 96cade6f6ccacf5ed088df67ae0e225720679d47 /src/backend/replication/logical/origin.c | |
parent | 56df07bb9e50a3ca4d148c537524f00bccc6650e (diff) | |
download | postgresql-e41d0a1090b75fed4c033c2e404643382348f88e.tar.gz postgresql-e41d0a1090b75fed4c033c2e404643382348f88e.zip |
Add proper errcodes to new error messages for read() failures
Those would use the default ERRCODE_INTERNAL_ERROR, but for foreseeable
failures an errcode ought to be set, ERRCODE_DATA_CORRUPTED making the
most sense here.
While on the way, fix one errcode_for_file_access missing in origin.c
since the code has been created, and remove one assignment of errno to 0
before calling read(), as this was around to fit with what was present
before 811b6e36 where errno would not be set when not enough bytes are
read. I have noticed the first one, and Tom has pinged me about the
second one.
Author: Michael Paquier
Reported-by: Tom Lane
Discussion: https://postgr.es/m/27265.1531925836@sss.pgh.pa.us
Diffstat (limited to 'src/backend/replication/logical/origin.c')
-rw-r--r-- | src/backend/replication/logical/origin.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index 2d05d04b872..822c96d1c2f 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -715,11 +715,13 @@ StartupReplicationOrigin(void) { if (readBytes < 0) ereport(PANIC, - (errmsg("could not read file \"%s\": %m", + (errcode_for_file_access(), + errmsg("could not read file \"%s\": %m", path))); else ereport(PANIC, - (errmsg("could not read file \"%s\": read %d of %zu", + (errcode(ERRCODE_DATA_CORRUPTED), + errmsg("could not read file \"%s\": read %d of %zu", path, readBytes, sizeof(magic)))); } COMP_CRC32C(crc, &magic, sizeof(magic)); |