From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Viktor Shitkovskiy <hanksmail@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Rollback on include error in psql
Date: Sun, 28 Dec 2014 07:14:12 -0800
Message-ID: <54A01E44.9050105@aklaver.com> (raw)
In-Reply-To: <CAK7FUCxR2cozA3ZTtPqUKgivFXBpPz=kJrfX6oWH5V5QtpnQBA@mail.gmail.com>
References: <CAK7FUCxR2cozA3ZTtPqUKgivFXBpPz=kJrfX6oWH5V5QtpnQBA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
On 12/28/2014 12:02 AM, Viktor Shitkovskiy wrote:
> Hello.
>
> I'm trying to execute an sql script file in a single transation. The
> file contains includes for some other scripts which in my example create
> some tables. It looks like this:
> \include ../tables/table1.cre
> \include ../tables/table2.cre
> ...
> \include ../tables/table10.cre
>
> I'm executing it using psql:
> psql -X --set AUTOCOMMIT=off --set ON_ERROR_STOP=on -e
> --single-transaction -d my_db -f my_script.sql
>
> The problem is that errors with the include meta command do not cause a
> transactiopn rollback. e.g. if some of tableX.cre files is missing, any
> changes before its include will be commited. However, if there's some
> SQL syntax error, everyting works as expected.
>
> Is it possible to somehow handle include related errors and rollback the
> active transcation?
>
Where is the \include coming from?
What is in the tableX.cre files?
So if I am following you want a complete rollback on non-SQL or SQL
errors, correct?
> I'm using PostgreSQL 9.2.1.
>
> P.S. Initially I asked this question at dba.stackexchange.com
> <http://dba.stackexchange.com;:
> http://dba.stackexchange.com/questions/87040/rollback-on-include-error-in-psql
--
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, hanksmail@gmail.com, pgsql-general@postgresql.org
Subject: Re: Rollback on include error in psql
In-Reply-To: <54A01E44.9050105@aklaver.com>
References: <CAK7FUCxR2cozA3ZTtPqUKgivFXBpPz=kJrfX6oWH5V5QtpnQBA@mail.gmail.com> <54A01E44.9050105@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