Skip to content

Commit 6f79ae7

Browse files
committed
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.
1 parent a859e64 commit 6f79ae7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/backend/replication/logical/reorderbuffer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,10 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
23172317

23182318
if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
23192319
{
2320+
int save_errno = errno;
2321+
23202322
CloseTransientFile(fd);
2323+
errno = save_errno;
23212324
ereport(ERROR,
23222325
(errcode_for_file_access(),
23232326
errmsg("could not write to data file for XID %u: %m",
@@ -3070,7 +3073,8 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
30703073
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
30713074
if (fd < 0)
30723075
ereport(ERROR,
3073-
(errmsg("could not open file \"%s\": %m", path)));
3076+
(errcode_for_file_access(),
3077+
errmsg("could not open file \"%s\": %m", path)));
30743078

30753079
while (true)
30763080
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy