On Wed, Mar 2, 2016 at 4:25 PM, wcting <wcting163@163.com> wrote:
> /*
> * If at page start, we must skip over the page header. But
> we can't
> * do that until we've read in the page, since the header
> size is
> * variable.
> */
>
> i don't know the meaning behind this comments,
>
> if ((RecPtr->xrecoff % XLogSegSize) == 0)
> it's a long page header, else a short page header,
>
> so "the header size" can be calculated ? right?
This means that the page must be read first, before recalculating the
record pointer to be the first one after the page header. This is done
a little bit after in ReadRecord(): pageHeaderSize = XLogPageHeaderSize((XLogPageHeader) readBuf); targetRecOff =
RecPtr->xrecoff% XLOG_BLCKSZ; if (targetRecOff == 0) { /* * At page start, so skip over page header.
TheAssert checks that * we're not scribbling on caller's record pointer; it's OK because we * can only
gethere in the continuing-from-prev-record case, since * XRecOffIsValid rejected the zero-page-offset case
otherwise. */ Assert(RecPtr == &tmpRecPtr); RecPtr->xrecoff += pageHeaderSize; targetRecOff =
pageHeaderSize; }
And XLogPageHeaderSize() makes the difference between a long a short header.
--
Michael