aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/nbtree/nbtutils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 54afa6f4176..bbe2fe4bce5 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2205,7 +2205,8 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
{
IndexTuple tidpivot;
- pivot = index_truncate_tuple(itupdesc, firstright, keepnatts);
+ pivot = index_truncate_tuple(itupdesc, firstright,
+ Min(keepnatts, nkeyatts));
if (BTreeTupleIsPosting(pivot))
{
@@ -2250,6 +2251,10 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
/*
* No truncation was possible, since key attributes are all equal.
* It's necessary to add a heap TID attribute to the new pivot tuple.
+ *
+ * This path is only taken when rel is not an INCLUDE index. It
+ * avoids a second palloc0() by avoiding the index_truncate_tuple()
+ * call completely.
*/
Assert(natts == nkeyatts);
newsize = IndexTupleSize(firstright) + MAXALIGN(sizeof(ItemPointerData));