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 A280AD1B20E for ; Thu, 17 Jun 2004 16:33:47 -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 75523-08 for ; Thu, 17 Jun 2004 19:33:47 +0000 (GMT) Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com [64.84.59.212]) by svr1.postgresql.org (Postfix) with ESMTP id DF789D1B1B4 for ; Thu, 17 Jun 2004 16:33:42 -0300 (ADT) Received: from xythos.com ([64.154.218.194]) by NSNOVPS00411.nacio.xythos.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 17 Jun 2004 12:33:40 -0700 Message-ID: <40D1BF13.3050208@xythos.com> Date: Thu, 17 Jun 2004 08:56:03 -0700 From: Barry Lind User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alvaro Herrera Cc: Simon Riggs , Patches Subject: Re: Nested transactions References: <20040608222356.GC13820@dcc.uchile.cl> <1087425935.12015.1154.camel@stromboli> <20040617014359.GA5925@dcc.uchile.cl> In-Reply-To: <20040617014359.GA5925@dcc.uchile.cl> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 17 Jun 2004 19:33:41.0025 (UTC) FILETIME=[FE8BA910:01C454A1] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=DATE_IN_PAST_03_06 X-Spam-Level: X-Archive-Number: 200406/230 X-Sequence-Number: 11453 Alvaro Herrera wrote: > With this in place, implementing SAVEPOINTs the way SQL expects them to > work appears to be a very trivial exercise. > > You may not see it, but a savepoint is just the start of a nested > transaction in disguise. Consider: > > begin; > insert into foo values (1); > savepoint dammit; > insert into foo values (2); > select foo; -- fails > rollback to dammit; > insert into foo values (3); > commit; > > You expect the transaction to finish with tuples 1 and 3 in table foo, > right? Well, this is exactly the same as > > begin; > insert into foo values (1); > begin; -- dammit > insert into foo values (2); > select foo; -- fails, goes to aborted state > rollback; > insert into foo values (3); > commit; > > So all that's needed for the former to work is to be able to define a > "name" for a transaction (using a cute syntax) and being able to > rollback to it. Definitely trivial, after all the work I have put into > making the latter work. > 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. thanks, --Barry