Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y5iwp-0001Uq-EL for pgsql-general@arkaria.postgresql.org; Mon, 29 Dec 2014 22:37:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y5iwo-0005hT-Ry for pgsql-general@arkaria.postgresql.org; Mon, 29 Dec 2014 22:37:58 +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 1Y5iwm-0005eL-TY for pgsql-general@postgresql.org; Mon, 29 Dec 2014 22:37:57 +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 1Y5iwj-0008Kr-7x for pgsql-general@postgresql.org; Mon, 29 Dec 2014 22:37:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6860520B42 for ; Mon, 29 Dec 2014 17:37:52 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Mon, 29 Dec 2014 17:37:52 -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=01FFPDCDdXvakQkFzRqltzaacb4=; b=GHDyCmBMMXEOzpg25w ml0T8zUMEjJGRyB82La+FuNntx5t9/ivqsQwjeYDY33Ca4kk0RaQzc4LrX9AUaeH 3BTOnzyk2szuS+hfCi2KyWKfj4A1tnGA62RigDcM2KwMXyzgDfyqlKIGqMP9QqkJ FkzOc0A81DEN4s0bMP1hbWKhg= 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=01FFPDCDdXvakQkFzRqltz aacb4=; b=EP/P8NS4lvykCIt+cCih4dLkxN5BNg7VSN/E+Ejuk1s8s3QQmuSD98 FileW0Ve/sBmEWPwyGMT7Gras+euAEzfyx3yjBFGNbHEghLOuTBpZBF7rfwvbvRq E+jILrhJqqxl/dqvqFGaDWzftoRH1CaPdw4762AvDPwS+HOwi6YWQ= X-Sasl-enc: YgfnrsJCAybDOMB9xyG7BvVKpbXMiiQwqperE8G2TlbM 1419892672 Received: from killi.site (unknown [50.197.80.2]) by mail.messagingengine.com (Postfix) with ESMTPA id BF8AFC00282; Mon, 29 Dec 2014 17:37:51 -0500 (EST) Message-ID: <54A1D7BF.3060300@aklaver.com> Date: Mon, 29 Dec 2014 14:37:51 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux x86_64; 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: 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> 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 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 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? > > 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). i.e., if in an actual > transaction the server will not issue the standard "error has > occurred, > you must ROLLBACK." message for any subsequent statements in the > script. This is probably not to the level of a bug but it is > related to > the ON_ERROR_STOP bug. > > > I could see improving the wording on this, to let the user know that > includes are on them as Viktor already determined and took action on. > > > ​I think you have a typo somewhere here 'cause that sentence fragment > (...includes and on them as) makes no sense to me.​ Should have been clearer. I am saying that it would be good to tell users that using \i(nclude) puts the burden on them to verify the included scripts actually can be found. > > The overall complaint is that a missing \include file, without > ON_ERROR_STOP, ​ends up being totally ignored even while in > non-interactive mode. I get the benefit to that behavior in interactive > mode and so being required to use ON_ERROR_STOP in script mode (which is > the safest practice anyway) isn't that big a deal as long as in that > mode a failure causes an immediate stop without any other SQL being sent > to the server and, by extension, the session closing and effecting a > rollback in the process if in --single-transaction mode just like that > mode promises. > > I'm not sure why --single-transaction even exists TBH. The script > should determine its desired transaction modes and not leave the > decision up to the caller. If the script relies on all-or-nothing it > should have explicit BEGIN/COMMIT statements. > > That said it does exist so it should play nicely with ON_ERROR_STOP. It > currently does not nor is the not-nice interaction documented anywhere. > > David J. -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general