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

Function assignSortGroupRef

src/backend/parser/parse_clause.c:3772–3792  ·  view source on GitHub ↗

* assignSortGroupRef * Assign the targetentry an unused ressortgroupref, if it doesn't * already have one. Return the assigned or pre-existing refnumber. * * 'tlist' is the targetlist containing (or to contain) the given targetentry. */

Source from the content-addressed store, hash-verified

3770 * 'tlist' is the targetlist containing (or to contain) the given targetentry.
3771 */
3772Index
3773assignSortGroupRef(TargetEntry *tle, List *tlist)
3774{
3775 Index maxRef;
3776 ListCell *l;
3777
3778 if (tle->ressortgroupref) /* already has one? */
3779 return tle->ressortgroupref;
3780
3781 /* easiest way to pick an unused refnumber: max used + 1 */
3782 maxRef = 0;
3783 foreach(l, tlist)
3784 {
3785 Index ref = ((TargetEntry *) lfirst(l))->ressortgroupref;
3786
3787 if (ref > maxRef)
3788 maxRef = ref;
3789 }
3790 tle->ressortgroupref = maxRef + 1;
3791 return tle->ressortgroupref;
3792}
3793
3794/*
3795 * targetIsInSortList

Callers 6

addTargetToSortListFunction · 0.85
addTargetToGroupListFunction · 0.85
add_gsetid_tlistFunction · 0.85
create_unique_planFunction · 0.85
build_minmax_pathFunction · 0.85

Calls 1

foreachFunction · 0.50

Tested by

no test coverage detected