Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f01157e

Browse files
Further simplify nbtree high key truncation.
Commit 7c2dbc6 reorganized _bt_truncate() in a way that enables a further simplification that I (pgeoghegan) missed: Since we mark the tuple that is returned to the caller as a pivot tuple before the point where its heap TID is set as of 7c2dbc6, it is possible to use the high level BTreeTupleGetHeapTID() inline function to get an item pointer. Do it that way now. This approach is clearer and more maintainable.
1 parent dd9ac7d commit f01157e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/backend/access/nbtree/nbtutils.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -2251,6 +2251,7 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
22512251
tidpivot->t_info |= newsize;
22522252
BTreeTupleSetNAtts(tidpivot, nkeyatts);
22532253
BTreeTupleSetAltHeapTID(tidpivot);
2254+
pivotheaptid = BTreeTupleGetHeapTID(tidpivot);
22542255

22552256
/*
22562257
* Lehman & Yao use lastleft as the leaf high key in all cases, but don't
@@ -2259,8 +2260,6 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
22592260
* TID. (This is also the closest value to negative infinity that's
22602261
* legally usable.)
22612262
*/
2262-
pivotheaptid = (ItemPointer) ((char *) tidpivot + newsize -
2263-
sizeof(ItemPointerData));
22642263
ItemPointerCopy(BTreeTupleGetMaxHeapTID(lastleft), pivotheaptid);
22652264

22662265
/*

0 commit comments

Comments
 (0)