v2-0001-Keep-the-return-value-of-XLogInsertRecord-for-XLO.patch
application/octet-stream
Filename: v2-0001-Keep-the-return-value-of-XLogInsertRecord-for-XLO.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0001
Subject: Keep the return value of XLogInsertRecord() for XLOG_SWITCH record consistent with other records
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 9 | 2 |
From ce95aa5fa3545580fbf5cfdfca83768aa8cdddd9 Mon Sep 17 00:00:00 2001
From: ChangAo Chen <cca5507@qq.com>
Date: Tue, 21 Apr 2026 19:21:58 +0800
Subject: [PATCH v2] Keep the return value of XLogInsertRecord() for
XLOG_SWITCH record consistent with other records
---
src/backend/access/transam/xlog.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e39af79c03b..bd992d1f3e2 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1027,8 +1027,15 @@ XLogInsertRecord(XLogRecData *rdata,
*/
if (inserted)
{
- EndPos = StartPos + SizeOfXLogRecord;
- if (StartPos / XLOG_BLCKSZ != EndPos / XLOG_BLCKSZ)
+ EndPos = StartPos + MAXALIGN(SizeOfXLogRecord);
+
+ /*
+ * If the XLOG_SWITCH record crosses a page boundary and actually has
+ * a part on the next page, we need to consider the page header. This
+ * is consistent with XLogBytePosToEndRecPtr().
+ */
+ if (StartPos / XLOG_BLCKSZ != EndPos / XLOG_BLCKSZ &&
+ EndPos % XLOG_BLCKSZ != 0)
{
uint64 offset = XLogSegmentOffset(EndPos, wal_segment_size);
--
2.34.1