aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:56 +0900
committerMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:56 +0900
commit58673b4a5fdff4d0d327c2d07e0cf8743f86f44c (patch)
tree6b7d85dd527f0e8b85eeb4f34122413749c36c7c /src/backend/access
parent75224ac20e90d2a9ba18ead1af62c74858d48c41 (diff)
downloadpostgresql-58673b4a5fdff4d0d327c2d07e0cf8743f86f44c.tar.gz
postgresql-58673b4a5fdff4d0d327c2d07e0cf8743f86f44c.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 e8d4e37fe30..ed3e36c0c2a 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1665,6 +1665,7 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
path)));
/* Write content and CRC */
+ errno = 0;
pgstat_report_wait_start(WAIT_EVENT_TWOPHASE_FILE_WRITE);
if (write(fd, content, len) != len)
{