X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CEC3D3A3D36 for ; Wed, 10 Nov 2004 10:28:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89677-01 for ; Wed, 10 Nov 2004 10:28:08 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 1DE403A3AE1 for ; Wed, 10 Nov 2004 10:28:07 +0000 (GMT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id iAAAwS5x006914; Wed, 10 Nov 2004 12:58:28 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id iAAAwRWZ006910; Wed, 10 Nov 2004 12:58:27 +0200 Date: Wed, 10 Nov 2004 12:58:27 +0200 (EET) From: Achilleus Mantzios To: Michael Fuhr Cc: "Riccardo G. Facchini" , , Theodore Petrosky , Andrei Bintintan , sad Subject: Re: A transaction in transaction? Possible? In-Reply-To: <20041110095352.GA55504@winnie.fuhr.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200411/102 X-Sequence-Number: 19421 O Michael Fuhr έγραψε στις Nov 10, 2004 : > 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; Just a very naive thought.... Wouldn't make more sense to allow nested begin/commit/rollback blocks? > > 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 > > -- -Achilleus