From db436adf761bd5cb7990745ceba2959ac4bfca7c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 21 Aug 1999 03:49:17 +0000 Subject: Major revision of sort-node handling: push knowledge of query sort order down into planner, instead of handling it only at the very top level of the planner. This fixes many things. An explicit sort is now avoided if there is a cheaper alternative (typically an indexscan) not only for ORDER BY, but also for the internal sort of GROUP BY. It works even when there is no other reason (such as a WHERE condition) to consider the indexscan. It works for indexes on functions. It works for indexes on functions, backwards. It's just so cool... CAUTION: I have changed the representation of SortClause nodes, therefore THIS UPDATE BREAKS STORED RULES. You will need to initdb. --- src/backend/parser/parse_agg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/backend/parser/parse_agg.c') diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 3cca6d681fc..a5007822976 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.27 1999/08/16 02:10:13 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.28 1999/08/21 03:48:55 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -154,7 +154,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry) GroupClause *grpcl = lfirst(tl); Node *expr; - expr = (Node *) get_groupclause_expr(grpcl, qry->targetList); + expr = get_sortgroupclause_expr(grpcl, qry->targetList); if (contain_agg_clause(expr)) elog(ERROR, "Aggregates not allowed in GROUP BY clause"); groupClauses = lcons(expr, groupClauses); @@ -293,10 +293,8 @@ ParseAgg(ParseState *pstate, char *aggname, Oid basetype, aggref->aggname = pstrdup(aggname); aggref->basetype = aggform->aggbasetype; aggref->aggtype = fintype; - aggref->target = lfirst(target); - if (usenulls) - aggref->usenulls = true; + aggref->usenulls = usenulls; pstate->p_hasAggs = true; -- cgit v1.2.3