pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Aleksander Alekseev <aleksander@timescale.com>
Cc: pgsql-hackers@lists.postgresql.org, Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: bt23yoshidar@oss.nttdata.com
Subject: Re: Bug fix for psql's meta-command \ev
Date: Wed, 20 Sep 2023 09:32:36 +0900
Message-ID: <ZQo9pH4eN9fEvAVN@paquier.xyz> (raw)
In-Reply-To: <CAJ7c6TPBN-C_Y0WP1UnLvMxbBpS7-p7vneoaG96WBN-KsEJ2WQ@mail.gmail.com>
References: <01419622d84ef093fd4fe585520bf03c@oss.nttdata.com>
	<20230915.151750.1163612305682721014.horikyota.ntt@gmail.com>
	<CAJ7c6TMnvwgDRU5KmcTf_Nqar0mhuc6Q0FEtPnoJkNos_wQAbA@mail.gmail.com>
	<ZQkbVxL9fKZxMwVE@paquier.xyz>
	<CAJ7c6TPBN-C_Y0WP1UnLvMxbBpS7-p7vneoaG96WBN-KsEJ2WQ@mail.gmail.com>

On Tue, Sep 19, 2023 at 01:23:54PM +0300, Aleksander Alekseev wrote:
> You are right, I missed it. Your patch is correct while the original
> one is not quite so.

Actually there was a bit more to it in the presence of \e, that could
also get some unpredictible behaviors if some errors happen while
editing a query, which is something unlikely, still leads to strange
behaviors on failure injections.  I was considering first to move the
reset in do_edit(), but also we have the case of \e[v|f] where the
buffer has no edits so it felt a bit more natural to do that in the
upper layer like in this patch.

Another aspect of all these code paths is the line number that can be
optionally number after an object name for \e[v|f] or a file name for
\e (in the latter case it is possible to have a line number without a
file name, as well).  Anyway, we only fill the query buffer after
validating all the options at hand.  So, while the status is set to
PSQL_CMD_ERROR, we'd still do a reset of the query buffer but nothing
got added to it yet.

I've also considered a backpatch for this change, but at the end
discarded this option, at least for now.  I don't think that someone
is relying on the existing behavior of having the query buffer still
around on failure if \ev or \ef fail their object lookup as the
contents are undefined, because that's not unintuitive, but this
change is not critical enough to make it backpatchable if somebody's
been actually relying on the previous behavior.  I'm OK to revisit
this choice later on depending on the feedback, though.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (10+ messages)  latest in thread

Message-ID: <ZQo9pH4eN9fEvAVN@paquier.xyz>
Permalink:  ../ZQo9pH4eN9fEvAVN@paquier.xyz/
Also on:    postgresql.org/message-id/ZQo9pH4eN9fEvAVN@paquier.xyz

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: michael@paquier.xyz, aleksander@timescale.com, horikyota.ntt@gmail.com, bt23yoshidar@oss.nttdata.com
  Subject: Re: Bug fix for psql's meta-command \ev
  In-Reply-To: <ZQo9pH4eN9fEvAVN@paquier.xyz>
  References: <01419622d84ef093fd4fe585520bf03c@oss.nttdata.com> <20230915.151750.1163612305682721014.horikyota.ntt@gmail.com> <CAJ7c6TMnvwgDRU5KmcTf_Nqar0mhuc6Q0FEtPnoJkNos_wQAbA@mail.gmail.com> <ZQkbVxL9fKZxMwVE@paquier.xyz> <CAJ7c6TPBN-C_Y0WP1UnLvMxbBpS7-p7vneoaG96WBN-KsEJ2WQ@mail.gmail.com> <ZQo9pH4eN9fEvAVN@paquier.xyz>

* 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