Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VRND4-000570-Gd for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Oct 2013 14:15:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VRND3-0007Uf-QK for pgsql-bugs@arkaria.postgresql.org; Wed, 02 Oct 2013 14:15:25 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VRND2-0007UV-Nt for pgsql-bugs@postgresql.org; Wed, 02 Oct 2013 14:15:24 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VRNCr-0002mg-QK for pgsql-bugs@postgresql.org; Wed, 02 Oct 2013 14:15:23 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1VRNCr-0004pf-0W; Wed, 02 Oct 2013 10:15:13 -0400 Date: Wed, 2 Oct 2013 10:15:13 -0400 From: Bruce Momjian To: Alexey Klyukin Cc: pgsql-bugs@postgresql.org Subject: Re: psql \i command with a missing file name doesn't rollback the transaction Message-ID: <20131002141513.GD21547@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Fri, Sep 20, 2013 at 11:15:01AM +0200, Alexey Klyukin wrote: > 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?). The problem is how would we decide what psql actions should trigger a rollback, and how would we show the user we did that. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs