Skip to content

Commit aefa6d1

Browse files
committed
Add some CHECK_FOR_INTERRUPTS() calls to the heap-sort call path.
I broke this in commit 337b6f5, which among other things arranged for quicksorts to CHECK_FOR_INTERRUPTS() slightly less frequently. Sadly, it also arranged for heapsorts to CHECK_FOR_INTERRUPTS() much less frequently. Repair.
1 parent 64c6048 commit aefa6d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/backend/utils/sort/tuplesort.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ puttuple_common(Tuplesortstate *state, SortTuple *tuple)
11681168
{
11691169
/* new tuple <= top of the heap, so we can discard it */
11701170
free_sort_tuple(state, tuple);
1171+
CHECK_FOR_INTERRUPTS();
11711172
}
11721173
else
11731174
{
@@ -2431,6 +2432,7 @@ make_bounded_heap(Tuplesortstate *state)
24312432
{
24322433
/* New tuple would just get thrown out, so skip it */
24332434
free_sort_tuple(state, &state->memtuples[i]);
2435+
CHECK_FOR_INTERRUPTS();
24342436
}
24352437
else
24362438
{
@@ -2518,6 +2520,8 @@ tuplesort_heap_insert(Tuplesortstate *state, SortTuple *tuple,
25182520
memtuples = state->memtuples;
25192521
Assert(state->memtupcount < state->memtupsize);
25202522

2523+
CHECK_FOR_INTERRUPTS();
2524+
25212525
/*
25222526
* Sift-up the new entry, per Knuth 5.2.3 exercise 16. Note that Knuth is
25232527
* using 1-based array indexes, not 0-based.
@@ -2549,6 +2553,9 @@ tuplesort_heap_siftup(Tuplesortstate *state, bool checkIndex)
25492553

25502554
if (--state->memtupcount <= 0)
25512555
return;
2556+
2557+
CHECK_FOR_INTERRUPTS();
2558+
25522559
n = state->memtupcount;
25532560
tuple = &memtuples[n]; /* tuple that must be reinserted */
25542561
i = 0; /* i is where the "hole" is */

0 commit comments

Comments
 (0)