From: Adrian Klaver <adrian.klaver@aklaver.com>
To: David Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Rollback on include error in psql
Date: Mon, 29 Dec 2014 09:06:45 -0800
Message-ID: <54A18A25.50303@aklaver.com> (raw)
In-Reply-To: <CAKFQuwbPxVT+bKoGdT1KCmJUBSCGgQw+Epv7AbndcrDwWpP_Zw@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>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
On 12/29/2014 08:49 AM, David Johnston wrote:
> On Mon, Dec 29, 2014 at 9:39 AM, Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>wrote:
>
> On 12/29/2014 07:59 AM, David Johnston wrote:
>
>
> Anyway, the third undocumented bug is that --single-transactions
> gets to
> send its COMMIT even if ON_ERROR_STOP
> takes hold before the end of the script. I imagined it such
> that only
> if every statement in the "-f <script>" was called would the
> COMMIT be
> issued - thus the error_stop would supercede and leave the session
> uncommitted and by default rolledback.
>
>
> Not seeing the bug. --single-transaction wraps the entire script in
> BEGIN/COMMIT, ON_ERROR_STOP stops 'processing' the command, nothing
> in there about stopping transaction or rollback. So the failed \i
> stops the script from processing anything after that and the session
> goes directly to the COMMIT. If you want to deal with transactions
> there is ON_ERROR_ROLLBACK. Though I did find something interesting
> about that, which will subject of another post.
>
>
> Then --single-transaction has nothing to do with the script file
> at-all. It should be documented as issuing a BEGIN at session connect
> and a COMMIT just before session disconnect - regardless of whether the
> named script executes to completion, which can happen if it is combined
> with ON_ERROR_STOP.
Seems to me when you do:
psql --single-transaction -f some_script
the script is the session.
ON_ERROR_STOP
" ..psql will exit, returning error code 3 to distinguish this case from
fatal error conditions, which are reported using error code 1"
So psql does not see this a fatal error.
This is one of those glass half full/empty situations, where it is down
to the eye of the beholder. I would also say this a perfect example of
why tests are written, to see what actually happens versus what you
think happens.
>
> David J.
>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
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: Rollback on include error in psql
In-Reply-To: <54A18A25.50303@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>
* 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