Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 294C116B0CAE for ; Mon, 19 Dec 2011 16:43:44 -0400 (AST) Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rck3g-0005CY-LX for pgsql-hackers@postgresql.org; Mon, 19 Dec 2011 20:43:43 +0000 Received: from know-smtpout-4.server.virginmedia.net ([62.254.123.4]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20111219204327.NAYU19823.mtaout03-winn.ispmail.ntl.com@know-smtpout-4.server.virginmedia.net>; Mon, 19 Dec 2011 20:43:27 +0000 Received: from [77.99.161.245] (helo=leggeri.gi.lan) by know-smtpout-4.server.virginmedia.net with esmtp (Exim 4.63) (envelope-from ) id 1Rck3T-0001I0-S4; Mon, 19 Dec 2011 20:43:27 +0000 Received: from gianni by leggeri.gi.lan with local (masqmail 0.2.27) id 1Rck3B-3n6-00; Mon, 19 Dec 2011 20:43:09 +0000 Date: Mon, 19 Dec 2011 20:43:09 +0000 From: Gianni Ciolli To: Marti Raudsepp Cc: Simon Riggs , pgsql-hackers@postgresql.org Subject: Re: Autonomous subtransactions Message-ID: <20111219204309.GC26381@leggeri.gi.lan> References: <20111218082812.GA14355@leggeri.gi.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=XYJHFtupD_QA:10 a=-0jasrWylJYA:10 a=b30I1FEBwLAA:10 a=kj9zAlcOel0A:10 a=Rdvl4hr_AAAA:8 a=xavqvzXs_WcFAR1lwykA:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/924 X-Sequence-Number: 200176 On Mon, Dec 19, 2011 at 09:32:06PM +0200, Marti Raudsepp wrote: > Maybe that's just my paranoia, but the fact that subtransactions > aren't named means it's pretty easy to accidentally get "out of step" > and commit the wrong subtransaction. I see app developers often > messing up BEGIN/COMMIT/ROLLBACK already. This is why I like the > SAVEPOINT style; it's obvious when there's a bug. For each COMMIT/ROLLBACK there is only one possible BEGIN SUBTRANSACTION, therefore naming is not strictly necessary, unlike in the SAVEPOINT case where you can have more than one option. However, ISTM that allowing to optionally name each transaction could provide a nice safety measure that the careful developer can use to reduce the chances of human error. If subtransactions are not named, no check is made; but if they are named, then the Xs on BEGIN SUBTRANSACTION X and COMMIT/ROLLBACK SUBTRANSACTION X must match, otherwise an exception is raised (and a bug is detected). Regards, Dr. Gianni Ciolli - 2ndQuadrant Italia PostgreSQL Training, Services and Support gianni.ciolli@2ndquadrant.it | www.2ndquadrant.it