Gokulakannan Somasundaram <gokul007@gmail.com> writes:
> I noticed a problem with the source code of 9.0Alpha 4. In parse_agg.c,
> there is a call made to transformSortClause.
> ...
> Here agg->aggorder should be a List of SortGroupClause pointers, whereas
> transformSortClause expects the second argument as a list of SortBy
> pointers.
Uh, no, read the comment at the head of transformAggregateCall:
* parse_func.c has recognized the function as an aggregate, and has set* up all the fields of the Aggref except
aggdistinctand agglevelsup.* However, the args list is just bare expressions, and the aggorder list* hasn't been
transformedat all.** Here we convert the args list into a targetlist by inserting TargetEntry* nodes, and then
transformthe aggorder and agg_distinct specifications to* produce lists of SortGroupClause nodes. (That might also
resultin adding* resjunk expressions to the targetlist.)
transformSortClause is passed the untransformed aggorder list, which is
in fact a list of SortBy nodes, and it returns the transformed list
(SortGroupClause nodes), which is stored back into the aggorder field
a bit further down.
There are a number of regression tests that would fail in obvious ways
if this code didn't work.
regards, tom lane