Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5jtX-0003PP-W9 for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Dec 2014 23:38:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5jtX-0000rQ-Gv for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Dec 2014 23:38:39 +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 1Y5jtV-0000rH-9N for pgsql-bugs@postgresql.org; Mon, 29 Dec 2014 23:38:37 +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 1Y5jtR-00010X-CK for pgsql-bugs@postgresql.org; Mon, 29 Dec 2014 23:38:35 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id ED90A20AEB for ; Mon, 29 Dec 2014 18:38:31 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Mon, 29 Dec 2014 18:38:31 -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=+d+D5awdVRKqGHLOcP/M7zy23dw=; b=iRvJ8B7O1wMUN1QklG WeEWhpP7j9irvq3PK+sj5ELnQaIwxR2kBVaKeIjfvrqwXPIaiTriTqkMaGvsYOJs /T0tejzqoFkBaLpKeoITnrlFxpbr9RnFeRMRggD875EXCBm6n6f2q+3NuMm2delb SP42/F7lKd/E40+5B8ykhFccY= 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=+d+D5awdVRKqGHLOcP/M7z y23dw=; b=tYzmmhawmmAldjsNSel0xiowPsJwKT8aCK+Z8suVFrY8dxKalGG5B2 76tdmOSOrfEFsmMQakZ8RxUFz1+JvYvmBUJmnF7hmhuo1M6cpS7/zEHv/qh0tbHC DnQ8QKaON+DZOzRSr/S//3wS1JVrXaZKLObHPoeuRbDlW+jxJXh5I= X-Sasl-enc: wrTPq14E/HgfXDZUTszZkGyvAESQcdai8cTCmQv7QX3F 1419896311 Received: from [192.168.1.2] (unknown [174.21.251.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 55CC1C00281; Mon, 29 Dec 2014 18:38:31 -0500 (EST) Message-ID: <54A1E5F6.2000100@aklaver.com> Date: Mon, 29 Dec 2014 15:38:30 -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> 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 02:55 PM, David Johnston wrote: > On Mon, Dec 29, 2014 at 3:37 PM, Adrian Klaver > >wrote: > > On 12/29/2014 02:28 PM, David Johnston wrote: > > On Mon, Dec 29, 2014 at 3:07 PM, Adrian Klaver > > >>wrote: > > On 12/29/2014 09:38 AM, David Johnston wrote: > > > This is one of those glass half full/empty situations, > where it is > down to the eye of the beholder. I would also say > this a > perfect > example of why tests are written, to see what > actually happens > versus what you think happens. > > > ​If a user of our product needs to run a test to determine > behavior then > our documentation is flawed - which is the point I am > making. > > > Still not seeing the flaw in the documentation. > ​​ > ​... > ​ > ​psql does not see any error due to meta-commands or > SQL as fatal - > which is why the ON_ERROR_STOP option exists. > > > And ON_ERROR_STOP does not change that. All it does is toggle > whether psql continues on after an error or stops > processing commands. > > > > If it walks and talks like a duck...the fact that ON_ERROR_STOP > makes > psql halt processing means that it now treats them like it does any > other fatal error.​ > > > But it does not: > > ON_ERROR_STOP > > By default, command processing continues after an error. When > this variable is set, it will instead stop immediately. In > interactive mode, psql will return to the command prompt; otherwise, > > psql will exit, returning error code 3 to distinguish > this case from fatal error conditions, which are reported using > error code 1. > > In either case, any currently running scripts (the top-level script, > if any, and any other scripts which it may have in invoked) will be > terminated immediately. If the top-level command string contained > multiple SQL commands, processing will stop with the current command. > > > ​I am not seeing what point you are trying to make here.​ psql exits - > my contention is that it should do so before issuing "COMMIT;" if > --single-transaction was specified. I really don't care what made psql > exit - a fatal error or a non-fatal one while running under ON_ERROR_STOP. I am having trouble keeping up with this line of reasoning: "​psql does not see any error due to meta-commands or SQL as fatal - which is why the ON_ERROR_STOP option exists. " " If it walks and talks like a duck...the fact that ON_ERROR_STOP makes psql halt processing means that it now treats them like it does any other fatal error.​ " "I really don't care what made psql exit.." At this point I agree to disagree. > > I can find out the root cause by checking for either a 3 or a 1 but what > am I supposed to do with that information? More specifically, what > should I do if I see a 3 that I wouldn't do if I see a 1; and > vice-versa. As a user I really don't care I just want to know that any > changes my script may have performed prior to the error have been rolled > back if psql exits with a non-zero status. Then why have return status codes? > > > I believe that if ON_ERROR_STOP causes an abort that > the COMMIT from > --single-transaction should not run. That is a behavior > change. But > not documenting the known and deterministic interaction > between > the two > options is a bug. > > > I am not seeing anything in the below that says an ABORT is > issued: > > > ​I was using term in its non-SQL sense: to stop processing and > return > control to the user.​ > > > So if is non-SQL why should the transaction care about it? > > > ​The transaction doesn't - but psql allows me to do non-SQL stuff along > side of SQL stuff and I want the entire thing to fail if either the SQL > or the non-SQL stuff has a problem. It is incumbent upon psql to make > the boundary between the two as invisible as possible and right now it > does not do as good a job as it could. psql is a client not an all knowing entity. Not sure it is in its remit to monitor all possible interactions of database commands and non database commands. For instance, you have in a script a function written in plpythonu that sends email and in the same script a line that runs that function to send an email. Do you expect psql to abort everything if the receiving email server rejects the message? A contrived example to be sure, but not entirely out of the realm of possibility and journey done a tortuous path. > > From the standpoint of psql \include should be just as much a part of > the transaction as SELECT * FROM tbl - at least when operating in > file/script mode. My issue is with psql - how it manages the underlying > session/transaction to make that works is its problem and should be an > implementation detail I do not have to worry about. > > Note: This all likely extends to "\!" as well but I haven't gone and > explored that dynamic. Just not seeing it. At this point I have made my arguments. Will be interested whether others have comments or even care. > ​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