Skip to content

Commit 87eb255

Browse files
Backpatch tuplesort.c assertion.
Backpatch an assertion (that was originally added to Postgres 12 by commit dd299df) 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
1 parent baecd27 commit 87eb255

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,9 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b,
40764076
return (pos1 < pos2) ? -1 : 1;
40774077
}
40784078

4079+
/* ItemPointer values should never be equal */
4080+
Assert(false);
4081+
40794082
return 0;
40804083
}
40814084

@@ -4128,6 +4131,9 @@ comparetup_index_hash(const SortTuple *a, const SortTuple *b,
41284131
return (pos1 < pos2) ? -1 : 1;
41294132
}
41304133

4134+
/* ItemPointer values should never be equal */
4135+
Assert(false);
4136+
41314137
return 0;
41324138
}
41334139

0 commit comments

Comments
 (0)