Re: concurrency in stored procedures

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: concurrency in stored procedures
Дата
Msg-id b42b73150703231422n2ea5dda5wb1edf5dfd1aa0b2d@mail.gmail.com
обсуждение исходный текст
Ответ на Re: concurrency in stored procedures  (Ottavio Campana <ottavio@campana.vi.it>)
Ответы Re: concurrency in stored procedures  (Ottavio Campana <ottavio@campana.vi.it>)
Список pgsql-general
On 3/23/07, Ottavio Campana <ottavio@campana.vi.it> wrote:
> Ottavio Campana wrote:
> > What would you to in order to be sure that one function or a part of it
> > is atomically executed?
>
> would it be correct something like? or how would you write this?
>
> create or replace function my_function () returs integer as
> $$
> declare
>   ...
>   status boolean;
>   ...
> begin
>   ...
>   loop
>     begin
>       set transaction isolation level serializable;
>       ...
>       do_something();
>       ...
>       status := true;
>     exception serialization_failure
>       status := false;
>     end;
>
>     if status then exit;
>   end loop;
>   ...
>   return 0;
> end
> $$ language plpgsql

you can also use advisory locks if you want to implement 'critical
section' inside a plpgsql function.

see:
http://merlinmoncure.blogspot.com/2006/12/advisory-locks-part-2.html

merlin

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Insert fail: could not open relation with OID 3221204992
Следующее
От: Ottavio Campana
Дата:
Сообщение: Re: concurrency in stored procedures