Re: postgres transaction isolation when rollback - Mailing list pgsql-novice

From Tom Lane
Subject Re: postgres transaction isolation when rollback
Date
Msg-id 22534.1151897233@sss.pgh.pa.us
Whole thread Raw
In response to postgres transaction isolation when rollback  ("Tomer Levinboim" <levinboim.tomer@gmail.com>)
List pgsql-novice
"Tomer Levinboim" <levinboim.tomer@gmail.com> writes:
> Suppose now that the order is like so
> transaction 1: UPDATE accounts SET balance = balance + 100.00 WHERE acctnum
> = 12345;
> transaction 2: UPDATE accounts SET balance = balance + 200.00 WHERE acctnum
> = 12345;
> transaction 1: transaction failure
> transaction 2: UPDATE accounts SET balance = balance - 200.00 WHERE acctnum
> = 7534;

> Would the balance of account 12345 increase by 200 or 300 ?

200.  Transaction 2 will block at its first UPDATE waiting to see if
transaction 1 commits or not, and will then use the appropriate version
of the row as the starting point for its update.

(I'm assuming you're speaking of READ COMMITTED rules here --- if T2
is SERIALIZABLE then the answer is different.)

            regards, tom lane

pgsql-novice by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: Insert more then one row
Next
From: "Guido Barosio"
Date:
Subject: Re: Password Help?