*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
*/
if (constant_qual)
{
- subplan = (Plan *) make_result((!root->hasAggs && !root->groupClause)
+ subplan = (Plan *) make_result((!root->hasAggs &&
+ !root->groupClause &&
+ !root->havingQual)
? tlist : subplan->targetlist,
(Node *) constant_qual,
subplan);
/*
* 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);
return subplan;
*/
else
{
- if (!root->hasAggs && !root->groupClause)
+ if (!root->hasAggs && !root->groupClause && !root->havingQual)
subplan->targetlist = flatten_tlist_vars(tlist,
subplan->targetlist);
return subplan;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
((Agg *) result_plan)->aggs =
set_agg_tlist_references((Agg *) result_plan);
- /***S*H***/
- if(parse->havingQual!=NULL) {
+ if(parse->havingQual != NULL) {
List *clause;
- /***S*H***/ /* set qpqual of having clause */
+ /* set qpqual of having clause */
((Agg *) result_plan)->plan.qual=cnfify((Expr *)parse->havingQual,true);
foreach(clause, ((Agg *) result_plan)->plan.qual)
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
new_root->uniqueFlag = NULL;
new_root->sortClause = NULL;
new_root->groupClause = NULL;
+ new_root->havingQual = NULL;
+
if (new_root->hasAggs)
{
new_root->hasAggs = false;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/* fix where clause */
qry->qual = transformWhereClause(pstate, stmt->whereClause);
+
+ qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
+
qry->hasSubLinks = pstate->p_hasSubLinks;
/* now the range table will not change */
qry->qual = transformWhereClause(pstate, stmt->whereClause);
- /***S*H***/
qry->havingQual = transformWhereClause(pstate, stmt->havingClause);
qry->hasSubLinks = pstate->p_hasSubLinks;