From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Kasia Tuszynska <ktuszynska@esri.com>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: transaction error handling
Date: Tue, 29 Nov 2011 12:55:16 -0600
Message-ID: <4ED4D63402000025000435E8@gw.wicourts.gov> (raw)
In-Reply-To: <232B5217AD58584C87019E8933556D11036BDE58EB@redmx2.esri.com>
References: <CAANiQEm92w70rapQhitV1qL0tpkNRo5qjpwo2fdg+iZ-AURMCg@mail.gmail.com>
<28131.1322067903@sss.pgh.pa.us>
<232B5217AD58584C87019E8933556D11036BDE58EB@redmx2.esri.com>
Kasia Tuszynska <ktuszynska@esri.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: Kevin.Grittner@wicourts.gov, ktuszynska@esri.com
Subject: Re: transaction error handling
In-Reply-To: <4ED4D63402000025000435E8@gw.wicourts.gov>
References: <CAANiQEm92w70rapQhitV1qL0tpkNRo5qjpwo2fdg+iZ-AURMCg@mail.gmail.com> <28131.1322067903@sss.pgh.pa.us> <232B5217AD58584C87019E8933556D11036BDE58EB@redmx2.esri.com> <4ED4D63402000025000435E8@gw.wicourts.gov>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox