postgres transaction isolation when rollback

Поиск
Список
Период
Сортировка
От Tomer Levinboim
Тема postgres transaction isolation when rollback
Дата
Msg-id 9825f9f50606301630p20128915pdfcfe8a66175b914@mail.gmail.com
обсуждение исходный текст
Ответы Re: postgres transaction isolation when rollback  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Derrick Betts"
Дата:
Сообщение: Column names as variables in plpgsql
Следующее
От: "Jim C. Nasby"
Дата:
Сообщение: Re: [SQL] Doubt in stored procedure