Re: UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
Cc: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>, Golden Liu <goldenliu(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: UPDATE/DELETE XXX WHERE CURRENT OF cursor_name
Date: 2006-07-24 15:26:04
Message-ID: 11085.1153754764@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Florian G. Pflug" <fgp(at)phlo(dot)org> writes:
> Couldn't this be emulated by doing
> begin;
> declare foo cursor for select * from bar for update;
> fetch foo into v_foo ;
> update bar set abc='def' where ctid = v_foo.ctid;

That wouldn't follow the expected semantics if there's a concurrent
update, because the updated row would always fail the WHERE clause,
and thus the update would just silently not happen. (I'm thinking
about READ COMMITTED mode of course --- in SERIALIZABLE you'd just get
the expected error.) You'd have to find some way to pump the row's most
up-to-date version through the cursor's query plan, a la EvalPlanQual,
to see if it still met the cursor's WHERE condition.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2006-07-24 15:28:01 Re: UPDATE/DELETE XXX WHERE CURRENT OF cursor_name
Previous Message Rod Taylor 2006-07-24 15:22:03 Re: Better name/syntax for "online" index creation