1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-25 13:17:41 +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:
Tom Lane
2011-06-10 17:03:03 -04:00
parent cb2d158c58
commit c2ba0121c7
2 changed files with 30 additions and 19 deletions

View File

@@ -154,13 +154,13 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
/* Align a record pointer to next page */
#define NextLogPage(recptr) \
do { \
if (recptr.xrecoff % XLOG_BLCKSZ != 0) \
recptr.xrecoff += \
(XLOG_BLCKSZ - recptr.xrecoff % XLOG_BLCKSZ); \
if (recptr.xrecoff >= XLogFileSize) \
if ((recptr).xrecoff % XLOG_BLCKSZ != 0) \
(recptr).xrecoff += \
(XLOG_BLCKSZ - (recptr).xrecoff % XLOG_BLCKSZ); \
if ((recptr).xrecoff >= XLogFileSize) \
{ \
(recptr.xlogid)++; \
recptr.xrecoff = 0; \
((recptr).xlogid)++; \
(recptr).xrecoff = 0; \
} \
} while (0)