mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Work around gcc 4.6.0 bug that breaks WAL replay.
ReadRecord's habit of using both direct references to tmpRecPtr and references to *RecPtr (which is pointing at tmpRecPtr) triggers an optimization bug in gcc 4.6.0, which apparently has forgotten about aliasing rules. Avoid the compiler bug, and make the code more readable to boot, by getting rid of the direct references. Improve the comments while at it. Back-patch to all supported versions, in case they get built with 4.6.0. Tom Lane, with some cosmetic suggestions from Alex Hunsaker
This commit is contained in:
@ -3041,12 +3041,12 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
|
|||||||
goto got_record;
|
goto got_record;
|
||||||
}
|
}
|
||||||
/* align old recptr to next page */
|
/* align old recptr to next page */
|
||||||
if (tmpRecPtr.xrecoff % XLOG_BLCKSZ != 0)
|
if (RecPtr->xrecoff % XLOG_BLCKSZ != 0)
|
||||||
tmpRecPtr.xrecoff += (XLOG_BLCKSZ - tmpRecPtr.xrecoff % XLOG_BLCKSZ);
|
RecPtr->xrecoff += (XLOG_BLCKSZ - RecPtr->xrecoff % XLOG_BLCKSZ);
|
||||||
if (tmpRecPtr.xrecoff >= XLogFileSize)
|
if (RecPtr->xrecoff >= XLogFileSize)
|
||||||
{
|
{
|
||||||
(tmpRecPtr.xlogid)++;
|
(RecPtr->xlogid)++;
|
||||||
tmpRecPtr.xrecoff = 0;
|
RecPtr->xrecoff = 0;
|
||||||
}
|
}
|
||||||
/* We will account for page header size below */
|
/* We will account for page header size below */
|
||||||
}
|
}
|
||||||
@ -3132,11 +3132,13 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
|
|||||||
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)
|
||||||
|
Reference in New Issue
Block a user