Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qil9I-007kj0-4w for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Sep 2023 00:33:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qil9G-00D1ut-K2 for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Sep 2023 00:32:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qil9F-00D1uR-84 for pgsql-hackers@lists.postgresql.org; Wed, 20 Sep 2023 00:32:58 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qil96-006D8z-LZ for pgsql-hackers@lists.postgresql.org; Wed, 20 Sep 2023 00:32:56 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0F1B53200953; Tue, 19 Sep 2023 20:32:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 19 Sep 2023 20:32:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type: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=fm2; t=1695169964; x=1695256364; bh=OV cKoEua+IqgCa53zZhohH3McXY5GDX+YRHv4ey9v4A=; b=Vm+N+voQsQLJfkyu5O LFMVAo3e2rR6XxiwMMyk6np1zuYFIvQvmAoJjs2AYkZsTG3piC3i2WAYB+PgtvT9 FmvSKonohtHYchhLD2zic8g/ZUXyyeiqq59emEW333lt9dCoAnO6uXLcZWfspsjp gcECd72X6/g3zd+uESsnGhKUz7enhxHVeI795f1Pce7h+NQvgqdiaewJACG8n6WX U8/pqVWFp7GmX+YZkUF4Tit51Bozldttuf8eMrv5V4C62Izi6eqJc6/i8no0ydiy IfsRJibCKRr8OEESONwG//fzD1gPtNyZLVespzF0j92aqD1TqEy+0wrlmOYqRTme i4dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type: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=fm2; t=1695169964; x=1695256364; bh=OVcKoEua+IqgC a53zZhohH3McXY5GDX+YRHv4ey9v4A=; b=ETy+IW6382PzgKDYTlGE2QzeDQpMX p5RRofI2xttO0Bvmof3pCsXul6zjI5J1QgRaXgmgYVy8W6m/rK9gwXpUEYD2nrGV IPVVaMs32LcqKig2w1I4XtyfqdpwHyOq2DZi8ks8imcYWpyojf8FQeY7fNb3K8ja 180xJa715SvA1IkN0m9GMJFlVyBSQi9DgnvsXgzx/fr2zp316PrDH0fVJbdXUsBW wmhCrtmzhZtBNbHHQYYB7niLA+JWTieaFHymJfDdwj+SRN/WRExagU0osS/nXRiY nls278lG4A9RYKO96FHlcY/S60tOc/4a5IG+MAt5A1BZnce0FMCw/4qMw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekvddgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 19 Sep 2023 20:32:40 -0400 (EDT) Date: Wed, 20 Sep 2023 09:32:36 +0900 From: Michael Paquier To: Aleksander Alekseev Cc: pgsql-hackers@lists.postgresql.org, Kyotaro Horiguchi , bt23yoshidar@oss.nttdata.com Subject: Re: Bug fix for psql's meta-command \ev Message-ID: References: <01419622d84ef093fd4fe585520bf03c@oss.nttdata.com> <20230915.151750.1163612305682721014.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Py1kVux0IXWRG0HJ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Py1kVux0IXWRG0HJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --Py1kVux0IXWRG0HJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmUKPaQACgkQnvQgOdby QH2ODA//auDXQ+xw6U67IbEOTseW+cdH2BMknsiYFrz++K+KXL0m3IhVOZbeH6eo 1HBEMxe8DDqm8v8sw4iM2CAybbDb3rMpz43Za4WvjZCPq7rrtVlmGucnlXDaBp0M hoQCCjYYjhqHle/kzMiwbqt4a6xt1xdhO4pkFUYc4XNj/f/ywpnptd0gnIEGXFif k5PqPGO88c7QsSNVNU1rSYF5zC5k9hxjyO3f4rgz9oyXCWqXSkjgN/KQPk0louoK KgzQdJxp7O11gJ2MyeUDtChZsjjpL9pvMEHeFJlrow0pxvkWcvoyASz8kdZhvJnu lPZSTeAzb3sJ0mAAvzjpsTq4Oj4p3KVVOM3SLEiOyFrZGSvyoOgiGok2eupJVpDn +St+zyuNE43w512nEke1yIPrgdrafmlReT3X2g0Xuv6+YXIjKaZmxjogJq9NL2he ehwSa6aZyw0+PhJuZ0G5lzyO84KPeSuHjBY1WLryUllY7xqXPYfIrMYwZz6st2Dd UDYn8UuRAIUZcEY14btPz1MqXHaJpDukFQEiih4Qeu92iuog8NdbKR1VS7is2J/6 /glWvBL8tf4MbmB/FogYCJVJsnY5gqcupXqa7wf3MHAT+iqxqTWKX69M5WplmeVk PpwWwHiwGo/BXhwLcfjTvS8ojiGPmZfVezeQHBf0KVGiOw2qFSA= =63bH -----END PGP SIGNATURE----- --Py1kVux0IXWRG0HJ--