Re: Rollback on include error in psql

From: Viktor Shitkovskiy <hanksmail(at)gmail(dot)com>
To: Melvin Davidson <melvin6925(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Rollback on include error in psql
Date: 2014-12-28 18:03:06
Message-ID: CAK7FUCxWGMPZvKy32B2hZTZmQcOP+DQLK=0m4Ou0zSr9oEPEpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

I use --single-transaction flag. But anyway, adding BEGIN and COMMIT
doesn't change anything. I stil get that problem.

On Sun, Dec 28, 2014 at 5:43 PM, Melvin Davidson <melvin6925(at)gmail(dot)com>
wrote:

> You did not show the complete script.
> Did you remember to start the "transaction" with BEGIN; and end with
> COMMIT;?
> eg:
> BEGIN;
> \include ../tables/table1.cre
> \include ../tables/table2.cre
> ...
> \include ../tables/table10.cre
> COMMIT;
>
>
> On Sun, Dec 28, 2014 at 3:02 AM, Viktor Shitkovskiy <hanksmail(at)gmail(dot)com>
> 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?
>>
>> I'm using PostgreSQL 9.2.1.
>>
>> P.S. Initially I asked this question at dba.stackexchange.com:
>> http://dba.stackexchange.com/questions/87040/rollback-on-include-error-in-psql
>>
>
>
>
> --
> *Melvin Davidson*
> I reserve the right to fantasize. Whether or not you
> wish to share my fantasy is entirely up to you.
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Viktor Shitkovskiy 2014-12-28 18:06:53 Re: Rollback on include error in psql
Previous Message Adrian Klaver 2014-12-28 15:14:12 Re: Rollback on include error in psql

Browse pgsql-general by date

  From Date Subject
Next Message Viktor Shitkovskiy 2014-12-28 18:06:53 Re: Rollback on include error in psql
Previous Message Adrian Klaver 2014-12-28 15:14:12 Re: Rollback on include error in psql