From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make XLogRecGetBlockTag() throw error if there's no such block.
Date: Mon, 11 Apr 2022 21:44:04 +0000
Message-ID: <E1ne1pM-00059Z-KZ@gemulon.postgresql.org> (raw)
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
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/bd037dc928dd126e5623117b2fe7633ec3fa7c40
Modified Files
--------------
src/backend/access/heap/heapam.c | 2 +-
src/backend/access/nbtree/nbtxlog.c | 2 +-
src/backend/access/rmgrdesc/xlogdesc.c | 11 +++++------
src/backend/access/transam/xlogreader.c | 24 ++++++++++++++++++------
src/backend/access/transam/xlogrecovery.c | 7 ++++---
src/backend/access/transam/xlogutils.c | 3 ++-
src/bin/pg_rewind/parsexlog.c | 3 ++-
src/bin/pg_waldump/pg_waldump.c | 5 ++---
src/include/access/xlogreader.h | 2 +-
9 files changed, 36 insertions(+), 23 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Make XLogRecGetBlockTag() throw error if there's no such block.
In-Reply-To: <E1ne1pM-00059Z-KZ@gemulon.postgresql.org>
References: <E1ne1pM-00059Z-KZ@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox