pgsql: nbtree: Use raw PageAddItem() for retail inserts. - Mailing list pgsql-committers

From Peter Geoghegan
Subject pgsql: nbtree: Use raw PageAddItem() for retail inserts.
Date
Msg-id E1jEjot-0003XJ-6M@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
nbtree: Use raw PageAddItem() for retail inserts.

Only internal page splits need to call _bt_pgaddtup() instead of
PageAddItem(), and only for data items, one of which will end up at the
first offset (or first offset after the high key offset) on the new
right page.  This data item alone will need to be truncated in
_bt_pgaddtup().

Since there is no reason why retail inserts ever need to truncate the
incoming item, use a raw PageAddItem() call there instead.  Even
_bt_split() uses raw PageAddItem() calls for left page and right page
high keys.  Clearly the _bt_pgaddtup() shim function wasn't really
encapsulating anything.  _bt_pgaddtup() should now be thought of as a
_bt_split() helper function.

Note that the assertions from commit d1e241c2 verify that retail inserts
never insert an item at an internal page's negative infinity offset.
This invariant could only ever be violated as a result of a basic logic
error in nbtinsert.c.

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6312c08a291fc34068571ec64ee439f2674d739a

Modified Files
--------------
src/backend/access/nbtree/nbtinsert.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Fix comment related to concurrent index swapping in index.c
Next
From: Amit Kapila
Date:
Subject: pgsql: Add assert to ensure that page locks don't participate in deadlo