pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: christoph.berg@credativ.de
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #17504: psql --single-transaction -vON_ERROR_STOP=1 still commits after client-side error
Date: Fri, 10 Jun 2022 11:41:49 -0400
Message-ID: <2649417.1654875709@sss.pgh.pa.us> (raw)
In-Reply-To: <Yp1jUAVnyYfn80vu@paquier.xyz>
References: <YpTgRGknCLBopP8C@msg.df7cb.de>
	<20220531.113927.640026319524742851.horikyota.ntt@gmail.com>
	<YphNHbOkg22H7d52@paquier.xyz>
	<20220603.175603.682874096867945240.horikyota.ntt@gmail.com>
	<Yp1jUAVnyYfn80vu@paquier.xyz>

Michael Paquier <michael@paquier.xyz> writes:
> On Fri, Jun 03, 2022 at 05:56:03PM +0900, Kyotaro Horiguchi wrote:
>>> It causes psql to issue a BEGIN command before the first such option
>>> and a COMMIT command after the last one, thereby wrapping all the
>>> commands into a single transaction.
>>> If any of the commands fails, a ROLLBACK command is sent instead.
>>> This ensures that either all the commands complete successfully, or
>>> no changes are applied.

> Looks fine to me, so applied down to 10.

While preparing release notes, I had to study this commit to figure
out what it actually did, and I do not think it is right yet.  It
definitely does not do what is claimed above, ie rollback if "any"
of the steps fails.  As coded, it rolls back only if the *last*
step fails.  Now, if you've got ON_ERROR_STOP set, then the loop
terminates after an error so there's no difference ... but if you
do not, I think this behavior is not what's expected.

ISTM that an appropriate fix would be to remember if any command
failed, not just the last one.

			regards, tom lane





view thread (22+ messages)  latest in thread

Message-ID: <2649417.1654875709@sss.pgh.pa.us>
Permalink:  ../2649417.1654875709@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2649417.1654875709@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, horikyota.ntt@gmail.com, 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
  In-Reply-To: <2649417.1654875709@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox