Re: transaction problem using cursors

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: transaction problem using cursors
Дата
Msg-id 17647.1181582470@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: transaction problem using cursors  (Gregory Stark <stark@enterprisedb.com>)
Список pgsql-general
Gregory Stark <stark@enterprisedb.com> writes:
> "Pit M." <fmi-soft@gmx.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

В списке pgsql-general по дате отправления:

Предыдущее
От: Gregory Stark
Дата:
Сообщение: Re: Materializing the relation
Следующее
От: Greg Smith
Дата:
Сообщение: Re: When should I worry?