MCPcopy Create free account
hub / github.com/apache/cloudberry / make_pathkeys_for_sortclauses

Function make_pathkeys_for_sortclauses

src/backend/optimizer/path/pathkeys.c:1655–1684  ·  view source on GitHub ↗

* make_pathkeys_for_sortclauses * Generate a pathkeys list that represents the sort order specified * by a list of SortGroupClauses * * The resulting PathKeys are always in canonical form. (Actually, there * is no longer any code anywhere that creates non-canonical PathKeys.) * * We assume that root->nullable_baserels is the set of base relids that could * have gone to NULL below the So

Source from the content-addressed store, hash-verified

1653 * 'tlist' is the targetlist to find the referenced tlist entries in
1654 */
1655List *
1656make_pathkeys_for_sortclauses(PlannerInfo *root,
1657 List *sortclauses,
1658 List *tlist)
1659{
1660 List *pathkeys = NIL;
1661 ListCell *l;
1662
1663 foreach(l, sortclauses)
1664 {
1665 SortGroupClause *sortcl = (SortGroupClause *) lfirst(l);
1666 Expr *sortkey;
1667 PathKey *pathkey;
1668
1669 sortkey = (Expr *) get_sortgroupclause_expr(sortcl, tlist);
1670 Assert(OidIsValid(sortcl->sortop));
1671 pathkey = make_pathkey_from_sortop(root,
1672 sortkey,
1673 root->nullable_baserels,
1674 sortcl->sortop,
1675 sortcl->nulls_first,
1676 sortcl->tleSortGroupRef,
1677 true);
1678
1679 /* Canonical form eliminates redundant ordering keys */
1680 if (!pathkey_is_redundant(pathkey, pathkeys))
1681 pathkeys = lappend(pathkeys, pathkey);
1682 }
1683 return pathkeys;
1684}
1685
1686/****************************************************************************
1687 * DISTRIBUTION KEYS

Callers 7

minmax_qp_callbackFunction · 0.85
grouping_plannerFunction · 0.85
standard_qp_callbackFunction · 0.85
make_pathkeys_for_windowFunction · 0.85
generate_nonunion_pathsFunction · 0.85
make_union_uniqueFunction · 0.85

Calls 5

get_sortgroupclause_exprFunction · 0.85
make_pathkey_from_sortopFunction · 0.85
pathkey_is_redundantFunction · 0.85
lappendFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected