]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Disallow aggregate functions in rule WHERE clauses. Per gripe from
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 20 Oct 2002 00:31:53 +0000 (00:31 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 20 Oct 2002 00:31:53 +0000 (00:31 +0000)
Fritz Lehmann-Grube back in January.

src/backend/parser/analyze.c

index 2dcaadc177fb25cf4b73452d41bad10736f2c88d..c8ed3ed8cb21e2ef683d23477dc3893b9e1a4724 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.251 2002/10/14 22:14:35 tgl Exp $
+ *     $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.252 2002/10/20 00:31:53 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1454,6 +1454,10 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
        if (length(pstate->p_rtable) != 2)      /* naughty, naughty... */
                elog(ERROR, "Rule WHERE condition may not contain references to other relations");
 
+       /* aggregates not allowed (but subselects are okay) */
+       if (contain_agg_clause(stmt->whereClause))
+               elog(ERROR, "Rule WHERE condition may not contain aggregate functions");
+
        /* save info about sublinks in where clause */
        qry->hasSubLinks = pstate->p_hasSubLinks;