From: Peter Geoghegan Date: Wed, 29 Jul 2020 23:00:52 +0000 (-0700) Subject: Backpatch tuplesort.c assertion. X-Git-Tag: REL_10_14~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fdbb97939b5519648414e032251559d331148bcf;p=thirdparty%2Fpostgresql.git Backpatch tuplesort.c assertion. Backpatch an assertion (that was originally added to Postgres 12 by commit dd299df8189) that seems broadly useful. The assertion can detect violations of the HOT invariant (i.e. no two index tuples can point to the same heap TID) when CREATE INDEX somehow incorrectly allows that to take place. For example, a IndexBuildHeapScan/heapam_index_build_range_scan bug might result in two tuples that both point to the same heap TID. If these two tuples also happen to be duplicates, the assertion will fail. Discussion: https://postgr.es/m/CAH2-WzmBxu4o=pMsniur+bwHqCGCmV_AOLkuK6BuU7ngA6evqw@mail.gmail.com Backpatch: 9.5-11 only --- diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index f895a3ae743..d49f024e431 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -4173,6 +4173,9 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b, return (pos1 < pos2) ? -1 : 1; } + /* ItemPointer values should never be equal */ + Assert(false); + return 0; } @@ -4225,6 +4228,9 @@ comparetup_index_hash(const SortTuple *a, const SortTuple *b, return (pos1 < pos2) ? -1 : 1; } + /* ItemPointer values should never be equal */ + Assert(false); + return 0; }