Re: Bug fix for psql's meta-command \ev

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, bt23yoshidar(at)oss(dot)nttdata(dot)com
Subject: Re: Bug fix for psql's meta-command \ev
Date: 2023-09-18 15:54:50
Message-ID: CAJ7c6TMnvwgDRU5KmcTf_Nqar0mhuc6Q0FEtPnoJkNos_wQAbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I came across the patch since it was marked as "Needs review" (and
then I realized that I mistakenly opened the upcoming commit fest, not
the current one...).

> Good catch! I agree to this.
>
> > This problem can be resolved by resetting the query buffer on
> > error. You can see the attached source code. After that, it will
> > result in output like the following:
>
> While exec_command_ef_ev() currently preserves the existing content of
> the query buffer in case of certain failures, This behavior doesn't
> seem to be particularly significant, especially given that both \ef
> and \ev are intended to overwrite the query buffer on success.
>
> We have the option to fix get_create_object_cmd() and ensure
> exec_command_ef_ev() retains the existing content of the query buffer
> on failure. However, this approach seems like overly cumbersome. So
> I'm +1 to this approach.
>
> A comment might be necessary to clarify that we need to wipe out the
> query buffer because it could be overwritten with an incomplete query
> string due to certain failures.

I tested the patch and it LGTM too. I don't have a strong opinion on
whether we should bother with a comment or not.

As a side note I wonder whether we shouldn't assume that query_buf is
always properly initialized elsewhere. But this is probably out of
scope of this particular discussion.

--
Best regards,
Aleksander Alekseev

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthias van de Meent 2023-09-18 15:56:00 Re: Improving btree performance through specializing by key shape, take 2
Previous Message Greg Sabino Mullane 2023-09-18 15:45:01 Re: Make --help output fit within 80 columns per line