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

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Greg Nancarrow <gregn4422@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2021-09-06T14:50:15Z
Lists: pgsql-hackers
On Mon, Sep 6, 2021 at 7:13 AM Greg Nancarrow <gregn4422@gmail.com> wrote:

> I've attached a patch that corrects the behaviour.
> For the type of lines mentioned, the patch makes the history behave
> more like Bash history.
>

I have my doubts that you've really fixed anything here since Bash is a
line-oriented shell while psql is a statement-oriented one.  This is a
feature.

What you are observing is, I think, a side-effect of that fact that
comments cannot terminate statements.  That seems reasonable.  In short,
your BEFORE results make sense and don't require fixing.

David J.

Commits

  1. psql: initialize comment-begin setting to a useful value by default.

  2. psql: treat "--" comments between queries as separate history entries.

  3. psql: include intra-query "--" comments in what's sent to the server.