* 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
| 3811 | * is that a TLE might be in only one of the lists. |
| 3812 | */ |
| 3813 | bool |
| 3814 | targetIsInSortList(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 |
no test coverage detected