Stupid question on Read Committed Isolation Level - Mailing list pgsql-hackers

From Marc G. Fournier
Subject Stupid question on Read Committed Isolation Level
Date
Msg-id 20040129132813.H6922@ganymede.hub.org
Whole thread Raw
Responses Re: Stupid question on Read Committed Isolation Level
Re: Stupid question on Read Committed Isolation Level
List pgsql-hackers
http://www.postgresql.org/docs/7.3/static/transaction-iso.html#XACT-READ-COMMITTED

Reading this:

"
BEGIN;UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;UPDATE accounts SET balance = balance -
100.00WHERE acctnum = 7534;COMMIT;
 

If two such transactions concurrently try to change the balance of account
12345, we clearly want the second transaction to start from the updated
version of the account's row. Because each query is affecting only a
predetermined row, letting it see the updated version of the row does not
create any troublesome inconsistency.
"

What happens if I abort on the first transaction?  If I'm reading this
right, if Trans2 does the exact same as above, and COMMITs before Trans1
Aborts, the value of balance becomes +200 (Trans2 + Trans1) ... but what
happens when Trans1 ABORTS?  Trans2 believes its COMMIT worked, but
ABORTng Trans1 will rollback to the original value, no?

Or am I reading that section wrong? :(


----
Marc G. Fournier           Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org           Yahoo!: yscrappy              ICQ: 7615664


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: returning PGresult as xml
Next
From: "Jeroen T. Vermeulen"
Date:
Subject: Re: Stupid question on Read Committed Isolation Level