diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-05 22:32:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-05 22:32:58 +0000 |
commit | 9ab4d98168407c3436d3f0e02d32720b0d9075a0 (patch) | |
tree | 3572d316a54a99512277ead2ad757032998b2839 /src/backend/parser/parse_agg.c | |
parent | 22dbd540478517ff6c55381ae7ce07a3a2e64474 (diff) |
Remove planner's private fields from Query struct, and put them into
a new PlannerInfo struct, which is passed around instead of the bare
Query in all the planning code. This commit is essentially just a
code-beautification exercise, but it does open the door to making
larger changes to the planner data structures without having to muck
with the widely-known Query struct.
Diffstat (limited to 'src/backend/parser/parse_agg.c')
-rw-r--r-- | src/backend/parser/parse_agg.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 18a42c5742b..799bacd233e 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.68 2005/03/29 00:17:04 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.69 2005/06/05 22:32:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -101,6 +101,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry) bool have_non_var_grouping; ListCell *l; bool hasJoinRTEs; + PlannerInfo *root; Node *clause; /* This should only be called if we found aggregates or grouping */ @@ -162,9 +163,22 @@ parseCheckAggregates(ParseState *pstate, Query *qry) } } + /* + * We use the planner's flatten_join_alias_vars routine to do the + * flattening; it wants a PlannerInfo root node, which fortunately + * can be mostly dummy. + */ if (hasJoinRTEs) - groupClauses = (List *) flatten_join_alias_vars(qry, + { + root = makeNode(PlannerInfo); + root->parse = qry; + root->hasJoinRTEs = true; + + groupClauses = (List *) flatten_join_alias_vars(root, (Node *) groupClauses); + } + else + root = NULL; /* keep compiler quiet */ /* * Detect whether any of the grouping expressions aren't simple Vars; @@ -186,13 +200,13 @@ parseCheckAggregates(ParseState *pstate, Query *qry) */ clause = (Node *) qry->targetList; if (hasJoinRTEs) - clause = flatten_join_alias_vars(qry, clause); + clause = flatten_join_alias_vars(root, clause); check_ungrouped_columns(clause, pstate, groupClauses, have_non_var_grouping); clause = (Node *) qry->havingQual; if (hasJoinRTEs) - clause = flatten_join_alias_vars(qry, clause); + clause = flatten_join_alias_vars(root, clause); check_ungrouped_columns(clause, pstate, groupClauses, have_non_var_grouping); } |