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 93fab264ae4..a1e7636adb1 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2143,7 +2143,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 there is a distinguishing key attribute within new pivot tuple,
@@ -2173,6 +2174,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));