mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
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
This commit is contained in:
@ -2933,7 +2933,7 @@ transformWindowDefinitions(ParseState *pstate,
|
||||
sortcl->sortop);
|
||||
/* Record properties of sort ordering */
|
||||
wc->inRangeColl = exprCollation(sortkey);
|
||||
wc->inRangeAsc = (rangestrategy == BTLessStrategyNumber);
|
||||
wc->inRangeAsc = !sortcl->reverse_sort;
|
||||
wc->inRangeNullsFirst = sortcl->nulls_first;
|
||||
}
|
||||
|
||||
@ -3489,6 +3489,7 @@ addTargetToSortList(ParseState *pstate, TargetEntry *tle,
|
||||
sortcl->eqop = eqop;
|
||||
sortcl->sortop = sortop;
|
||||
sortcl->hashable = hashable;
|
||||
sortcl->reverse_sort = reverse;
|
||||
|
||||
switch (sortby->sortby_nulls)
|
||||
{
|
||||
@ -3571,6 +3572,8 @@ addTargetToGroupList(ParseState *pstate, TargetEntry *tle,
|
||||
grpcl->tleSortGroupRef = assignSortGroupRef(tle, targetlist);
|
||||
grpcl->eqop = eqop;
|
||||
grpcl->sortop = sortop;
|
||||
grpcl->reverse_sort = false; /* sortop is "less than", or
|
||||
* InvalidOid */
|
||||
grpcl->nulls_first = false; /* OK with or without sortop */
|
||||
grpcl->hashable = hashable;
|
||||
|
||||
|
Reference in New Issue
Block a user