aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:18 +0900
committerMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:18 +0900
commit5a23c74b63ec9f63c648f79b13a900c37332ee55 (patch)
tree3d8c59682c7f4d43a57ad29c2712c285532002c7 /src/backend/access
parente61f21b921aebc0870d3ac47f77fc17e75e2fefb (diff)
downloadpostgresql-5a23c74b63ec9f63c648f79b13a900c37332ee55.tar.gz
postgresql-5a23c74b63ec9f63c648f79b13a900c37332ee55.zip
Reset properly errno before calling write()
6cb3372 enforces errno to ENOSPC when less bytes than what is expected have been written when it is unset, though it forgot to properly reset errno before doing a system call to write(), causing errno to potentially come from a previous system call. Reported-by: Tom Lane Author: Michael Paquier Reviewed-by: Tom Lane Discussion: https://postgr.es/m/31797.1533326676@sss.pgh.pa.us
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/heap/rewriteheap.c1
-rw-r--r--src/backend/access/transam/twophase.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/access/heap/rewriteheap.c b/src/backend/access/heap/rewriteheap.c
index ed7ba181c79..85f92973c95 100644
--- a/src/backend/access/heap/rewriteheap.c
+++ b/src/backend/access/heap/rewriteheap.c
@@ -1166,6 +1166,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
/* write out tail end of mapping file (again) */
+ errno = 0;
pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
if (write(fd, data, len) != len)
{
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 306861bb793..0ae07227941 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1669,6 +1669,7 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
errmsg("could not recreate file \"%s\": %m", path)));
/* Write content and CRC */
+ errno = 0;
pgstat_report_wait_start(WAIT_EVENT_TWOPHASE_FILE_WRITE);
if (write(fd, content, len) != len)
{