Re: Correct handling of blank/commented lines in PSQL interactive-mode history - Mailing list pgsql-hackers

From Greg Nancarrow
Subject Re: Correct handling of blank/commented lines in PSQL interactive-mode history
Date
Msg-id CAJcOf-fRXxbU2wAhYDqNJ7Frd73g5hSeBu0orPnO9wmWHaUsSQ@mail.gmail.com
Whole thread Raw
In response to Re: Correct handling of blank/commented lines in PSQL interactive-mode history  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Correct handling of blank/commented lines in PSQL interactive-mode history
List pgsql-hackers
On Tue, Nov 30, 2021 at 7:56 AM Tom Lane <tgl@sss.pgh.pa.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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Lots of memory allocated when reassigning Large Objects
Next
From: Chapman Flack
Date:
Subject: Re: improve CREATE EXTENSION error message