summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/sort/sortsupport.c15
-rw-r--r--src/backend/utils/sort/tuplesortvariants.c14
2 files changed, 12 insertions, 17 deletions
diff --git a/src/backend/utils/sort/sortsupport.c b/src/backend/utils/sort/sortsupport.c
index 6037031eaa3..0b4f08ed2ec 100644
--- a/src/backend/utils/sort/sortsupport.c
+++ b/src/backend/utils/sort/sortsupport.c
@@ -150,15 +150,15 @@ PrepareSortSupportFromOrderingOp(Oid orderingOp, SortSupport ssup)
}
/*
- * Fill in SortSupport given an index relation, attribute, and strategy.
+ * Fill in SortSupport given an index relation and attribute.
*
* Caller must previously have zeroed the SortSupportData structure and then
* filled in ssup_cxt, ssup_attno, ssup_collation, and ssup_nulls_first. This
- * will fill in ssup_reverse (based on the supplied strategy), as well as the
+ * will fill in ssup_reverse (based on the supplied argument), as well as the
* comparator function pointer.
*/
void
-PrepareSortSupportFromIndexRel(Relation indexRel, int16 strategy,
+PrepareSortSupportFromIndexRel(Relation indexRel, bool reverse,
SortSupport ssup)
{
Oid opfamily = indexRel->rd_opfamily[ssup->ssup_attno - 1];
@@ -166,12 +166,9 @@ PrepareSortSupportFromIndexRel(Relation indexRel, int16 strategy,
Assert(ssup->comparator == NULL);
- if (indexRel->rd_rel->relam != BTREE_AM_OID)
- elog(ERROR, "unexpected non-btree AM: %u", indexRel->rd_rel->relam);
- if (strategy != BTGreaterStrategyNumber &&
- strategy != BTLessStrategyNumber)
- elog(ERROR, "unexpected sort support strategy: %d", strategy);
- ssup->ssup_reverse = (strategy == BTGreaterStrategyNumber);
+ if (!indexRel->rd_indam->amcanorder)
+ elog(ERROR, "unexpected non-amcanorder AM: %u", indexRel->rd_rel->relam);
+ ssup->ssup_reverse = reverse;
FinishSortSupportFunction(opfamily, opcintype, ssup);
}
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index eb8601e2257..4059af5bb71 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -329,7 +329,7 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
{
SortSupport sortKey = base->sortKeys + i;
ScanKey scanKey = indexScanKey->scankeys + i;
- int16 strategy;
+ bool reverse;
sortKey->ssup_cxt = CurrentMemoryContext;
sortKey->ssup_collation = scanKey->sk_collation;
@@ -341,10 +341,9 @@ tuplesort_begin_cluster(TupleDesc tupDesc,
Assert(sortKey->ssup_attno != 0);
- strategy = (scanKey->sk_flags & SK_BT_DESC) != 0 ?
- BTGreaterStrategyNumber : BTLessStrategyNumber;
+ reverse = (scanKey->sk_flags & SK_BT_DESC) != 0;
- PrepareSortSupportFromIndexRel(indexRel, strategy, sortKey);
+ PrepareSortSupportFromIndexRel(indexRel, reverse, sortKey);
}
pfree(indexScanKey);
@@ -412,7 +411,7 @@ tuplesort_begin_index_btree(Relation heapRel,
{
SortSupport sortKey = base->sortKeys + i;
ScanKey scanKey = indexScanKey->scankeys + i;
- int16 strategy;
+ bool reverse;
sortKey->ssup_cxt = CurrentMemoryContext;
sortKey->ssup_collation = scanKey->sk_collation;
@@ -424,10 +423,9 @@ tuplesort_begin_index_btree(Relation heapRel,
Assert(sortKey->ssup_attno != 0);
- strategy = (scanKey->sk_flags & SK_BT_DESC) != 0 ?
- BTGreaterStrategyNumber : BTLessStrategyNumber;
+ reverse = (scanKey->sk_flags & SK_BT_DESC) != 0;
- PrepareSortSupportFromIndexRel(indexRel, strategy, sortKey);
+ PrepareSortSupportFromIndexRel(indexRel, reverse, sortKey);
}
pfree(indexScanKey);