Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6F06B1E74D99 for ; Tue, 29 Nov 2011 14:55:51 -0400 (AST) Received: from gwmta.wicourts.gov ([165.219.244.99] helo=gw.wicourts.gov) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RVSqK-0003Ze-M2 for pgsql-admin@postgresql.org; Tue, 29 Nov 2011 18:55:50 +0000 Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Tue, 29 Nov 2011 12:55:22 -0600 Message-Id: <4ED4D63402000025000435E8@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Tue, 29 Nov 2011 12:55:16 -0600 From: "Kevin Grittner" To: "Kasia Tuszynska" , "pgsql-admin@postgresql.org" Subject: Re: transaction error handling References: <28131.1322067903@sss.pgh.pa.us> <232B5217AD58584C87019E8933556D11036BDE58EB@redmx2.esri.com> In-Reply-To: <232B5217AD58584C87019E8933556D11036BDE58EB@redmx2.esri.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Pg-Spam-Score: -5.4 (-----) X-Archive-Number: 201111/143 X-Sequence-Number: 38737 Kasia Tuszynska wrote: > Oracle: > Begin transaction > Insert - no error > Implicit savepoint > Insert - error raised > Implicit rollback to the savepoint, no transaction loss, error > raised on the insert statement that errored out. > End transaction, implicit commit, with the single error free > insert. > > Postgres: > Begin transaction > Insert - no error > Insert - error raised > Transaction loss = no implicit rollback to the single error free > insert. > > Is this a correct interpretation of the Postgres transaction error > handling? Well, in psql you can set ON_ERROR_ROLLBACK so that each statement will be automatically preceded by a SAVEPOINT which will be automatically rolled back if the statement has an error. There are various constructs for accomplishing this in supported PLs, depending on the language. I'm not aware of any "explicitly start a transaction but guess at whether a commit is intended" feature in PostgreSQL. An explicit transaction is committed if and when you say so. -Kevin