Andrew Gierth <and...@tao11.riddles.org.uk> writes: > Updated version of the aggregate order by patch.
Applied with some editorialization. The main change I made was to get rid of all the ad-hoc DISTINCT handling in parse_agg.c and use transformDistinctClause() instead. This exposed what I believe to be a bug in the submitted patch: it accepted cases like agg(DISTINCT x ORDER BY x,y) We do not allow that in ordinary query-level DISTINCT because it's ambiguous --- there might be multiple y values for any particular value of x, so the ordering is uncertain. The only way it's not uncertain is if the sort by x fully determines the order, in which case listing y is merely useless. I think this is something that was changed not too long ago, so maybe you were trying to emulate the old behavior, but in any case it's better to not have extra code that doesn't behave quite like the normal case. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers