* For ordered-set aggregates, it's somewhat unclear how best to proceed. * The spec-defined inverse distribution functions have only one sort column * and don't return collatable types, but this is clearly too restrictive in * the general case. Our solution is to consider that the aggregate's direct * arguments contribute normally to determination of the aggregate's own * collation, while ag
| 921 | * Otherwise this is much like the plain-aggregate case. |
| 922 | */ |
| 923 | static void |
| 924 | assign_ordered_set_collations(Aggref *aggref, |
| 925 | assign_collations_context *loccontext) |
| 926 | { |
| 927 | bool merge_sort_collations; |
| 928 | ListCell *lc; |
| 929 | |
| 930 | /* Merge sort collations to parent only if there can be only one */ |
| 931 | merge_sort_collations = (list_length(aggref->args) == 1 && |
| 932 | get_func_variadictype(aggref->aggfnoid) == InvalidOid); |
| 933 | |
| 934 | /* Direct args, if any, are normal children of the Aggref node */ |
| 935 | (void) assign_collations_walker((Node *) aggref->aggdirectargs, |
| 936 | loccontext); |
| 937 | |
| 938 | /* Process aggregated args appropriately */ |
| 939 | foreach(lc, aggref->args) |
| 940 | { |
| 941 | TargetEntry *tle = lfirst_node(TargetEntry, lc); |
| 942 | |
| 943 | if (merge_sort_collations) |
| 944 | (void) assign_collations_walker((Node *) tle, loccontext); |
| 945 | else |
| 946 | assign_expr_collations(loccontext->pstate, (Node *) tle); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | /* |
| 951 | * Hypothetical-set aggregates are even more special: per spec, we need to |
no test coverage detected