diff options
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r-- | src/backend/access/transam/xlogreader.c | 24 | ||||
-rw-r--r-- | src/backend/access/transam/xlogrecovery.c | 7 | ||||
-rw-r--r-- | src/backend/access/transam/xlogutils.c | 3 |
3 files changed, 24 insertions, 10 deletions
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index b3e37003ac5..cf5db23cb86 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -37,6 +37,8 @@ #include "miscadmin.h" #include "pgstat.h" #include "utils/memutils.h" +#else +#include "common/logging.h" #endif static void report_invalid_record(XLogReaderState *state, const char *fmt,...) @@ -1918,14 +1920,25 @@ err: /* * Returns information about the block that a block reference refers to. - * See XLogRecGetBlockTagExtended(). + * + * This is like XLogRecGetBlockTagExtended, except that the block reference + * must exist and there's no access to prefetch_buffer. */ -bool +void XLogRecGetBlockTag(XLogReaderState *record, uint8 block_id, RelFileNode *rnode, ForkNumber *forknum, BlockNumber *blknum) { - return XLogRecGetBlockTagExtended(record, block_id, rnode, forknum, blknum, - NULL); + if (!XLogRecGetBlockTagExtended(record, block_id, rnode, forknum, blknum, + NULL)) + { +#ifndef FRONTEND + elog(ERROR, "failed to locate backup block with ID %d in WAL record", + block_id); +#else + pg_fatal("failed to locate backup block with ID %d in WAL record", + block_id); +#endif + } } /* @@ -1944,8 +1957,7 @@ XLogRecGetBlockTagExtended(XLogReaderState *record, uint8 block_id, { DecodedBkpBlock *bkpb; - if (block_id > record->record->max_block_id || - !record->record->blocks[block_id].in_use) + if (!XLogRecHasBlockRef(record, block_id)) return false; bkpb = &record->record->blocks[block_id]; diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index 4ee29182ac8..26be94b3f19 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -2172,10 +2172,10 @@ xlog_block_info(StringInfo buf, XLogReaderState *record) ForkNumber forknum; BlockNumber blk; - if (!XLogRecHasBlockRef(record, block_id)) + if (!XLogRecGetBlockTagExtended(record, block_id, + &rnode, &forknum, &blk, NULL)) continue; - XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blk); if (forknum != MAIN_FORKNUM) appendStringInfo(buf, "; blkref #%d: rel %u/%u/%u, fork %u, blk %u", block_id, @@ -2303,7 +2303,8 @@ verifyBackupPageConsistency(XLogReaderState *record) Buffer buf; Page page; - if (!XLogRecGetBlockTag(record, block_id, &rnode, &forknum, &blkno)) + if (!XLogRecGetBlockTagExtended(record, block_id, + &rnode, &forknum, &blkno, NULL)) { /* * WAL record doesn't contain a block reference with the given id. diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index b5d34c61e66..425702641a6 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -369,7 +369,8 @@ XLogReadBufferForRedoExtended(XLogReaderState *record, &prefetch_buffer)) { /* Caller specified a bogus block_id */ - elog(PANIC, "failed to locate backup block with ID %d", block_id); + elog(PANIC, "failed to locate backup block with ID %d in WAL record", + block_id); } /* |