Re: transaction problem using cursors

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: "Pit M(dot)" <fmi-soft(at)gmx(dot)de>, pgsql-general(at)postgresql(dot)org
Subject: Re: transaction problem using cursors
Date: 2007-06-11 17:21:10
Message-ID: 17647.1181582470@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Pit M." <fmi-soft(at)gmx(dot)de> writes:
>> The goal is to maintain a valid cursor that can be used to FETCH other records.
>> It would be ideal to skip this record an continue fetching the next record ->
>> but how can i achieve this?

> Well ideally the answer would be to wrap each FETCH in a savepoint and roll
> back to the savepoint if it fails. However I just tried it and this doesn't
> work. So I think the answer is you can't, sorry.

The problem is to distinguish failures that don't imply the cursor
itself is broken from failures that do. What I'd suggest is reducing
the cursor definition to a simple "SELECT * FROM ..." and then doing
the failure-prone calculations separately. The cursor won't get marked
PORTAL_FAILED unless the error occurs during a FETCH from it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gabriele 2007-06-11 17:44:38 PostGreSQL for a small Desktop Application
Previous Message Gregory Stark 2007-06-11 17:17:55 Re: Materializing the relation