mirror of
https://github.com/postgres/postgres.git
synced 2025-05-06 19:59:18 +03:00
reorderbuffer: preserve errno while reporting error
Clobbering errno during cleanup after an error is an oft-repeated, easy to make mistake. Deal with it here as everywhere else, by saving it aside and restoring after cleanup, before ereport'ing. In passing, add a missing errcode declaration in another ereport() call in the same file, which I noticed while skimming the file looking for similar problems. Backpatch to 9.4, where this code was introduced.
This commit is contained in:
parent
2b4ae9c29d
commit
0440f49523
@ -2317,7 +2317,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
|
|||||||
|
|
||||||
if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
|
if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
|
||||||
{
|
{
|
||||||
|
int save_errno = errno;
|
||||||
|
|
||||||
CloseTransientFile(fd);
|
CloseTransientFile(fd);
|
||||||
|
errno = save_errno;
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not write to data file for XID %u: %m",
|
errmsg("could not write to data file for XID %u: %m",
|
||||||
@ -3070,7 +3073,8 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
|
|||||||
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
|
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg("could not open file \"%s\": %m", path)));
|
(errcode_for_file_access(),
|
||||||
|
errmsg("could not open file \"%s\": %m", path)));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user