On Tue, 2008-01-29 at 13:06 +0100, Peter Eisentraut wrote:
> The ORDER BY clause would also used in XMLAGG, so we should try to parse this
> in a generalized way.
Yeah, that should be doable. We could go further and expose ORDER BY to
CREATE AGGREGATE, so that users could write aggregates that are
guaranteed to see their input in a certain order. This would be rather
more complicated to implement, though (for one thing, you couldn't do
the "qsort in the final function" trick -- the input to the agg would
need to be presented in the right order, which might differ from the
ordering required by the rest of the query block. We'll need to arrange
for something vaguely similar to do window functions, though.)
-Neil