@ -3728,23 +3728,32 @@ ReadRecord(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt)
RecPtr = & tmpRecPtr ;
RecPtr = & tmpRecPtr ;
/*
/*
* Align recptr to next page if no more records can fit on the current
* RecPtr is pointing to end + 1 of the previous WAL record . We must
* page .
* advance it if necessary to where the next record starts . First ,
* align to next page if no more records can fit on the current page .
*/
*/
if ( XLOG_BLCKSZ - ( RecPtr - > xrecoff % XLOG_BLCKSZ ) < SizeOfXLogRecord )
if ( XLOG_BLCKSZ - ( RecPtr - > xrecoff % XLOG_BLCKSZ ) < SizeOfXLogRecord )
{
NextLogPage ( * RecPtr ) ;
NextLogPage ( tmpRecPtr ) ;
/* We will account for page header size below */
}
if ( tmpRecPtr . xrecoff > = XLogFileSize )
/* Check for crossing of xlog segment boundary */
if ( RecPtr - > xrecoff > = XLogFileSize )
{
{
( tmpRecPtr . xlogid ) + + ;
( RecPtr - > xlogid ) + + ;
tmpRecPtr . xrecoff = 0 ;
RecPtr - > xrecoff = 0 ;
}
}
/*
* 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 .
*/
}
}
else
else
{
{
/*
* In this case , the passed - in record pointer should already be
* pointing to a valid record starting position .
*/
if ( ! XRecOffIsValid ( RecPtr - > xrecoff ) )
if ( ! XRecOffIsValid ( RecPtr - > xrecoff ) )
ereport ( PANIC ,
ereport ( PANIC ,
( errmsg ( " invalid record offset at %X/%X " ,
( errmsg ( " invalid record offset at %X/%X " ,
@ -3773,11 +3782,13 @@ retry:
if ( targetRecOff = = 0 )
if ( targetRecOff = = 0 )
{
{
/*
/*
* Can only get here in the continuing - from - prev - page case , because
* At page start , so skip over page header . The Assert checks that
* XRecOffIsValid eliminated the zero - page - offset case otherwise . Need
* we ' re not scribbling on caller ' s record pointer ; it ' s OK because we
* to skip over the new page ' s header .
* can only get here in the continuing - from - prev - record case , since
* XRecOffIsValid rejected the zero - page - offset case otherwise .
*/
*/
tmpRecPtr . xrecoff + = pageHeaderSize ;
Assert ( RecPtr = = & tmpRecPtr ) ;
RecPtr - > xrecoff + = pageHeaderSize ;
targetRecOff = pageHeaderSize ;
targetRecOff = pageHeaderSize ;
}
}
else if ( targetRecOff < pageHeaderSize )
else if ( targetRecOff < pageHeaderSize )