Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5dM6-0005Lj-24 for pgsql-general@arkaria.postgresql.org; Mon, 29 Dec 2014 16:39:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5dM5-0007U0-DG for pgsql-general@arkaria.postgresql.org; Mon, 29 Dec 2014 16:39:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5dM3-0007Qu-J5 for pgsql-general@postgresql.org; Mon, 29 Dec 2014 16:39:39 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5dM0-0001cs-58 for pgsql-general@postgresql.org; Mon, 29 Dec 2014 16:39:37 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 7D7E5204C6 for ; Mon, 29 Dec 2014 11:39:34 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute2.internal (MEProxy); Mon, 29 Dec 2014 11:39:34 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h= x-sasl-enc:message-id:date:from:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; s=mesmtp; bh=QSld+ZVUcC8xx26eNawJGQME3gE=; b=Bk8Csg+SodZ4tZDwxL peTXHp3/gHKV+pX9wKVzi0Q7I1wRYJYBovXblA0UAd6tPI2K4SH6CQIHqXQkwfJw XqM+wXWENYPBCzmAyukSyXpuiJAKhh4khndGQPPAVtIILvGkgPH29NOzYvDbWSZm txqWqp7aJ5plNFH0DWVpF4B/o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:message-id:date:from :mime-version:to:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=QSld+ZVUcC8xx26eNawJGQ ME3gE=; b=jTDMo12XJcR1mhzFYJJP2dBV0XzJ7nYqyNP+UKg2m1yU6SXg5HlN+0 SX9UWVTcTR1pP21Tmrt6c2nIr5DCApfoBPQRSt37K8e0WvC6CTnKmFjNOMv4wzD5 TW/mzTmLQ/E0qAIqrFN6xe8ZZNllMyfMKWBr7df/mTBBwbRT57eSU= X-Sasl-enc: yWgmlvxkedeb900Qkx8eiLeo33bSJfYQV2eSCHq5+k97 1419871174 Received: from [192.168.1.2] (unknown [174.21.251.95]) by mail.messagingengine.com (Postfix) with ESMTPA id ED5FC68019F; Mon, 29 Dec 2014 11:39:33 -0500 (EST) Message-ID: <54A183C5.1080500@aklaver.com> Date: Mon, 29 Dec 2014 08:39:33 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: David Johnston CC: "pgsql-general@postgresql.org" Subject: Re: Rollback on include error in psql References: <54A01E44.9050105@aklaver.com> <54A06C58.2020009@aklaver.com> <1419815044308-5832233.post@n5.nabble.com> <54A17800.1010700@aklaver.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org On 12/29/2014 07:59 AM, David Johnston wrote: > On Mon, Dec 29, 2014 at 8:49 AM, Adrian Klaver > >wrote: > > On 12/28/2014 05:04 PM, David G Johnston wrote: > > Adrian Klaver-4 wrote > >> On 12/28/2014 10:06 AM, Viktor Shitkovskiy wrote: > >>> I include my own scripts. Each of them creates some table or > makes some > >>> changes to existing tables. > >> > >> It is hard to say where to go from here without more information. > > > > really? > > Yes. The if, ands and buts for each of the options by themselves > much less in > combination would indicate that an answer is dependent on what is > actually > happening in the scripts. We have a fragment of the main script and > not much information as to what is actually happening in the called > scripts. See > below why this is important. > > > > > This seems like a documentation bug (or, at the least worth more > > documentation explanation) at minimum; two of them probably: > > > > 1) it is not documented that "\include" is a valid alias for "\i" > > 2) the implications of \include being a client-side mechanic and > thus, > > invisible to the server, is not well explained. Specifically > that a failure > > to include is the equivalent of simply omitting the statement > altogether > > (aside from the psql warning). > > Agreed. > > > > > I would suggest an enhancement whereby psql will send a guaranteed-to-fail > > command to the server upon failing to find an included file - at least in > > non-interactive mode; in interactive mode the warning is likely sufficient > > though the interplay with auto-commit would be concerning. > > > > > >> The options you are passing to psql all have caveats: > > > > I'm not seeing how any of those caveats are coming into play here. > > > > The ON_ERROR_STOP behavior is actually surprising since psql does > indeed > > return 3 but even with single transaction and auto-commit=off any > updates > > prior to the include are committed. > > > > This isn't that difficult to test... > > [db] > > CREATE TABLE testtbl (col text PRIMARY KEY); > > INSERT INTO testtbl VALUES ( 'value' ); > > > > [script] > > UPDATE testtbl SET col = 'some other value'; > > \i some_missing_file.sql > > UPDATE testtbl SET col = 'yet another value'; > > [/script] > > > > execute using: > > > > psql --single-transaction --set ON_ERROR_STOP=1 --set > AUTOCOMMIT=off -f > >