Re: Correct handling of blank/commented lines in PSQL interactive-mode history

From: Greg Nancarrow <gregn4422(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Correct handling of blank/commented lines in PSQL interactive-mode history
Date: 2021-11-29 23:37:42
Message-ID: CAJcOf-fRXxbU2wAhYDqNJ7Frd73g5hSeBu0orPnO9wmWHaUsSQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 30, 2021 at 7:56 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> After some further hackery, here's a set of patches that I think
> might be acceptable. They're actually fairly independent, although
> they touch different aspects of the same behavior.
>
> 0001 gets rid of psqlscan.l's habit of suppressing dash-dash comments,
> but only once we have collected some non-whitespace query input.
> The upshot of this is that dash-dash comments will get sent to the
> server as long as they are within the query proper, that is after the
> first non-whitespace token and before the ending semicolon. Comments
> that are between queries are still suppressed, because not doing that
> seems to result in far too much behavioral change. As it stands,
> though, there are just a few regression test result changes.
>
> 0002 is a simplified version of Greg's patch. I think we only need
> to look at the state of the query_buf to see if any input has been
> collected in order to determine if we are within or between queries.
> I'd originally thought this'd need to be a lot more complicated,
> but as long as psqlscan.l continues to drop pre-query comments,
> this seems to be enough.
>
> 0003 is the same patch I posted before to adjust M-# behavior.
>

I did some testing of the patches against the 4 problems that I
originally reported, and they fixed all of them.
0002 is definitely simpler than my original effort.
The patches LGTM.
Thanks for working on this.
(BTW, the patches are in Windows CRLF format, so on Linux at least I
needed to convert them using dos2unix so they'd apply using Git)

Regards,
Greg Nancarrow
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chapman Flack 2021-11-29 23:46:09 Re: improve CREATE EXTENSION error message
Previous Message Tom Lane 2021-11-29 23:25:09 Re: Lots of memory allocated when reassigning Large Objects