0003-Use-pg_fstat_size-in-walsender.c.patch
application/octet-stream
Filename: 0003-Use-pg_fstat_size-in-walsender.c.patch
Type: application/octet-stream
Part: 2
Patch
Format: format-patch
Series: patch 0003
Subject: Use pg_fstat_size() in walsender.c.
| File | + | − |
|---|---|---|
| src/backend/replication/walsender.c | 2 | 6 |
From 252bbc8f88f980d977b721d157af74f7c2e8e83a Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Tue, 11 Feb 2020 17:10:25 +1300
Subject: [PATCH 3/3] Use pg_fstat_size() in walsender.c.
This replaces couple of lseek() calls.
---
src/backend/replication/walsender.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index abb533b9d0..b94304a0e9 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -487,15 +487,11 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
errmsg("could not open file \"%s\": %m", path)));
/* Determine file length and send it to client */
- histfilelen = lseek(fd, 0, SEEK_END);
+ histfilelen = pg_fstat_size(fd);
if (histfilelen < 0)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not seek to end of file \"%s\": %m", path)));
- if (lseek(fd, 0, SEEK_SET) != 0)
- ereport(ERROR,
- (errcode_for_file_access(),
- errmsg("could not seek to beginning of file \"%s\": %m", path)));
+ errmsg("could not fstat file \"%s\": %m", path)));
pq_sendint32(&buf, histfilelen); /* col2 len */
--
2.23.0