From bd037dc928dd126e5623117b2fe7633ec3fa7c40 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 11 Apr 2022 17:43:46 -0400 Subject: Make XLogRecGetBlockTag() throw error if there's no such block. All but a few existing callers assume without checking that this function succeeds. While it probably will, that's a poor excuse for not checking. Let's make it return void and instead throw an error if it doesn't find the block reference. Callers that actually need to handle the no-such-block case must now use the underlying function XLogRecGetBlockTagExtended. In addition to being a bit less error-prone, this should also serve to suppress some Coverity complaints about XLogRecGetBlockRefInfo. While at it, clean up some inconsistency about use of the XLogRecHasBlockRef macro: make XLogRecGetBlockTagExtended use that instead of open-coding the same condition, and avoid calling XLogRecHasBlockRef twice in relevant code paths. (That is, calling XLogRecHasBlockRef followed by XLogRecGetBlockTag is now deprecated: use XLogRecGetBlockTagExtended instead.) Patch HEAD only; this doesn't seem to have enough value to consider a back-branch API break. Discussion: https://postgr.es/m/425039.1649701221@sss.pgh.pa.us --- src/backend/access/transam/xlogutils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/backend/access/transam/xlogutils.c') 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); } /* -- cgit v1.2.3