From: Robert Haas Date: Tue, 14 Feb 2012 17:26:30 +0000 (-0500) Subject: Call CHECK_FOR_INTERRUPTS slightly less often when tuplesorting. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=51b839de605ec2b065925024396416eb872e593e;p=users%2Frhaas%2Fpostgres.git Call CHECK_FOR_INTERRUPTS slightly less often when tuplesorting. --- diff --git a/src/backend/utils/sort/qsort_tuple.c b/src/backend/utils/sort/qsort_tuple.c index b3d75743cd..f751007ada 100644 --- a/src/backend/utils/sort/qsort_tuple.c +++ b/src/backend/utils/sort/qsort_tuple.c @@ -98,6 +98,7 @@ qsort_tuple(SortTuple *a, size_t n, SortTupleComparator cmp, presorted; loop: + CHECK_FOR_INTERRUPTS(); if (n < 7) { for (pm = a + 1; pm < a + n; pm++) @@ -108,6 +109,7 @@ loop: presorted = 1; for (pm = a + 1; pm < a + n; pm++) { + CHECK_FOR_INTERRUPTS(); if (cmp(pm - 1, pm, state) > 0) { presorted = 0; @@ -137,6 +139,7 @@ loop: { while (pb <= pc && (r = cmp(pb, a, state)) <= 0) { + CHECK_FOR_INTERRUPTS(); if (r == 0) { swap(pa, pb); @@ -146,6 +149,7 @@ loop: } while (pb <= pc && (r = cmp(pc, a, state)) >= 0) { + CHECK_FOR_INTERRUPTS(); if (r == 0) { swap(pc, pd); diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 6d7012afb9..0dfe9fb9f1 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -2666,9 +2666,6 @@ comparetup_heap(const SortTuple *a, const SortTuple *b, Tuplesortstate *state) int nkey; int32 compare; - /* Allow interrupting long sorts */ - CHECK_FOR_INTERRUPTS(); - /* Compare the leading sort key */ compare = ApplySortComparator(a->datum1, a->isnull1, b->datum1, b->isnull1, @@ -2810,9 +2807,6 @@ comparetup_cluster(const SortTuple *a, const SortTuple *b, int nkey; int32 compare; - /* Allow interrupting long sorts */ - CHECK_FOR_INTERRUPTS(); - /* Compare the leading sort key, if it's simple */ if (state->indexInfo->ii_KeyAttrNumbers[0] != 0) { @@ -3001,9 +2995,6 @@ comparetup_index_btree(const SortTuple *a, const SortTuple *b, int nkey; int32 compare; - /* Allow interrupting long sorts */ - CHECK_FOR_INTERRUPTS(); - /* Compare the leading sort key */ compare = inlineApplySortFunction(&scanKey->sk_func, scanKey->sk_flags, scanKey->sk_collation, @@ -3108,9 +3099,6 @@ comparetup_index_hash(const SortTuple *a, const SortTuple *b, IndexTuple tuple1; IndexTuple tuple2; - /* Allow interrupting long sorts */ - CHECK_FOR_INTERRUPTS(); - /* * Fetch hash keys and mask off bits we don't want to sort by. We know * that the first column of the index tuple is the hash key. @@ -3237,9 +3225,6 @@ reversedirection_index_hash(Tuplesortstate *state) static int comparetup_datum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state) { - /* Allow interrupting long sorts */ - CHECK_FOR_INTERRUPTS(); - return ApplySortComparator(a->datum1, a->isnull1, b->datum1, b->isnull1, state->datumKey);