pgsql: nbtree: Allocate new pages in separate function.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: nbtree: Allocate new pages in separate function.
Date: 2023-06-10 21:09:11
Message-ID: E1q85pf-0019X8-7W@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

nbtree: Allocate new pages in separate function.

Split nbtree's _bt_getbuf function is two: code that read locks or write
locks existing pages remains in _bt_getbuf, while code that deals with
allocating new pages is moved to a new, dedicated function called
_bt_allocbuf. This simplifies most _bt_getbuf callers, since it is no
longer necessary for them to pass a heaprel argument. Many of the
changes to nbtree from commit 61b313e4 can be reverted. This minimizes
the divergence between HEAD/PostgreSQL 16 and earlier release branches.

_bt_allocbuf replaces the previous nbtree idiom of passing P_NEW to
_bt_getbuf. There are only 3 affected call sites, all of which continue
to pass a heaprel for recovery conflict purposes. Note that nbtree's
use of P_NEW was superficial; nbtree never actually relied on the P_NEW
code paths in bufmgr.c, so this change is strictly mechanical.

GiST already took the same approach; it has a dedicated function for
allocating new pages called gistNewBuffer(). That factor allowed commit
61b313e4 to make much more targeted changes to GiST.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-By: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Discussion: https://postgr.es/m/CAH2-Wz=8Z9qY58bjm_7TAHgtW6RzZ5Ke62q5emdCEy9BAzwhmg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d088ba5a5aa410d39b64f013e8433ad9eb3d17f1

Modified Files
--------------
contrib/amcheck/verify_nbtree.c | 15 +-
src/backend/access/heap/heapam_handler.c | 9 +-
src/backend/access/nbtree/nbtinsert.c | 48 ++--
src/backend/access/nbtree/nbtpage.c | 354 +++++++++++++++--------------
src/backend/access/nbtree/nbtree.c | 4 +-
src/backend/access/nbtree/nbtsearch.c | 48 ++--
src/backend/access/nbtree/nbtsort.c | 2 +-
src/backend/access/nbtree/nbtutils.c | 7 +-
src/backend/optimizer/util/plancat.c | 2 +-
src/backend/utils/sort/tuplesortvariants.c | 5 +-
src/include/access/nbtree.h | 26 ++-
src/include/utils/tuplesort.h | 4 +-
12 files changed, 269 insertions(+), 255 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2023-06-11 01:34:14 pgsql: Fix missing initializations of MyProc.delayChkptEnd
Previous Message Peter Geoghegan 2023-06-10 20:55:56 pgsql: Add another old commit to git-blame-ignore-revs.