X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 18877D1B1A1 for ; Thu, 17 Jun 2004 19:03:26 -0300 (ADT) 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 30271-05 for ; Thu, 17 Jun 2004 22:03:25 +0000 (GMT) Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 8AFD3D1B18E for ; Thu, 17 Jun 2004 19:03:18 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id i5HM1ns22285; Thu, 17 Jun 2004 18:01:49 -0400 (EDT) From: Bruce Momjian Message-Id: <200406172201.i5HM1ns22285@candle.pha.pa.us> Subject: Re: Nested transactions In-Reply-To: <40D1BF13.3050208@xythos.com> To: Barry Lind Date: Thu, 17 Jun 2004 18:01:49 -0400 (EDT) Cc: Alvaro Herrera , Simon Riggs , Patches X-Mailer: ELM [version 2.4ME+ PL108 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/232 X-Sequence-Number: 11455 > The problem I see with moving towards supporting savepoints with the > current proposal is with how commit works: > > Consider: > > begin; > insert into foo values (1); > savepoint dammit; > insert into foo values (2); > select foo; > insert into foo values (3); > commit; > > This one commit needs to commit the top level transaction. But if the > savepoint command is really starting a sub transaction then that commit > would only commit the subtransaction not the top level transaction. I > don't see how you can use COMMIT to sometimes mean commit the > subtransaction and other times have it mean commit the top level > transaction. > > I don't have a problem with the under the covers functionality in this > patch, it is how begin/commit are changed to support the underlying > functionality that concerns me. IMHO we should not change the behavior > of begin/commit for nested transactions (leave them do what they have > always done - i.e. control the top level transaction state), but > introduce new syntax for subtransactions control. Well, because their was only one BEGIN, the commit commits all open subtransactions. The code will have to track the number of BEGIN's used and will have to roll all savepoints into the next commit. However, it is only the commit that matches the outermost begin that has this behavior. Consider this: > begin; > insert into foo values (1); > savepoint aa; > begin; > savepoint dammit; > insert into foo values (2); > commit; > select foo; > rollback dammit; > rollback aa; > insert into foo values (3); > commit; OK, the inner commit does not close the aa subtransaction. One big question is whether it closes the dammit subtransaction. And is rollback to aa valid (I think so), and what about rollback dammit, which was defined in a subtransaction (I think we have to disallow that). Did I make a mistake by promoting subtransactions rather than savepoints? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073