Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5kma-0005Tq-2O for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Dec 2014 00:35:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5kmZ-00068f-Ir for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Dec 2014 00:35:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5kmY-00068W-SH for pgsql-bugs@postgresql.org; Tue, 30 Dec 2014 00:35:30 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y5kmV-0006pv-AU for pgsql-bugs@postgresql.org; Tue, 30 Dec 2014 00:35:29 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C770A2074A for ; Mon, 29 Dec 2014 19:35:25 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Mon, 29 Dec 2014 19:35:25 -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=n3cF5IN/QMot4mERUPLilDMAHtc=; b=hAqtJ7DMD2ymhxXuXW p3kCGENzrMQnyR95onMVmRcul1f8QClRhgIS7tWQVGrjLjvrUgc+q8W70kcKor4T HRWy9oVB5xBzeY5dZBDY4VgUqB6tDj4n5X0h5bVhbdtOdntKap5wFsKD6Zo13tVd dUSgLH+na4i0+7n9K+rs/3ib8= 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=n3cF5IN/QMot4mERUPLilD MAHtc=; b=X7dbaNGnLE2YblkwyBaUsoLTY8yzUGJdbRokfFlfKX92RsOn3qywnB N4UtrDT66ViwbbfGXaHPdKdnyv8KauRtdPP9A/kFNXbnFGaF97VPZ4TL9Lv+kq2k MQxDTI20vDL4yx8J9hoUQh8k1Q6KJS0wCjK55fJ/A0rEVieJNmw70= X-Sasl-enc: bIJmrv0+QLdfjBIu/n0ALcKrURV/Amt+71DqL2pY0iq7 1419899725 Received: from [192.168.1.2] (unknown [174.21.251.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 1A467680114; Mon, 29 Dec 2014 19:35:24 -0500 (EST) Message-ID: <54A1F34C.8010106@aklaver.com> Date: Mon, 29 Dec 2014 16:35:24 -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" , "pgsql-bugs@postgresql.org" Subject: Re: [GENERAL] 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> <54A183C5.1080500@aklaver.com> <54A18A25.50303@aklaver.com> <54A1D0BA.4080609@aklaver.com> <54A1D7BF.3060300@aklaver.com> <54A1E5F6.2000100@aklaver.com> <54A1ED2C.2070701@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-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 12/29/2014 04:26 PM, David Johnston wrote: > On Mon, Dec 29, 2014 at 5:09 PM, Adrian Klaver > >wrote: > > On 12/29/2014 03:56 PM, David Johnston wrote: > > ​So you think psql should issue "COMMIT;" even if it is exiting > due to > > "ON_ERROR_STOP"? > > > I say yes, if it is a non-SQL error. As Viktor stated, SQL errors > abort the transaction. > > > ​Ok, so we disagree here because that distinction seems arbitrary and > decidedly not useful.​ > > > Whether you do or don't can you show me where in the > documentation the > current behavior is described? > > > Your biggest issue seems to be with --single-transaction and > ON_ERROR_STOP so: > > --single-transaction > > When psql executes a script, adding this option wraps > BEGIN/COMMIT around the script to execute it as a single transaction. > > Therefore: > > BEGIN; > script > COMMIT; > > I would and have agreed with your previous statements that it is not > clear enough that \i is not an SQL command and an error with same is > ignored by the transaction. Outside of that I see no problem. > > > ​That still leaves ambiguity. How about:​ > > ​--single-transaction > ​ When psql executes a script using this option it explicitly begins > a transaction at session start and commits that transaction at session > end. ​The transaction will commit even if the script is forced to exit > early due to ON_ERROR_STOP: and if no SQL errors have occurred all > statements prior to the error-inducing psql meta-command will be > committed. For this reason it is not recommended to combine this option > and ON_ERROR_STOP if you want the entire script to rollback instead of partially committing. - instead omit this option and supply the transaction > commands yourself. > > ON_ERROR_STOP > [existing wording] > As described under the --single-transaction option the commit > issued at session end will occur prior to psql exiting and could result > in running script being partially committed. Works for me:) > > David J. > -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs