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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Greg Nancarrow <gregn4422(at)gmail(dot)com>, "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 20:56:28
Message-ID: 1433553.1638219388@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

regards, tom lane

Attachment Content-Type Size
0001-keep-intraquery-comments.patch text/x-diff 5.1 KB
0002-flush-empty-lines-to-history.patch text/x-diff 988 bytes
0003-fix-readline-comment-begin.patch text/x-diff 583 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-11-29 21:02:27 Re: improve CREATE EXTENSION error message
Previous Message Daniel Gustafsson 2021-11-29 20:32:20 Re: improve CREATE EXTENSION error message