* 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
| 1653 | * 'tlist' is the targetlist to find the referenced tlist entries in |
| 1654 | */ |
| 1655 | List * |
| 1656 | make_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 |
no test coverage detected