Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4b42a89

Browse filesBrowse 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
Copy full SHA for 4b42a89

File tree

1 file changed

+6
-1
lines changed
Filter options

1 file changed

+6
-1
lines changed

‎src/backend/access/nbtree/nbtutils.c

Copy file name to clipboardExpand all lines: src/backend/access/nbtree/nbtutils.c
+6-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.