From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Replace RelationOpenSmgr() with RelationGetSmgr(). |
Date: | 2021-07-12 21:01:55 |
Message-ID: | E1m333r-0005FO-0M@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-07-12 23:17:53 | pgsql: Probe for preadv/pwritev in a more macOS-friendly way. |
Previous Message | Peter Eisentraut | 2021-07-12 20:21:14 | pgsql: doc: Fix typo in function prototype |