Re: committing inside cursor loop

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: committing inside cursor loop
Дата
Msg-id 4ab5df79-140a-23f8-879a-94d5c4978be3@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: committing inside cursor loop  (Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>)
Ответы Re: committing inside cursor loop  (Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>)
Список pgsql-hackers
On 3/6/18 07:48, Ildus Kurbangaliev wrote:
> Although as was discussed before it seems inconsistent without ROLLBACK
> support. There was a little discussion about it, but no replies. Maybe
> the status of the patch should be changed to 'Waiting on author' until
> the end of discussion.

I'm wondering what the semantics of it should be.

For example, consider this:

drop table test1;
create table test1 (a int, b int);
insert into test1 values (1, 11), (2, 22), (3, 33);

do
language plpgsql
$$
declare
  x int;
begin
  for x in update test1 set b = b + 1 where b > 20 returning a loop
    raise info 'x = %', x;
    if x = 2 then
       rollback;
    end if;
  end loop;
end;
$$;

The ROLLBACK call in the first loop iteration undoes the UPDATE command
that drives the loop.  Is it then sensible to continue the loop?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [HACKERS] Another oddity in handling of WCO constraints inpostgres_fdw
Следующее
От: leap
Дата:
Сообщение: [submit code] I develop a tool for pgsql, how can I submit it