>>>>> "Peter" == Peter Eisentraut <pete...@gmx.net> writes:
>> I'm not entirely convinced that adding ORDER BY here is a good idea, >> partly because it goes so far beyond the spec Peter> This is exactly the syntax that is in the spec AFAICT. Right. The spec defines this syntax for array_agg and xmlagg (only). The patch goes beyond the spec in that it allows ORDER BY for any aggregate at all, and also allows combination of ORDER BY and DISTINCT (the spec only allows DISTINCT with <general set operation> which doesn't include array_agg or xmlagg, so there is nowhere that both are allowed). But it would be entirely unreasonable, the way postgres works, to implement ORDER BY for only specific aggregates. (Note also that combining ORDER BY and DISTINCT can change the behaviour of DISTINCT. e.g. foo(distinct x order by x using <<<) will use whatever definition of equality is implied by the hypothetical <<< operator when comparing values of x for distinctness.) As for the null handling, the spec is no help there for this reason: it allows DISTINCT only for <general set operation>, and for all <general set operation>s whether DISTINCT or not, NULLs are always discarded from the input before processing (i.e. the behaviour we implement for strict aggregates). So even the fact that we allow array_agg(distinct x) at all is going beyond the spec and therefore doesn't have a defined result. -- Andrew (irc:RhodiumToad) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers