Skip to content

Commit 2110f71

Browse files
nbtree: Tweak _bt_pgaddtup() comments.
Make it clear that _bt_pgaddtup() truncates the first data item on an internal page because its key is supposed to be treated as minus infinity within _bt_compare().
1 parent bf2efc5 commit 2110f71

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/backend/access/nbtree/nbtinsert.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,10 +2230,10 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
22302230
*
22312231
* The main difference between this routine and a bare PageAddItem call
22322232
* is that this code knows that the leftmost index tuple on a non-leaf
2233-
* btree page doesn't need to have a key. Therefore, it strips such
2234-
* tuples down to just the tuple header. CAUTION: this works ONLY if
2235-
* we insert the tuples in order, so that the given itup_off does
2236-
* represent the final position of the tuple!
2233+
* btree page has a key that must be treated as minus infinity.
2234+
* Therefore, it truncates away all attributes. CAUTION: this works
2235+
* ONLY if we insert the tuples in order, so that the given itup_off
2236+
* does represent the final position of the tuple!
22372237
*/
22382238
static bool
22392239
_bt_pgaddtup(Page page,
@@ -2248,7 +2248,6 @@ _bt_pgaddtup(Page page,
22482248
{
22492249
trunctuple = *itup;
22502250
trunctuple.t_info = sizeof(IndexTupleData);
2251-
/* Deliberately zero INDEX_ALT_TID_MASK bits */
22522251
BTreeTupleSetNAtts(&trunctuple, 0);
22532252
itup = &trunctuple;
22542253
itemsize = sizeof(IndexTupleData);

src/backend/access/nbtree/nbtsort.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ _bt_slideleft(Page page)
756756
* Add an item to a page being built.
757757
*
758758
* The main difference between this routine and a bare PageAddItem call
759-
* is that this code knows that the leftmost data item on a non-leaf
760-
* btree page doesn't need to have a key. Therefore, it strips such
761-
* items down to just the item header.
759+
* is that this code knows that the leftmost data item on a non-leaf btree
760+
* page has a key that must be treated as minus infinity. Therefore, it
761+
* truncates away all attributes.
762762
*
763763
* This is almost like nbtinsert.c's _bt_pgaddtup(), but we can't use
764764
* that because it assumes that P_RIGHTMOST() will return the correct
@@ -778,7 +778,6 @@ _bt_sortaddtup(Page page,
778778
{
779779
trunctuple = *itup;
780780
trunctuple.t_info = sizeof(IndexTupleData);
781-
/* Deliberately zero INDEX_ALT_TID_MASK bits */
782781
BTreeTupleSetNAtts(&trunctuple, 0);
783782
itup = &trunctuple;
784783
itemsize = sizeof(IndexTupleData);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy