[HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Golden Liu
Updateable cursors are used as follows: begin; declare foo cursor for select * from bar for update; fetch foo; update bar set abc='def' where current of foo; fetch foo; delete from bar where current of foo; commit; PostgreSQL doesn't support this feature now ( 8.1.4). Will PGSQL support it

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Gavin Sherry
On Mon, 24 Jul 2006, Golden Liu wrote: Updateable cursors are used as follows: begin; declare foo cursor for select * from bar for update; fetch foo; update bar set abc='def' where current of foo; fetch foo; delete from bar where current of foo; commit; PostgreSQL doesn't support this

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Florian G. Pflug
Gavin Sherry wrote: On Mon, 24 Jul 2006, Golden Liu wrote: begin; declare foo cursor for select * from bar for update; fetch foo; update bar set abc='def' where current of foo; fetch foo; delete from bar where current of foo; commit; No one has stepped up to do this for 8.2 so unfortunately

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Tom Lane
Florian G. Pflug [EMAIL PROTECTED] 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,

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Alvaro Herrera
Florian G. Pflug wrote: Gavin Sherry wrote: On Mon, 24 Jul 2006, Golden Liu wrote: begin; declare foo cursor for select * from bar for update; fetch foo; update bar set abc='def' where current of foo; fetch foo; delete from bar where current of foo; commit; No one has stepped up to

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Florian G. Pflug
Tom Lane wrote: Florian G. Pflug [EMAIL PROTECTED] 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

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Tom Lane
Alvaro Herrera [EMAIL PROTECTED] writes: No, a concurrent vacuum can't change that because vacuum can't change the page unless it can get a super-exclusive lock on it (which means nobody else can have a scan stopped at that page, which is exactly what this cursor has). More to the point,

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Tom Lane
Florian G. Pflug [EMAIL PROTECTED] writes: How could there be a concurrent update of the _same_ row, when I do select * from bar *for update*. AFAICT the spec doesn't require one to have written FOR UPDATE in order to use WHERE CURRENT OF. (In effect, they expect FOR UPDATE to be the default,

Re: [HACKERS] UPDATE/DELETE XXX WHERE CURRENT OF cursor_name

2006-07-24 Thread Florian G. Pflug
Tom Lane wrote: Florian G. Pflug [EMAIL PROTECTED] writes: How could there be a concurrent update of the _same_ row, when I do select * from bar *for update*. AFAICT the spec doesn't require one to have written FOR UPDATE in order to use WHERE CURRENT OF. (In effect, they expect FOR UPDATE