pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert Zenz <robert.zenz@sibvisions.com>
To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Information on savepoint requirement within transctions
Date: Mon, 29 Jan 2018 15:06:30 +0000
Message-ID: <5A6F3875.80607@sibvisions.com> (raw)
In-Reply-To: <CAF-3MvMA-4hJU1NRLUHqwa1nPe5msFwP92MuNJFgZAyxozk5sA@mail.gmail.com>
References: <5A6B3F78.6030908@sibvisions.com>
	<CANu8Fixd_cKLouG_euktWHs12Nc7Ld5VXZ-qu13yuSs7HKnVPw@mail.gmail.com>
	<5A6B4A12.9000002@sibvisions.com>
	<CANu8FixBRh=+aKFDPtWc6o4o_++tOTDQSGDOBTsQ5AnfiiCFCQ@mail.gmail.com>
	<CAKFQuwYY+uMxpgmWm=V=E99GL8x53cY5-oBnnqGb8ZhTmcbznw@mail.gmail.com>
	<5A6EDD41.70005@sibvisions.com>
	<CAKFQuwbTro=vw6UxkGaR6DRdaPxGBOKTsLDJFWqD9Uz-n7gVXA@mail.gmail.com>
	<5A6F28A7.5080800@sibvisions.com>
	<CAF-3MvMA-4hJU1NRLUHqwa1nPe5msFwP92MuNJFgZAyxozk5sA@mail.gmail.com>

On 29.01.2018 15:11, Alban Hertroys wrote:
> IMHO, the burden of explaining that is with those RDBMSes that don't
> behave properly:
> 
> If you start a transaction and something goes wrong in the process,
> the logical behaviour is to fail - the user will want to rollback to a
> sane state, doing any more work is rather pointless because of that.
> Allowing a commit at the end is dubious at best.

One could argue that automatically "undoing all broken things" (read: reverting
back to the state before the failing statement was executed) would be a feature
worth having. As far as I recall, that has also been brought up on the mailing
list. Though, I don't care particularly about it. I was just interested in the
documentation.

> That does not exclude PG from documenting this behaviour, but I'd have
> a look at the docs for those other vendors whether they perhaps
> documented their irregular transactional behaviour ;)

Heh, good luck. :)

> You didn't mention which RDBMSes behave like what you expected
> (probably from experience), but I seem to recall Oracle does odd stuff
> like that, as well as issuing a commit to all open transactions when
> any DDL happens or treating NULLs and empty literals as the same
> thing. Just to say that the "big names" aren't without flaws - they're
> kind of hard to fix when users probably depend on their behaviour
> though.

To reiterate my example (to get rid of any misconceptions):

    begin transaction
    insert row #1
    insert row #2 (this fails)
    insert row #3
    commit

I've tested MySQL/MariaDB, Oracle, H2 and SQLite, all allow to continue a
transaction after a failed statement without user interaction (rows #1 and #3
are in the database after committing). PostgresSQL requires the manual rollback
to savepoint after a failed statement (obviously stores #1 and #3 in the
database if each insert is "wrapped" with a savepoint). MSSQL on the other hand
loses the complete state up to the failed statement and allows the user to
continue to use the transaction like nothing happened (only #3 is inserted when
committing). So, I think we can all agree who's the actually broken one here. ;)

view thread (32+ messages)  latest in thread

Message-ID: <5A6F3875.80607@sibvisions.com>
Permalink:  ../5A6F3875.80607@sibvisions.com/
Also on:    postgresql.org/message-id/5A6F3875.80607@sibvisions.com

 · 

reply

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-general@postgresql.org
  Cc: robert.zenz@sibvisions.com
  Subject: Re: Information on savepoint requirement within transctions
  In-Reply-To: <5A6F3875.80607@sibvisions.com>
  References: <5A6B3F78.6030908@sibvisions.com> <CANu8Fixd_cKLouG_euktWHs12Nc7Ld5VXZ-qu13yuSs7HKnVPw@mail.gmail.com> <5A6B4A12.9000002@sibvisions.com> <CANu8FixBRh=+aKFDPtWc6o4o_++tOTDQSGDOBTsQ5AnfiiCFCQ@mail.gmail.com> <CAKFQuwYY+uMxpgmWm=V=E99GL8x53cY5-oBnnqGb8ZhTmcbznw@mail.gmail.com> <5A6EDD41.70005@sibvisions.com> <CAKFQuwbTro=vw6UxkGaR6DRdaPxGBOKTsLDJFWqD9Uz-n7gVXA@mail.gmail.com> <5A6F28A7.5080800@sibvisions.com> <CAF-3MvMA-4hJU1NRLUHqwa1nPe5msFwP92MuNJFgZAyxozk5sA@mail.gmail.com> <5A6F3875.80607@sibvisions.com>

* 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