Stored procedure and transactions - Mailing list pgadmin-support

From inspector morse
Subject Stored procedure and transactions
Date
Msg-id CAHYn==4Puu3pyQt=zun+VO3vnXqfFu641Px_T=VzrDbp+U2bHA@mail.gmail.com
Whole thread Raw
Responses Re: Stored procedure and transactions
List 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 by date:

Previous
From: Albe Laurenz
Date:
Subject: REFRESH MATERIALIZED VIEW blocks pgAdmin III login
Next
From: Robins Tharakan
Date:
Subject: Re: Stored procedure and transactions