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

Function targetIsInSortList

src/backend/parser/parse_clause.c:3813–3834  ·  view source on GitHub ↗

* targetIsInSortList * Is the given target item already in the sortlist? * If sortop is not InvalidOid, also test for a match to the sortop. * * It is not an oversight that this function ignores the nulls_first flag. * We check sortop when determining if an ORDER BY item is redundant with * earlier ORDER BY items, because it's conceivable that "ORDER BY * foo USING <, foo USING <<<" is no

Source from the content-addressed store, hash-verified

3811 * is that a TLE might be in only one of the lists.
3812 */
3813bool
3814targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList)
3815{
3816 Index ref = tle->ressortgroupref;
3817 ListCell *l;
3818
3819 /* no need to scan list if tle has no marker */
3820 if (ref == 0)
3821 return false;
3822
3823 foreach(l, sortList)
3824 {
3825 SortGroupClause *scl = (SortGroupClause *) lfirst(l);
3826
3827 if (scl->tleSortGroupRef == ref &&
3828 (sortop == InvalidOid ||
3829 sortop == scl->sortop ||
3830 sortop == get_commutator(scl->sortop)))
3831 return true;
3832 }
3833 return false;
3834}
3835
3836/*
3837 * findWindowClause

Callers 7

examine_simple_variableFunction · 0.85
transformGroupClauseExprFunction · 0.85
addTargetToSortListFunction · 0.85
addTargetToGroupListFunction · 0.85
check_output_expressionsFunction · 0.85

Calls 2

get_commutatorFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected