Commit 8dc48ba8 authored by Bruce Momjian's avatar Bruce Momjian

Small HAVING cleanup.

parent 9fbdda03
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.20 1998/02/26 04:32:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.21 1998/03/31 23:30:49 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -187,7 +187,9 @@ query_planner(Query *root, ...@@ -187,7 +187,9 @@ query_planner(Query *root,
*/ */
if (constant_qual) if (constant_qual)
{ {
subplan = (Plan *) make_result((!root->hasAggs && !root->groupClause) subplan = (Plan *) make_result((!root->hasAggs &&
!root->groupClause &&
!root->havingQual)
? tlist : subplan->targetlist, ? tlist : subplan->targetlist,
(Node *) constant_qual, (Node *) constant_qual,
subplan); subplan);
...@@ -195,7 +197,7 @@ query_planner(Query *root, ...@@ -195,7 +197,7 @@ query_planner(Query *root,
/* /*
* Change all varno's of the Result's node target list. * Change all varno's of the Result's node target list.
*/ */
if (!root->hasAggs && !root->groupClause) if (!root->hasAggs && !root->groupClause && !root->havingQual)
set_tlist_references(subplan); set_tlist_references(subplan);
return subplan; return subplan;
...@@ -216,7 +218,7 @@ query_planner(Query *root, ...@@ -216,7 +218,7 @@ query_planner(Query *root,
*/ */
else else
{ {
if (!root->hasAggs && !root->groupClause) if (!root->hasAggs && !root->groupClause && !root->havingQual)
subplan->targetlist = flatten_tlist_vars(tlist, subplan->targetlist = flatten_tlist_vars(tlist,
subplan->targetlist); subplan->targetlist);
return subplan; return subplan;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.24 1998/03/30 16:36:04 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.25 1998/03/31 23:30:51 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -292,11 +292,10 @@ union_planner(Query *parse) ...@@ -292,11 +292,10 @@ union_planner(Query *parse)
((Agg *) result_plan)->aggs = ((Agg *) result_plan)->aggs =
set_agg_tlist_references((Agg *) result_plan); set_agg_tlist_references((Agg *) result_plan);
/***S*H***/ if(parse->havingQual != NULL) {
if(parse->havingQual!=NULL) {
List *clause; List *clause;
/***S*H***/ /* set qpqual of having clause */ /* set qpqual of having clause */
((Agg *) result_plan)->plan.qual=cnfify((Expr *)parse->havingQual,true); ((Agg *) result_plan)->plan.qual=cnfify((Expr *)parse->havingQual,true);
foreach(clause, ((Agg *) result_plan)->plan.qual) foreach(clause, ((Agg *) result_plan)->plan.qual)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.22 1998/03/31 04:43:49 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.23 1998/03/31 23:30:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -280,6 +280,8 @@ plan_inherit_query(List *relids, ...@@ -280,6 +280,8 @@ plan_inherit_query(List *relids,
new_root->uniqueFlag = NULL; new_root->uniqueFlag = NULL;
new_root->sortClause = NULL; new_root->sortClause = NULL;
new_root->groupClause = NULL; new_root->groupClause = NULL;
new_root->havingQual = NULL;
if (new_root->hasAggs) if (new_root->hasAggs)
{ {
new_root->hasAggs = false; new_root->hasAggs = false;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.73 1998/03/30 16:47:02 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.74 1998/03/31 23:31:10 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -319,6 +319,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt) ...@@ -319,6 +319,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
/* fix where clause */ /* fix where clause */
qry->qual = transformWhereClause(pstate, stmt->whereClause); qry->qual = transformWhereClause(pstate, stmt->whereClause);
qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
qry->hasSubLinks = pstate->p_hasSubLinks; qry->hasSubLinks = pstate->p_hasSubLinks;
/* now the range table will not change */ /* now the range table will not change */
...@@ -784,7 +787,6 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt) ...@@ -784,7 +787,6 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
qry->qual = transformWhereClause(pstate, stmt->whereClause); qry->qual = transformWhereClause(pstate, stmt->whereClause);
/***S*H***/
qry->havingQual = transformWhereClause(pstate, stmt->havingClause); qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
qry->hasSubLinks = pstate->p_hasSubLinks; qry->hasSubLinks = pstate->p_hasSubLinks;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment