From 9e41148229192dccc4bcc40f53af588b73d8ffea Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 20 Apr 2021 16:58:30 -0400 Subject: [PATCH] Fix under-parenthesized XLogRecHasBlockRef() macro. Commit f003d9f87 left this macro with inadequate (or, one could say, too much) parenthesization. Which was catastrophic to the correctness of calls such as "if (!XLogRecHasBlockRef(record, 1)) ...". There are only a few of those, which perhaps explains why we didn't notice immediately (with our general weakness of WAL replay testing being another factor). I found it by debugging intermittent replay failures like 2021-04-08 14:33:30.191 EDT [29463] PANIC: failed to locate backup block with ID 1 2021-04-08 14:33:30.191 EDT [29463] CONTEXT: WAL redo at 0/95D3438 for SPGist/ADD_NODE: off 1; blkref #0: rel 1663/16384/25998, blk 1 --- src/include/access/xlogreader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index d5308b25a2..3b8af31a8f 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -385,8 +385,8 @@ extern bool DecodeXLogRecord(XLogReaderState *state, #define XLogRecMaxBlockId(decoder) ((decoder)->record->max_block_id) #define XLogRecGetBlock(decoder, i) (&(decoder)->record->blocks[(i)]) #define XLogRecHasBlockRef(decoder, block_id) \ - ((decoder)->record->max_block_id >= (block_id)) && \ - ((decoder)->record->blocks[block_id].in_use) + ((decoder)->record->max_block_id >= (block_id) && \ + (decoder)->record->blocks[block_id].in_use) #define XLogRecHasBlockImage(decoder, block_id) \ ((decoder)->record->blocks[block_id].has_image) #define XLogRecBlockImageApply(decoder, block_id) \