| From: | inspector morse <inspectormorse86(at)gmail(dot)com> |
|---|---|
| To: | pgadmin-support(at)postgresql(dot)org |
| Subject: | Stored procedure and transactions |
| Date: | 2015-02-19 01:09:22 |
| Message-ID: | CAHYn==4Puu3pyQt=zun+VO3vnXqfFu641Px_T=VzrDbp+U2bHA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robins Tharakan | 2015-02-19 03:36:50 | Re: Stored procedure and transactions |
| Previous Message | Albe Laurenz | 2015-02-18 13:58:40 | REFRESH MATERIALIZED VIEW blocks pgAdmin III login |