Return value of XLogInsertRecord() for XLOG_SWITCH record - Mailing list pgsql-hackers

From cca5507
Subject Return value of XLogInsertRecord() for XLOG_SWITCH record
Date
Msg-id tencent_FED0BEC2DFDAE0143699373CD78321BBA407@qq.com
Whole thread Raw
List 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

pgsql-hackers by date:

Previous
From: SATYANARAYANA NARLAPURAM
Date:
Subject: Re: Bug: Rule actions see wrong values for generated columns (NEW.gen reads OLD value)
Next
From: jian he
Date:
Subject: Re: DELETE/UPDATE FOR PORTION OF with rule system is not working