Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwdYw-00067K-7P for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Jun 2022 05:40:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nwdYu-0004nA-PJ for pgsql-bugs@arkaria.postgresql.org; Thu, 02 Jun 2022 05:40:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwdYt-0004mV-0s for pgsql-bugs@lists.postgresql.org; Thu, 02 Jun 2022 05:40:00 +0000 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nwdYp-0001CP-UZ for pgsql-bugs@lists.postgresql.org; Thu, 02 Jun 2022 05:39:57 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 24BE43200912; Thu, 2 Jun 2022 01:39:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 02 Jun 2022 01:39:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1654148393; x=1654234793; bh=F8mod3X0mX T1us+wnaF49QzrsYJVYxAKcp6hOr8thdw=; b=RM5gyuuR+qSuGpGUKLnoxXYGjg 1uCV5umy4qanFjD6UsDIXYXEI4SjDahsIUIknRF1PXFvEJGnU6T4Fy+klHYU7qLL cy71WPq39bTRBoqW9Dy3YfWi9v2WJtmvZ8hgDeokKmfoue01xLZzkd2wbEoOqNmV YkT/g4UHhVSso7An+8RjXao2JhAAEaRKjk7WqHM+95NuGxyLwLXSym2/O6X/5Ieh KPfLlPLnUi8/CSdxZv22xrIX98Nb5gTpfd0ZpeX93MTlCFmgSbCTQQVpnOJN/HXa fkfwL+/Jjgq5mq07Vr0rHLhoR+nprY2biyWTSiE0Zgw3OJsp/HDvN6pA31kQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1654148393; x=1654234793; bh=F8mod3X0mXT1us+wnaF49QzrsYJV YxAKcp6hOr8thdw=; b=oY6RLRT4rKsTjkw46t9pA8mSls+OmrdzT82AKjT3f/+3 3DbNqH6AZKjypJFarwf21nhOYKud9qZUSX59wvRrjLlGx9AwO8eVzBvIMJqy+FRh +OqySXkOC9bkX9J0Q/ALoYE5spCBxrwbX5+CpqX9JoYqzz7cNVoxmBNRzD7Zj5Y5 d6quhUFoH3/OKd6c/FdLP4D2sa9grvPORCCUZBO2NJzoew2dEwZyDOAk6BxIKRPq 7ylsTIU6azC1aO7As/Mn1STnP+1KP8FFuvoevQ0/sYosMFRPEhURuqmOBIGLEIc5 qDdML4BkDAqoj4usNvPwxLFZ4FM0EbzbupNweh942g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrledugdelfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf evuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpeetleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthh grvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 2 Jun 2022 01:39:51 -0400 (EDT) Date: Thu, 2 Jun 2022 14:39:41 +0900 From: Michael Paquier To: Kyotaro Horiguchi Cc: christoph.berg@credativ.de, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17504: psql --single-transaction -vON_ERROR_STOP=1 still commits after client-side error Message-ID: References: <17504-76b68018e130415e@postgresql.org> <20220531.113927.640026319524742851.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="0lZZAiWmiIOgudmD" Content-Disposition: inline In-Reply-To: <20220531.113927.640026319524742851.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0lZZAiWmiIOgudmD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 31, 2022 at 11:39:27AM +0900, Kyotaro Horiguchi wrote: > The code looks like just a thinko that "COMMIT" works fine even if the > given commands have ended in failure. But actually it doesn't for > client-side failure. >=20 > diff --git a/src/bin/psql/startup.c b/src/bin/psql/startup.c > index ddff903915..2261f78f81 100644 > --- a/src/bin/psql/startup.c > +++ b/src/bin/psql/startup.c > @@ -426,7 +426,9 @@ main(int argc, char *argv[]) > =20 > if (options.single_txn) > { > - if ((res =3D PSQLexec("COMMIT")) =3D=3D NULL) > + res =3D PSQLexec(successResult =3D=3D EXIT_SUCCES= S ? > + "COMMIT" : "ROLLBACK"); > + if (res =3D=3D NULL) > { > if (pset.on_error_stop) > { Yeah, it seems a bit strange to commit the changes if an error happens on the client side, and the docs are a bit blurry about that because it has never been considered, I guess. This would not happen with a failure in the backend as COMMIT would just map to a ROLLBACK automatically. The change that you are sending would enforce this policy as Christoph would like. Some tests would be nice to check such behaviors, say in 001_basic.pl, but we also need to be careful when sending down queries with psql expected to fail because of SIGPIPE (c757a3d, 6d41dd0). The docs need a refresh, they mention now that COMMIT is sent after the last command but that would not be the case anymore with this patch if there is a client-side error. -- Michael --0lZZAiWmiIOgudmD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmKYTR0ACgkQnvQgOdby QH2qwRAAjEtWSVhQb+5hZgFbYJjkgPHFVUsQ1Js4zOsxQPjs0RFbJ6AUMnaDTlqi kX/Z9CpJyHss1hctxz+7Y5Q1hCAyjNW5wNeHiq8ets7SPp6LHccveU2pa+0Drv3j KSSCmsgGGwJBonpoZ7TShoGtgUvK8bXTePM/wC0GMga5fviJgEO12jL2M0AV7qMk NXnVOdpBn3YWlF+/ganZfCKYGDUh9IxJxUCqRZXaQ2Vj87O+h6zM8IOdPCfzQgpr 5cJtbp4shIU8cnVaLluq4GOxIeilsdOBf3dIMR6/uRsRArB+/X5ix/Qz0l3wTzqu +S50HEmHVqGrl15hZRciWJpVPXqzp8ao0eZPtSlW+DETXQJs3VU9RA/qYKqpM4H+ 80GOC+hX/VnIPPs68PhDUNUbDD8lo4BR6sSsev4GE3skQ/msmM5qWuZCvCBCHzs5 sHsUYe09YSPbWw7By8bb0r8MGqeOPO9up5/aYUd2mOxqWXyW5yLXpEmUe7j/i3tw pk8NzhzlwhWXfUTYfw9HBbmI6ep0TFCHX+3yUIVF5buG9/aG6zNcfIq/jEf7juta znBDGz3IL8ClxqFJNy5MzXXUmzCLql0ZeHHLL9BfxCbUqYXzsjVfbOwN07VHK3t6 4JVKZ0qKMsXckFsPSBdVS/jumz/wjnwMhHNwLgoLBPySVEKHqEc= =qXXc -----END PGP SIGNATURE----- --0lZZAiWmiIOgudmD--