Skip to content

Commit 4b42a89

Browse files
Consistently truncate non-key suffix columns.
INCLUDE indexes failed to have their non-key attributes physically truncated away in certain rare cases. This led to physically larger pivot tuples that contained useless non-key attribute values. The impact on users should be negligible, but this is still clearly a regression (Postgres 11 supports INCLUDE indexes, and yet was not affected). The bug appeared in commit dd299df, which introduced "true" suffix truncation of key attributes. Discussion: https://postgr.es/m/CAH2-Wz=E8pkV9ivRSFHtv812H5ckf8s1-yhx61_WrJbKccGcrQ@mail.gmail.com Backpatch: 12-, where "true" suffix truncation was introduced.
1 parent 911e702 commit 4b42a89

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/access/nbtree/nbtutils.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,8 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
22052205
{
22062206
IndexTuple tidpivot;
22072207

2208-
pivot = index_truncate_tuple(itupdesc, firstright, keepnatts);
2208+
pivot = index_truncate_tuple(itupdesc, firstright,
2209+
Min(keepnatts, nkeyatts));
22092210

22102211
if (BTreeTupleIsPosting(pivot))
22112212
{
@@ -2250,6 +2251,10 @@ _bt_truncate(Relation rel, IndexTuple lastleft, IndexTuple firstright,
22502251
/*
22512252
* No truncation was possible, since key attributes are all equal.
22522253
* It's necessary to add a heap TID attribute to the new pivot tuple.
2254+
*
2255+
* This path is only taken when rel is not an INCLUDE index. It
2256+
* avoids a second palloc0() by avoiding the index_truncate_tuple()
2257+
* call completely.
22532258
*/
22542259
Assert(natts == nkeyatts);
22552260
newsize = IndexTupleSize(firstright) + MAXALIGN(sizeof(ItemPointerData));

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