BUG #5385: gd disallows agg function in subselect of update

From: "Corin" <wakathane(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5385: gd disallows agg function in subselect of update
Date: 2010-03-20 11:25:49
Message-ID: 201003201125.o2KBPnPs035109@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5385
Logged by: Corin
Email address: wakathane(at)gmail(dot)com
PostgreSQL version: 8.4.2
Operating system: ubuntu amd64
Description: gd disallows agg function in subselect of update
Details:

query:
UPDATE imagecontest_participations AS g SET rating_ratings_sum=(SELECT
SUM(rating_ratings_sum) FROM imagecontest_participation_ratings WHERE
imagecontest_participation_id=g.id)

error message:
cannot use aggregate function in UPDATE

while looking for a solution I found this commit:
http://archives.postgresql.org/pgsql-committers/2006-06/msg00299.php
... "Disallow aggregate functions in UPDATE commands (unless within a
sub-SELECT).
This is disallowed by the SQL spec because it doesn't have any very
sensible
interpretation." ...

As the subquery is not top-level but inside a subquery I suspect this being
an error. I don't want to use the UPDATE ... FROM syntax if possible to keep
compatibility with other sql servers.

Browse pgsql-bugs by date

  From Date Subject
Next Message Corin 2010-03-20 11:56:07 Re: BUG #5385: gd disallows agg function in subselect of update
Previous Message tomas 2010-03-20 05:59:23 Re: BUG #5380: error in xlog