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

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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 15:23:46
Message-ID: 202111291523.s3c73i5qvi7u@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021-Nov-29, Tom Lane wrote:

> Greg's patch would fix this specifically by ensuring that the line
> with the space and comment is treated as a separate history entry.
> So I don't really see that as a separate bug. Or, if you will,
> the fact that people see it as a bug confirms that such a line
> should be treated as a separate history entry.

I wonder if these things would be easier to deal with or more convenient
if we thought of -- as starting a line-scoped comment, and /* */ as
starting a query-scoped comment, and treat both types differently. That
is, a -- comment would not be part of the subsequent command (and they
would become two separate history entries), but a /* */ comment would be
part of the command, and so both the comment and the query would be
saved as a single history entry.

So with ignorespace, then you can get either behavior:

/* don't put neither comment nor command in history */
select 1;
and then nothing gets put in history; but if you do

-- don't put this *comment* in history, but do put command
select 1;

then the comment is ignored, but the query does end up in history.

Perhaps one problem is how to behave with intra-query -- comments.
Surely they should not split the command in three parts, but I'm not
sure to what extent that is possible to implement.

This doesn't actually fix the issue that Greg was complaining about,
because his problem is precisely the -- comments. But would Greg and
other users be satisfied if we made that distinction?

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2021-11-29 15:25:04 Re: Correct handling of blank/commented lines in PSQL interactive-mode history
Previous Message Justin Pryzby 2021-11-29 15:15:35 Re: Lots of memory allocated when reassigning Large Objects