|
6 | 6 | * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 |
| - * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.334 2006/04/30 18:30:39 tgl Exp $ |
| 9 | + * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.335 2006/06/21 18:30:11 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
@@ -1613,7 +1613,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
|
1613 | 1613 | if (pstate->p_hasAggs)
|
1614 | 1614 | ereport(ERROR,
|
1615 | 1615 | (errcode(ERRCODE_GROUPING_ERROR),
|
1616 |
| - errmsg("rule WHERE condition may not contain aggregate functions"))); |
| 1616 | + errmsg("cannot use aggregate function in rule WHERE condition"))); |
1617 | 1617 |
|
1618 | 1618 | /* save info about sublinks in where clause */
|
1619 | 1619 | qry->hasSubLinks = pstate->p_hasSubLinks;
|
@@ -2346,9 +2346,16 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
|
2346 | 2346 | qry->jointree = makeFromExpr(pstate->p_joinlist, qual);
|
2347 | 2347 |
|
2348 | 2348 | qry->hasSubLinks = pstate->p_hasSubLinks;
|
2349 |
| - qry->hasAggs = pstate->p_hasAggs; |
| 2349 | + |
| 2350 | + /* |
| 2351 | + * Top-level aggregates are simply disallowed in UPDATE, per spec. |
| 2352 | + * (From an implementation point of view, this is forced because the |
| 2353 | + * implicit ctid reference would otherwise be an ungrouped variable.) |
| 2354 | + */ |
2350 | 2355 | if (pstate->p_hasAggs)
|
2351 |
| - parseCheckAggregates(pstate, qry); |
| 2356 | + ereport(ERROR, |
| 2357 | + (errcode(ERRCODE_GROUPING_ERROR), |
| 2358 | + errmsg("cannot use aggregate function in UPDATE"))); |
2352 | 2359 |
|
2353 | 2360 | /*
|
2354 | 2361 | * Now we are done with SELECT-like processing, and can get on with
|
|
0 commit comments