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: v1-0001-Keep-the-return-value-of-XLogInsertRecord-for-XLO.patch
Description: Binary data

Reply via email to