Return value of XLogInsertRecord() for XLOG_SWITCH record
cca5507 <cca5507@qq.com>
From: cca5507 <cca5507@qq.com>
To: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-13T08:47:38Z
Lists: pgsql-hackers
Attachments
- v1-0001-Keep-the-return-value-of-XLogInsertRecord-for-XLO.patch (application/octet-stream) patch v1-0001
Hi,
I find that the return value of XLogInsertRecord() for XLOG_SWITCH record
is inconsistent with other records.
For XLOG_SWITCH record:
```
/*
* Even though we reserved the rest of the segment for us, which is
* reflected in EndPos, we return a pointer to just the end of the
* xlog-switch record.
*/
if (inserted)
{
EndPos = StartPos + SizeOfXLogRecord;
if (StartPos / XLOG_BLCKSZ != EndPos / XLOG_BLCKSZ)
{
uint64 offset = XLogSegmentOffset(EndPos, wal_segment_size);
if (offset == EndPos % XLOG_BLCKSZ)
EndPos += SizeOfXLogLongPHD;
else
EndPos += SizeOfXLogShortPHD;
}
}
```
It is equivalent to XLogBytePosToRecPtr(), but all other records use XLogBytePosToEndRecPtr().
No actual problem found yet, but I think it's better to keep them consistent. Thoughts?
--
Regards,
ChangAo Chen
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Undo thinko in commit e78d1d6d4.
- 9d141466ff08 19 (unreleased) cited
-
Fix orphaned processes when startup process fails during PM_STARTUP
- 9b43e6793b0f 19 (unreleased) cited