aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/analyze.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r--src/backend/parser/analyze.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 4bcf79a7277..08c209b2a5d 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: analyze.c,v 1.120 1999/10/03 23:55:30 tgl Exp $
+ * $Id: analyze.c,v 1.121 1999/10/07 04:23:11 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -298,19 +298,10 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->hasAggs = pstate->p_hasAggs;
- if (pstate->p_hasAggs || qry->groupClause)
+ if (pstate->p_hasAggs || qry->groupClause || qry->havingQual)
parseCheckAggregates(pstate, qry);
/*
- * If there is a havingQual but there are no aggregates, then there is
- * something wrong with the query because HAVING must contain
- * aggregates in its expressions! Otherwise the query could have been
- * formulated using the WHERE clause.
- */
- if (qry->havingQual && ! qry->hasAggs)
- elog(ERROR, "SELECT/HAVING requires aggregates to be valid");
-
- /*
* The INSERT INTO ... SELECT ... could have a UNION in child, so
* unionClause may be false
*/
@@ -961,9 +952,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
nothing_qry->commandType = CMD_NOTHING;
addRangeTableEntry(pstate, stmt->object->relname, "*CURRENT*",
- FALSE, FALSE);
+ FALSE, FALSE, FALSE);
addRangeTableEntry(pstate, stmt->object->relname, "*NEW*",
- FALSE, FALSE);
+ FALSE, FALSE, FALSE);
nothing_qry->rtable = pstate->p_rtable;
@@ -983,9 +974,9 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt)
* equal to 2.
*/
addRangeTableEntry(pstate, stmt->object->relname, "*CURRENT*",
- FALSE, FALSE);
+ FALSE, FALSE, FALSE);
addRangeTableEntry(pstate, stmt->object->relname, "*NEW*",
- FALSE, FALSE);
+ FALSE, FALSE, FALSE);
pstate->p_last_resno = 1;
pstate->p_is_rule = true; /* for expand all */
@@ -1048,19 +1039,10 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->hasAggs = pstate->p_hasAggs;
- if (pstate->p_hasAggs || qry->groupClause)
+ if (pstate->p_hasAggs || qry->groupClause || qry->havingQual)
parseCheckAggregates(pstate, qry);
/*
- * If there is a havingQual but there are no aggregates, then there is
- * something wrong with the query because HAVING must contain
- * aggregates in its expressions! Otherwise the query could have been
- * formulated using the WHERE clause.
- */
- if (qry->havingQual && ! qry->hasAggs)
- elog(ERROR, "SELECT/HAVING requires aggregates to be valid");
-
- /*
* The INSERT INTO ... SELECT ... could have a UNION in child, so
* unionClause may be false
*/