From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Replace RelationOpenSmgr() with RelationGetSmgr().
Date: Mon, 12 Jul 2021 21:01:55 +0000
Message-ID: <E1m333r-0005FO-0M@gemulon.postgresql.org> (raw)
Replace RelationOpenSmgr() with RelationGetSmgr().
The idea behind this patch is to design out bugs like the one fixed
by commit 9d523119f. Previously, once one did RelationOpenSmgr(rel),
it was considered okay to access rel->rd_smgr directly for some
not-very-clear interval. But since that pointer will be cleared by
relcache flushes, we had bugs arising from overreliance on a previous
RelationOpenSmgr call still being effective.
Now, very little code except that in rel.h and relcache.c should ever
touch the rd_smgr field directly. The normal coding rule is to use
RelationGetSmgr(rel) and not expect the result to be valid for longer
than one smgr function call. There are a couple of places where using
the function every single time seemed like overkill, but they are now
annotated with large warning comments.
Amul Sul, after an idea of mine.
Discussion: https://postgr.es/m/CANiYTQsU7yMFpQYnv=BrcRVqK_3U3mtAzAsJCaqtzsDHfsUbdQ@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/f10f0ae420ee62400876ab34dca2c09c20dcd030
Modified Files
--------------
contrib/amcheck/verify_nbtree.c | 3 +-
contrib/bloom/blinsert.c | 6 ++--
contrib/pg_prewarm/autoprewarm.c | 4 +--
contrib/pg_prewarm/pg_prewarm.c | 5 ++-
contrib/pg_visibility/pg_visibility.c | 6 ++--
src/backend/access/gist/gistbuild.c | 14 ++++----
src/backend/access/hash/hashpage.c | 4 +--
src/backend/access/heap/heapam_handler.c | 7 ++--
src/backend/access/heap/rewriteheap.c | 15 +++------
src/backend/access/heap/visibilitymap.c | 53 ++++++++++++++++---------------
src/backend/access/nbtree/nbtree.c | 6 ++--
src/backend/access/nbtree/nbtsort.c | 14 +++-----
src/backend/access/spgist/spginsert.c | 14 ++++----
src/backend/access/table/tableam.c | 7 ++--
src/backend/catalog/heap.c | 2 --
src/backend/catalog/index.c | 5 ++-
src/backend/catalog/storage.c | 46 ++++++++++++++++++---------
src/backend/commands/tablecmds.c | 7 ++--
src/backend/storage/buffer/bufmgr.c | 24 ++++----------
src/backend/storage/freespace/freespace.c | 52 ++++++++++++++++++------------
src/include/utils/rel.h | 37 +++++++++++++--------
21 files changed, 165 insertions(+), 166 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: Replace RelationOpenSmgr() with RelationGetSmgr().
In-Reply-To: <E1m333r-0005FO-0M@gemulon.postgresql.org>
References: <E1m333r-0005FO-0M@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