Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f452e8

Browse files
committed
Work around gcc 4.6.0 bug that breaks WAL replay.
ReadRecord's habit of using both direct references to tmpRecPtr andreferences to *RecPtr (which is pointing at tmpRecPtr) triggers anoptimization bug in gcc 4.6.0, which apparently has forgotten aboutaliasing rules. Avoid the compiler bug, and make the code more readableto boot, by getting rid of the direct references. Improve the commentswhile 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
1 parente5b50d0 commit0f452e8

File tree

1 file changed

+11
-9
lines changed
  • src/backend/access/transam

1 file changed

+11
-9
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,12 +2931,12 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
29312931
gotogot_record;
29322932
}
29332933
/* align old recptr to next page */
2934-
if (tmpRecPtr.xrecoff %XLOG_BLCKSZ!=0)
2935-
tmpRecPtr.xrecoff+= (XLOG_BLCKSZ-tmpRecPtr.xrecoff %XLOG_BLCKSZ);
2936-
if (tmpRecPtr.xrecoff >=XLogFileSize)
2934+
if (RecPtr->xrecoff %XLOG_BLCKSZ!=0)
2935+
RecPtr->xrecoff+= (XLOG_BLCKSZ-RecPtr->xrecoff %XLOG_BLCKSZ);
2936+
if (RecPtr->xrecoff >=XLogFileSize)
29372937
{
2938-
(tmpRecPtr.xlogid)++;
2939-
tmpRecPtr.xrecoff=0;
2938+
(RecPtr->xlogid)++;
2939+
RecPtr->xrecoff=0;
29402940
}
29412941
/* We will account for page header size below */
29422942
}
@@ -3022,11 +3022,13 @@ ReadRecord(XLogRecPtr *RecPtr, int emode)
30223022
if (targetRecOff==0)
30233023
{
30243024
/*
3025-
* Can only get here in the continuing-from-prev-page case, because
3026-
* XRecOffIsValid eliminated the zero-page-offset case otherwise. Need
3027-
* to skip over the new page's header.
3025+
* At page start, so skip over page header. The Assert checks that
3026+
* we're not scribbling on caller's record pointer; it's OK because we
3027+
* can only get here in the continuing-from-prev-record case, since
3028+
* XRecOffIsValid rejected the zero-page-offset case otherwise.
30283029
*/
3029-
tmpRecPtr.xrecoff+=pageHeaderSize;
3030+
Assert(RecPtr==&tmpRecPtr);
3031+
RecPtr->xrecoff+=pageHeaderSize;
30303032
targetRecOff=pageHeaderSize;
30313033
}
30323034
elseif (targetRecOff<pageHeaderSize)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp