second DML operation fails with updatable cursor

From: "Dharmendra Goyal" <dharmendra(dot)goyal(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: second DML operation fails with updatable cursor
Date: 2007-10-24 09:39:11
Message-ID: f87e6d710710240239g7d213f40t7eafaeb92bf6ce02@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

If i do update and delete operations on a row pointed by cursor's current
then only first operation succeeds, second operation fails.
Ex.
DROP TABLE IF EXISTS tab;
create table tab (num int,num2 int );
insert into tab values(1,100);
insert into tab values(2,200);
insert into tab values(3,300);
insert into tab values(4,400);
insert into tab values(5,500);
insert into tab values(6,600);
insert into tab values(7,700);
insert into tab values(8,800);
insert into tab values(9,900);
insert into tab values(10,1000);
BEGIN;
DECLARE c CURSOR FOR SELECT num FROM tab;
FETCH 5 FROM c;
UPDATE tab SET num=500 WHERE CURRENT OF c;
DELETE FROM tab WHERE CURRENT OF c; --> This delete fails.
SELECT * FROM tab;
FETCH 2 FROM c;
COMMIT;
SELECT * FROM tab;
FETCH 2 FROM c;

Is this as expected..??

Thanks,
Dharmendra Goyal

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavan Deolasee 2007-10-24 10:02:06 Re: VACUUM always makes all pages dirty
Previous Message Pavan Deolasee 2007-10-24 08:45:12 Re: VACUUM always makes all pages dirty