From f0a9e64afd1d2401abc269274113e4384bf537b9 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 30 Nov 1996 17:49:02 +0000 Subject: As someone asked for this feature - patch for 1.09 follows. Now You can do queries like select sum(some_func(x)) from ... select min(table1.x + table2.y) from table1, table2 where ... and so on. Vadim --- src/backend/parser/parser.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/backend/parser/parser.c') diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index 79bac80c115..a77007c6f4c 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.12 1996/11/25 03:03:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.13 1996/11/30 17:49:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -434,13 +434,16 @@ ParseAgg(char *aggname, Oid basetype, Node *target) fintype = aggform->aggfinaltype; xfn1 = aggform->aggtransfn1; - if (nodeTag(target) != T_Var) - elog(WARN, "parser: aggregate can only be applied on an attribute"); + if (nodeTag(target) != T_Var && nodeTag(target) != T_Expr) + elog(WARN, "parser: aggregate can only be applied on an attribute or expression"); /* only aggregates with transfn1 need a base type */ if (OidIsValid(xfn1)) { basetype = aggform->aggbasetype; - vartype = ((Var*)target)->vartype; + if (nodeTag(target) == T_Var) + vartype = ((Var*)target)->vartype; + else + vartype = ((Expr*)target)->typeOid; if (basetype != vartype) { Type tp1, tp2, get_id_type(); -- cgit v1.2.3