From: | "Tomer Levinboim" <levinboim(dot)tomer(at)gmail(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | postgres transaction isolation when rollback |
Date: | 2006-06-30 23:30:24 |
Message-ID: | 9825f9f50606301630p20128915pdfcfe8a66175b914@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi,
I've been using Postgres 8.1.x (and 8.0.x) for the past year or so and have
been really impressed and pleased with it so far.
I've read the Manual regarding transaction isolation and searched the lists
but still could not figure out the following (which seems to me like a
simple question):
Suppose I have two concurrent transactions similar to those in the manual [
http://www.postgresql.org/docs/7.4/interactive/transaction-iso.html]
*Transaction 1*
BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7555;
COMMIT;
*Transaction 2*
BEGIN;
UPDATE accounts SET balance = balance + 200.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 200.00 WHERE acctnum = 7534;
COMMIT;
*(notice the difference in the amount added to the balance, 100 vs. 200)*
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 ?
by transaction failure I mean that either
1) a rollback was issued
2) the transaction failed but no rollback occurred (especially, with respect
to the following error: "current transaction is aborted, queries ignored
until END of transaction block")
3) supposing there was some savepoint before the first UPDATE in the first
transaction and a ROLLBACK TO SAVEPOINT was issued.
I appreciate your feedback.
Thanks.
-- Tomer Levinboim
From | Date | Subject | |
---|---|---|---|
Next Message | Jim C. Nasby | 2006-07-01 05:50:35 | Re: [SQL] Doubt in stored procedure |
Previous Message | Derrick Betts | 2006-06-30 22:32:38 | Column names as variables in plpgsql |