From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: bug w/ cursors and savepoints |
Date: | 2005-01-25 17:16:58 |
Message-ID: | 4625.1106673418@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Tue, Jan 25, 2005 at 02:40:51AM -0500, Tom Lane wrote:
>> Offhand I'd say this should draw a "no such cursor as foo" error.
>> I'm too tired to look into why foo still exists after the rollback...
> At this point, gdb says that the portal is in PORTAL_READY state. The
> code says to keep it open and reassign it to the parent subxact. I
> don't remember what the rationale for this was ... I'll review the
> discussion about this.
IIRC, we had agreed that in a sequence like
BEGIN;
DECLARE c CURSOR ...;
SAVEPOINT x;
FETCH FROM c;
ROLLBACK TO x;
FETCH FROM c;
...
the second fetch should get the second cursor row, ie, the rollback does
not undo the cursor state change caused by the first fetch. This was
frankly driven mostly by implementation considerations, ie, we do not
have any mechanism that would support undoing changes of Executor state.
But I don't think that we really thought about the case of rolling back
the *creation* of a cursor. Neil's example seems to prove that we need
to do that. Even aside from the possibility that the database objects
won't exist any more, the locks taken out during plan startup would get
released by the rollback. So I think the rule ought to be that cursors
created inside a failed subtransaction go away.
I have some recollection that we did that initially and ran into the
problem that the portal holding the ROLLBACK command itself goes away
too soon :-(. So a bit of care will be needed here.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Oleg Bartunov | 2005-01-25 17:23:45 | improved support for compounds in tsearch2 |
Previous Message | Alvaro Herrera | 2005-01-25 17:06:24 | Re: bug w/ cursors and savepoints |