Stored procedure and transactions

Поиск
Список
Период
Сортировка
От inspector morse
Тема Stored procedure and transactions
Дата
Msg-id CAHYn==4Puu3pyQt=zun+VO3vnXqfFu641Px_T=VzrDbp+U2bHA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Stored procedure and transactions  (Robins Tharakan <tharakan@gmail.com>)
Список pgadmin-support
Hello,

I'm trying to figure out if the following stored procedure is safe in a high concurrency environment. I'm using the Postgresql 9.4 with all the default settings.

create procedure test(in topic_id int)
as
declare i_forum_id int;
declare i_post_tally int;
begin
     delete from forum_topics where topic_id = i_topic_id
     returning forum_id, post_tally into i_forum_id, i_post_tally;

     update forums set post_tally = post_tally - i_post_tally
     where forum_id = i_forum_id;
end;

If transaction #1 deletes the row from forum_topics and immediately after transaction #2 updates the post tally, will the update to the post_tally in transaction #1 be the correct value?

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

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: REFRESH MATERIALIZED VIEW blocks pgAdmin III login
Следующее
От: Robins Tharakan
Дата:
Сообщение: Re: Stored procedure and transactions