aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Geoghegan <pg@bowt.ie>2020-03-30 17:34:12 -0700
committerPeter Geoghegan <pg@bowt.ie>2020-03-30 17:34:12 -0700
commitf01157e2ac8ac4dff8ba159c36edf2fdb7d6704e (patch)
treec3985c26f709bb37f54dfd01c5d05e0edc9f4c1c
parentdd9ac7d5d80608a640bb82cffb6a805ce84cf112 (diff)
downloadpostgresql-f01157e2ac8ac4dff8ba159c36edf2fdb7d6704e.tar.gz
postgresql-f01157e2ac8ac4dff8ba159c36edf2fdb7d6704e.zip
Further simplify nbtree high key truncation.
Commit 7c2dbc69 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 7c2dbc69, 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.
-rw-r--r--src/backend/access/nbtree/nbtutils.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 610c7de1e51..aaa0c89c7dd 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2251,6 +2251,7 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
tidpivot->t_info |= newsize;
BTreeTupleSetNAtts(tidpivot, nkeyatts);
BTreeTupleSetAltHeapTID(tidpivot);
+ pivotheaptid = BTreeTupleGetHeapTID(tidpivot);
/*
* 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,
* TID. (This is also the closest value to negative infinity that's
* legally usable.)
*/
- pivotheaptid = (ItemPointer) ((char *) tidpivot + newsize -
- sizeof(ItemPointerData));
ItemPointerCopy(BTreeTupleGetMaxHeapTID(lastleft), pivotheaptid);
/*