postgres.git / summary / log / commit / refs
commit e3ba932da39bbcc88e431bc9bb8178627f53b07d
Author: Peter Geoghegan <pg@bowt.ie>
Date: Wed Jul 29 23:00:50 2020 +0000
First released in: 9.5.23, 9.6.19, 10.14, 11.9
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
src/backend/utils/sort/tuplesort.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 47efd2e3b80..147889177fa 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -4536,6 +4536,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;
}
@@ -4585,6 +4588,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;
}
[parent: 8a60f541f3e4]