psql \i command with a missing file name doesn't rollback the transaction

From: Alexey Klyukin <alexk(at)hintbits(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: psql \i command with a missing file name doesn't rollback the transaction
Date: 2013-09-20 09:15:01
Message-ID: CAAS3tyJYHtrs0PMeuTeEBvXFzH5aOBTWXH42sYOibkYfMBYa8w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

We've discovered a surprising behavior of psql \i command. What we
sometimes to add new tables to the database is:

begin;
\i /path/to/table/definitions/table1.sql
\i /path/to/table/definitions/table2.sql
...
\i /path/to/table/definitions/tableN.sql
commit;

What we discovered that some files in the /path/to/table/definitions were
missing (say, table 2,3), but the table 1, 4... N appeared in the database
after executing the transaction. This is quite a catch, since we cannot
rely on transaction consistency when using an include directive.

The test is simple:

begin;
\i whatever;
select 1;
commit;

The expected behavior was that select 1 would lead to 'ERROR: current
transaction is aborted'.
The current behavior is that it is executed, although a message is emitted
to a client:
whatever: No such file or directory

Would it be possible from the client side to generate the rollback to the
server on an attempt to include a non-existing file (perhaps only when
ON_ERROR_STOP is set to 1?).

--
Regards,
Alexey Klyukin

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Kellerer 2013-09-20 17:05:13 Re: Known issues for PostgreSQL server 8.1.19
Previous Message Dashputre, Anurag (GE Healthcare) 2013-09-20 06:39:57 Re: Known issues for PostgreSQL server 8.1.19