summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_agg.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-09-29 18:21:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-09-29 18:21:41 +0000
commit3a94e789f5c9537d804210be3cb26f7fb08e3b9e (patch)
treef1eac12405e3c0ded881d7dd7e59cec35b30c335 /src/backend/parser/parse_agg.c
parent6f64c2e54a0b14154a335249f4dca91a39c61c50 (diff)
Subselects in FROM clause, per ISO syntax: FROM (SELECT ...) [AS] alias.
(Don't forget that an alias is required.) Views reimplemented as expanding to subselect-in-FROM. Grouping, aggregates, DISTINCT in views actually work now (he says optimistically). No UNION support in subselects/views yet, but I have some ideas about that. Rule-related permissions checking moved out of rewriter and into executor. INITDB REQUIRED!
Diffstat (limited to 'src/backend/parser/parse_agg.c')
-rw-r--r--src/backend/parser/parse_agg.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c
index c3ac417365c..e7d8fe8d3b7 100644
--- a/src/backend/parser/parse_agg.c
+++ b/src/backend/parser/parse_agg.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.41 2000/09/25 18:14:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.42 2000/09/29 18:21:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -129,10 +129,13 @@ check_ungrouped_columns_walker(Node *node,
* Ideally this should be done earlier, but it's difficult to distinguish
* aggregates from plain functions at the grammar level. So instead we
* check here. This function should be called after the target list and
- * qualifications are finalized.
+ * qualifications are finalized. BUT: in some cases we want to call this
+ * routine before we've assembled the joinlist and qual into a FromExpr.
+ * So, rather than looking at qry->jointree, look at pstate->p_joinlist
+ * and the explicitly-passed qual.
*/
void
-parseCheckAggregates(ParseState *pstate, Query *qry)
+parseCheckAggregates(ParseState *pstate, Query *qry, Node *qual)
{
List *groupClauses = NIL;
List *tl;
@@ -141,18 +144,16 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
Assert(pstate->p_hasAggs || qry->groupClause || qry->havingQual);
/*
- * Aggregates must never appear in WHERE clauses. (Note this check
- * should appear first to deliver an appropriate error message;
- * otherwise we are likely to complain about some innocent variable in
- * the target list, which is outright misleading if the problem is in
- * WHERE.)
+ * Aggregates must never appear in WHERE or JOIN/ON clauses.
+ *
+ * (Note this check should appear first to deliver an appropriate error
+ * message; otherwise we are likely to complain about some innocent
+ * variable in the target list, which is outright misleading if the
+ * problem is in WHERE.)
*/
- if (contain_agg_clause(qry->qual))
+ if (contain_agg_clause(qual))
elog(ERROR, "Aggregates not allowed in WHERE clause");
- /*
- * ON-conditions in JOIN expressions are like WHERE clauses.
- */
- if (contain_agg_clause((Node *) qry->jointree))
+ if (contain_agg_clause((Node *) pstate->p_joinlist))
elog(ERROR, "Aggregates not allowed in JOIN conditions");
/*