Re: pgsql gives ExecutePlan error after empty UPDATE?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mudie(at)digitaldeck(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: pgsql gives ExecutePlan error after empty UPDATE?
Date: 2000-07-12 17:42:04
Message-ID: 23918.963423724@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David C Mudie <mudie(at)digitaldeck(dot)com> writes:
> zorro_4330=# update foo set bar = count(*) from foo \g
> ERROR: ExecutePlan: (junk) `ctid' is NULL!

> Postgres seems to be reporting an error because the update matched no rows,
> but this a perfectly legitimate database operation.

Actually, it's flat-out illegal according to SQL92: thou shalt not
use an aggregate in UPDATE, quoth the standard. Try it with the
count() in a sub-select, which is legal SQL:

update foo set bar = (select count(*) from foo);

There is a thread going on in pghackers right now about whether it
makes sense to allow aggregates outside sub-selects in UPDATE, and
if so what it should mean exactly.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2000-07-12 17:48:57 Re: Slashdot discussion
Previous Message root 2000-07-12 17:41:10 Re: Re: [NOVICE] newbie problem on creating table