diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2024-10-14 15:36:02 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2024-10-14 15:36:02 +0200 |
commit | 0d2aa4d4937bb0500823edfc7d620f4e5fa45b9c (patch) | |
tree | b5165a7924bd11544d649daac2052a649b7e6b3f /src/backend/optimizer/path/pathkeys.c | |
parent | e7d0cf42b1acb185edc947a8732843966ea3c160 (diff) |
Track sort direction in SortGroupClause
Functions make_pathkey_from_sortop() and transformWindowDefinitions(),
which receive a SortGroupClause, were determining the sort order
(ascending vs. descending) by comparing that structure's operator
strategy to BTLessStrategyNumber, but could just as easily have gotten
it from the SortGroupClause object, if it had such a field, so add
one. This reduces the number of places that hardcode the assumption
that the strategy refers specifically to a btree strategy, rather than
some other index AM's operators.
Author: Mark Dilger <mark.dilger@enterprisedb.com>
Discussion: https://www.postgresql.org/message-id/flat/E72EAA49-354D-4C2E-8EB9-255197F55330@enterprisedb.com
Diffstat (limited to 'src/backend/optimizer/path/pathkeys.c')
-rw-r--r-- | src/backend/optimizer/path/pathkeys.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 035bbaa3856..7cf15e89b63 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -256,6 +256,7 @@ static PathKey * make_pathkey_from_sortop(PlannerInfo *root, Expr *expr, Oid ordering_op, + bool reverse_sort, bool nulls_first, Index sortref, bool create_it) @@ -279,7 +280,7 @@ make_pathkey_from_sortop(PlannerInfo *root, opfamily, opcintype, collation, - (strategy == BTGreaterStrategyNumber), + reverse_sort, nulls_first, sortref, NULL, @@ -1411,6 +1412,7 @@ make_pathkeys_for_sortclauses_extended(PlannerInfo *root, pathkey = make_pathkey_from_sortop(root, sortkey, sortcl->sortop, + sortcl->reverse_sort, sortcl->nulls_first, sortcl->tleSortGroupRef, true); |