Re: why does plperl cache functions using just a bool for is_trigger

Поиск
Список
Период
Сортировка
От Alex Hunsaker
Тема Re: why does plperl cache functions using just a bool for is_trigger
Дата
Msg-id AANLkTimPr=9Zov-T4aqes_ryguuJPRJo355mn+jdDdpQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: why does plperl cache functions using just a bool for is_trigger  (Hannu Krosing <hannu@2ndQuadrant.com>)
Ответы Re: why does plperl cache functions using just a bool for is_trigger  (Alex Hunsaker <badalex@gmail.com>)
Список pgsql-hackers
On Thu, Nov 4, 2010 at 13:43, Hannu Krosing <hannu@2ndquadrant.com> wrote:
> So your plan was to have some savepoint before each execute ?
>
> How would one rollback the latest transaction ?

It is always rolled back.  Its how plperl works today:
create or replace function foo() returns int as $$
eval {   spi_exec_query('create table uniq (num int primary key');   spi_exec_query('insert into uniq (num) values (1),
(1);',1); 
};

if($@) {# do something ... $@ == "duplicate key value violates unique
constraint "uniq_pkey" at line 2." warn $@;
}

# oh well do something else
# note the transaction is _not_ aborted
spi_exec_query('select 1;', 1);
return 1;
$$ language plperl;

=# begin;
=# select foo();
=# select 1;
=# commit;

It does not matter if you use eval or not, its always in a sub transaction.

> I see. "exception when unique violation" in plpgsql  does automatic
> rollback to block start (matching BEGIN) so I assumed that your
> try/except sample is designed to do something similar

Basically, minus the rollback to start.  Its per query.


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

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Re: why does plperl cache functions using just a bool for is_trigger
Следующее
От: Alex Hunsaker
Дата:
Сообщение: Re: why does plperl cache functions using just a bool for is_trigger