pgsql: nbtree: Use raw PageAddItem() for retail inserts.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: nbtree: Use raw PageAddItem() for retail inserts.
Date: 2020-03-19 01:17:59
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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

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.



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

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2020-03-19 02:26:17 Re: pgsql: walreceiver uses a temporary replication slot by default
Previous Message Michael Paquier 2020-03-19 00:52:56 pgsql: Fix comment related to concurrent index swapping in index.c