Skip to content

Commit 1f55eba

Browse files
Make _bt_keep_natts_fast() use datum_image_eq().
An upcoming patch that adds deduplication to the nbtree AM will rely on _bt_keep_natts_fast() understanding that differences in TOAST input state can never affect its answer. In particular, two opclass-equal datums (with opclasses deemed safe for deduplication) should never be treated as unequal by _bt_keep_natts_fast() due to TOAST input differences. This also seems like a good idea on general principle. nbtsplitloc.c will now occasionally make better decisions about where to split a leaf page. The behavior of _bt_keep_natts_fast() is now somewhat closer to the behavior of _bt_keep_natts(). Discussion: https://postgr.es/m/CAH2-Wzn3Ee49Gmxb7V1VJ3-AC8fWn-Fr8pfWQebHe8rYRxt5OQ@mail.gmail.com
1 parent dcb7d3c commit 1f55eba

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/backend/access/nbtree/nbtutils.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,9 +2303,7 @@ _bt_keep_natts(Relation rel, IndexTuple lastleft, IndexTuple firstright,
23032303
* The approach taken here usually provides the same answer as _bt_keep_natts
23042304
* will (for the same pair of tuples from a heapkeyspace index), since the
23052305
* majority of btree opclasses can never indicate that two datums are equal
2306-
* unless they're bitwise equal (once detoasted). Similarly, result may
2307-
* differ from the _bt_keep_natts result when either tuple has TOASTed datums,
2308-
* though this is barely possible in practice.
2306+
* unless they're bitwise equal after detoasting.
23092307
*
23102308
* These issues must be acceptable to callers, typically because they're only
23112309
* concerned about making suffix truncation as effective as possible without
@@ -2337,7 +2335,7 @@ _bt_keep_natts_fast(Relation rel, IndexTuple lastleft, IndexTuple firstright)
23372335
break;
23382336

23392337
if (!isNull1 &&
2340-
!datumIsEqual(datum1, datum2, att->attbyval, att->attlen))
2338+
!datum_image_eq(datum1, datum2, att->attbyval, att->attlen))
23412339
break;
23422340

23432341
keepnatts++;

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