From 34d26872ed816b299eef2fa4240d55316697f42d Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 15 Dec 2009 17:57:48 +0000 Subject: Support ORDER BY within aggregate function calls, at long last providing a non-kluge method for controlling the order in which values are fed to an aggregate function. At the same time eliminate the old implementation restriction that DISTINCT was only supported for single-argument aggregates. Possibly release-notable behavioral change: formerly, agg(DISTINCT x) dropped null values of x unconditionally. Now, it does so only if the agg transition function is strict; otherwise nulls are treated as DISTINCT normally would, ie, you get one copy. Andrew Gierth, reviewed by Hitoshi Harada --- src/backend/nodes/copyfuncs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/backend/nodes/copyfuncs.c') diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index c0bb01f1414..018f36cef60 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.453 2009/12/07 05:22:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.454 2009/12/15 17:57:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1023,9 +1023,10 @@ _copyAggref(Aggref *from) COPY_SCALAR_FIELD(aggfnoid); COPY_SCALAR_FIELD(aggtype); COPY_NODE_FIELD(args); - COPY_SCALAR_FIELD(agglevelsup); + COPY_NODE_FIELD(aggorder); + COPY_NODE_FIELD(aggdistinct); COPY_SCALAR_FIELD(aggstar); - COPY_SCALAR_FIELD(aggdistinct); + COPY_SCALAR_FIELD(agglevelsup); COPY_LOCATION_FIELD(location); return newnode; @@ -1968,6 +1969,7 @@ _copyFuncCall(FuncCall *from) COPY_NODE_FIELD(funcname); COPY_NODE_FIELD(args); + COPY_NODE_FIELD(agg_order); COPY_SCALAR_FIELD(agg_star); COPY_SCALAR_FIELD(agg_distinct); COPY_SCALAR_FIELD(func_variadic); -- cgit v1.2.3