From: Ryoga Yoshida <bt23yoshidar@oss.nttdata.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Aleksander Alekseev <aleksander@timescale.com>
Cc: pgsql-hackers@lists.postgresql.org, Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Subject: Re: Bug fix for psql's meta-command \ev
Date: Tue, 19 Sep 2023 15:29:11 +0900
Message-ID: <fd0bb41626615142bdd6cffe1ddcba52@oss.nttdata.com> (raw)
In-Reply-To: <ZQkbVxL9fKZxMwVE@paquier.xyz>
References: <01419622d84ef093fd4fe585520bf03c@oss.nttdata.com>
<20230915.151750.1163612305682721014.horikyota.ntt@gmail.com>
<CAJ7c6TMnvwgDRU5KmcTf_Nqar0mhuc6Q0FEtPnoJkNos_wQAbA@mail.gmail.com>
<ZQkbVxL9fKZxMwVE@paquier.xyz>
On 2023-09-19 12:53, Michael Paquier wrote:
> Adding a comment looks important to me once we consider the edit as a
> path that can fail and the edited query is only executed then reset
> when we have PSQL_CMD_NEWEDIT as status. I would suggest the patch
> attached instead, taking care of the error case of this thread and the
> ones I've spotted.
Thank you everyone for the reviews. I fixed the patch for the error and
also added a comment
. You can see attached file.
Ryoga Yoshida
Attachments:bug_fix_for_ev_command_2.patch (text/x-diff, 531B) downloaddiff --git a/src/bin/psql/command.c b/src/bin/psql/command.cindex bcd8eb3538..eb306d8d77 100644--- a/src/bin/psql/command.c+++ b/src/bin/psql/command.c@@ -1239,6 +1239,15 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
status = PSQL_CMD_NEWEDIT;
}
+ if (status == PSQL_CMD_ERROR)+ {+ /*+ * clear the query buffer because it could be overwritten with+ * an incomplete query string due to certain failures.+ */+ resetPQExpBuffer(query_buf);+ }+
free(obj_desc);
}
else
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: bt23yoshidar@oss.nttdata.com, michael@paquier.xyz, aleksander@timescale.com, horikyota.ntt@gmail.com
Subject: Re: Bug fix for psql's meta-command \ev
In-Reply-To: <fd0bb41626615142bdd6cffe1ddcba52@oss.nttdata.com>
References: <01419622d84ef093fd4fe585520bf03c@oss.nttdata.com> <20230915.151750.1163612305682721014.horikyota.ntt@gmail.com> <CAJ7c6TMnvwgDRU5KmcTf_Nqar0mhuc6Q0FEtPnoJkNos_wQAbA@mail.gmail.com> <ZQkbVxL9fKZxMwVE@paquier.xyz> <fd0bb41626615142bdd6cffe1ddcba52@oss.nttdata.com>
* 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