pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: [GENERAL] Rollback on include error in psql
Date: Mon, 29 Dec 2014 16:35:24 -0800
Message-ID: <54A1F34C.8010106@aklaver.com> (raw)
In-Reply-To: <CAKFQuwaWOs6iWPYeGZ6nZcUELvYBzckSviun7R9CAE7-hcNPHw@mail.gmail.com>
References: <CAK7FUCxR2cozA3ZTtPqUKgivFXBpPz=kJrfX6oWH5V5QtpnQBA@mail.gmail.com>
	<54A01E44.9050105@aklaver.com>
	<CAK7FUCxx8KHZ-nKb9RjB=S134kP2U8MjmNHLSUGo2Q13rY3Eyw@mail.gmail.com>
	<54A06C58.2020009@aklaver.com>
	<1419815044308-5832233.post@n5.nabble.com>
	<54A17800.1010700@aklaver.com>
	<CAKFQuwa1GOsfNc05rfCQ5X=WA9xwgVxbQWxs+uqmRCB+HEaw=g@mail.gmail.com>
	<54A183C5.1080500@aklaver.com>
	<CAKFQuwbPxVT+bKoGdT1KCmJUBSCGgQw+Epv7AbndcrDwWpP_Zw@mail.gmail.com>
	<54A18A25.50303@aklaver.com>
	<CAKFQuwaqyzRc1Dpt2HDm09OYUGZ9ysZ6406-Wj6QJkLnT_qrdw@mail.gmail.com>
	<54A1D0BA.4080609@aklaver.com>
	<CAKFQuwaEKnoP1i8CpHwn9_H1Wma5vRf13oinz1tdZ=MOpYek7Q@mail.gmail.com>
	<54A1D7BF.3060300@aklaver.com>
	<CAKFQuwYkfuxRrpKSe1n3wAgN+QTfXL3F7UCHmdvtm9KUX7gwkw@mail.gmail.com>
	<54A1E5F6.2000100@aklaver.com>
	<CAKFQuwaM6Uniq+aDGF=Mfo4ec80WaxrEYNBrYd+hf-w0c2X+-w@mail.gmail.com>
	<54A1ED2C.2070701@aklaver.com>
	<CAKFQuwaWOs6iWPYeGZ6nZcUELvYBzckSviun7R9CAE7-hcNPHw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

On 12/29/2014 04:26 PM, David Johnston wrote:
> On Mon, Dec 29, 2014 at 5:09 PM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>wrote:
>
>     On 12/29/2014 03:56 PM, David Johnston wrote:
>
>         ​So you think psql should issue "COMMIT;" even if it is exiting
>         due to
>
>         "ON_ERROR_STOP"?
>
>
>     I say yes, if it is a non-SQL error. As Viktor stated, SQL errors
>     abort the transaction.
>
>
> ​Ok, so we disagree here because that distinction seems arbitrary and
> decidedly not useful.​
>
>
>         Whether you do or don't can you show me where in the
>         documentation the
>         current behavior is described?
>
>
>     Your biggest issue seems to be with --single-transaction and
>     ON_ERROR_STOP so:
>
>     --single-transaction
>
>          When psql executes a script, adding this option wraps
>     BEGIN/COMMIT around the script to execute it as a single transaction.
>
>     Therefore:
>
>     BEGIN;
>     script
>     COMMIT;
>
>     I would and have agreed with your previous statements that it is not
>     clear enough that \i is not an SQL command and an error with same is
>     ignored by the transaction. Outside of that I see no problem.
>
>
> ​That still leaves ambiguity.  How about:​
>
> ​--single-transaction
> ​    When psql executes a script using this option it explicitly begins
> a transaction at session start and commits that transaction at session
> end.  ​The transaction will commit even if the script is forced to exit
> early due to ON_ERROR_STOP: and if no SQL errors have occurred all
> statements prior to the error-inducing psql meta-command will be
> committed.  For this reason it is not recommended to combine this option
> and ON_ERROR_STOP

if you want the entire script to rollback instead of partially committing.

- instead omit this option and supply the transaction
> commands yourself.
>
> ON_ERROR_STOP
>      [existing wording]
>      As described under the --single-transaction option the commit
> issued at session end will occur prior to psql exiting and could result
> in running script being partially committed.

Works for me:)

>
> David J.
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (24+ messages)

Message-ID: <54A1F34C.8010106@aklaver.com>
Permalink:  ../54A1F34C.8010106@aklaver.com/
Also on:    postgresql.org/message-id/54A1F34C.8010106@aklaver.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-bugs@postgresql.org
  Cc: adrian.klaver@aklaver.com, david.g.johnston@gmail.com, pgsql-general@postgresql.org
  Subject: Re: [GENERAL] Rollback on include error in psql
  In-Reply-To: <54A1F34C.8010106@aklaver.com>
  References: <CAK7FUCxR2cozA3ZTtPqUKgivFXBpPz=kJrfX6oWH5V5QtpnQBA@mail.gmail.com> <54A01E44.9050105@aklaver.com> <CAK7FUCxx8KHZ-nKb9RjB=S134kP2U8MjmNHLSUGo2Q13rY3Eyw@mail.gmail.com> <54A06C58.2020009@aklaver.com> <1419815044308-5832233.post@n5.nabble.com> <54A17800.1010700@aklaver.com> <CAKFQuwa1GOsfNc05rfCQ5X=WA9xwgVxbQWxs+uqmRCB+HEaw=g@mail.gmail.com> <54A183C5.1080500@aklaver.com> <CAKFQuwbPxVT+bKoGdT1KCmJUBSCGgQw+Epv7AbndcrDwWpP_Zw@mail.gmail.com> <54A18A25.50303@aklaver.com> <CAKFQuwaqyzRc1Dpt2HDm09OYUGZ9ysZ6406-Wj6QJkLnT_qrdw@mail.gmail.com> <54A1D0BA.4080609@aklaver.com> <CAKFQuwaEKnoP1i8CpHwn9_H1Wma5vRf13oinz1tdZ=MOpYek7Q@mail.gmail.com> <54A1D7BF.3060300@aklaver.com> <CAKFQuwYkfuxRrpKSe1n3wAgN+QTfXL3F7UCHmdvtm9KUX7gwkw@mail.gmail.com> <54A1E5F6.2000100@aklaver.com> <CAKFQuwaM6Uniq+aDGF=Mfo4ec80WaxrEYNBrYd+hf-w0c2X+-w@mail.gmail.com> <54A1ED2C.2070701@aklaver.com> <CAKFQuwaWOs6iWPYeGZ6nZcUELvYBzckSviun7R9CAE7-hcNPHw@mail.gmail.com> <54A1F34C.8010106@aklaver.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