| From: | cca5507 <cca5507(at)qq(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Return value of XLogInsertRecord() for XLOG_SWITCH record |
| Date: | 2026-04-13 08:47:38 |
| Message-ID: | tencent_FED0BEC2DFDAE0143699373CD78321BBA407@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Keep-the-return-value-of-XLogInsertRecord-for-XLO.patch | application/octet-stream | 1.1 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | jian he | 2026-04-13 09:01:06 | Re: DELETE/UPDATE FOR PORTION OF with rule system is not working |
| Previous Message | SATYANARAYANA NARLAPURAM | 2026-04-13 08:42:49 | Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value) |