Re: A transaction in transaction? Possible?

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: A transaction in transaction? Possible?
Дата
Msg-id 20041110095352.GA55504@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: A transaction in transaction? Possible?  ("Riccardo G. Facchini" <abief_ag_-postgresql@yahoo.com>)
Ответы Re: A transaction in transaction? Possible?
Список pgsql-sql
On Wed, Nov 10, 2004 at 12:45:19AM -0800, Riccardo G. Facchini wrote:

> Sorry, but I understand that your example is not really about nested
> transactions, but about sequential transactions.

Here's a more elaborate example.  If this doesn't demonstrate the
capability you're looking for, then please provide an example of
what you'd like to do and describe the desired behavior.

CREATE TABLE person (id SERIAL PRIMARY KEY, name TEXT NOT NULL);

BEGIN;   INSERT INTO person (name) VALUES ('Alice');
   SAVEPOINT s1;       INSERT INTO person (name) VALUES ('Bob');
SAVEPOINT s2;    INSERT INTO person (name) VALUES ('Charles');
    SAVEPOINT s3;        INSERT INTO person (name) VALUES ('David');    ROLLBACK TO s3;
    INSERT INTO person (name) VALUES ('Edward');ROLLBACK TO s2;
       INSERT INTO person (name) VALUES ('Frank');   RELEASE s1;
   INSERT INTO person (name) VALUES ('George');
COMMIT;

SELECT * FROM person;id |  name  
----+-------- 1 | Alice 2 | Bob 6 | Frank 7 | George

If you change "ROLLBACK TO s2" to "RELEASE s2" then you get this:
id |  name   
----+--------- 1 | Alice 2 | Bob 3 | Charles 5 | Edward 6 | Frank 7 | George

If you change "RELEASE s1" to "ROLLBACK TO s1" then you get this:
id |  name  
----+-------- 1 | Alice 7 | George

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/


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

Предыдущее
От: Sam Mason
Дата:
Сообщение: Re: Comparing two (largish) tables on different servers
Следующее
От: Achilleus Mantzios
Дата:
Сообщение: Re: A transaction in transaction? Possible?