Re: TODO item -- Improve psql's handling of multi-line - Mailing list pgsql-patches

From Sergey E. Koposov
Subject Re: TODO item -- Improve psql's handling of multi-line
Date
Msg-id Pine.LNX.4.44.0512080442460.30096-200000@lnfm1.sai.msu.ru
Whole thread Raw
In response to Re: TODO item -- Improve psql's handling of multi-line queries  (Andreas Seltenreich <seltenreich@gmx.de>)
Responses Re: TODO item -- Improve psql's handling of multi-line queries  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: TODO item -- Improve psql's handling of multi-line  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-patches
On Wed, 7 Dec 2005, Andreas Seltenreich wrote:

> Sergey E. Koposov schrob:
>
> > I submit the new version of my patch (against the CVS tip), correcting the
> > problem with \edit (pointed by Andreas). So now everything works fine.
>
> I think there's a pgflush_history() call missing somewhere, since the
> buffer isn't flushed on a control-c. The fresh query is appended to
> the aborted one in the history:

> Wouldn't it be more elegant to use the facilities in libpq's
> pqexpbuffer.h for the history buffer instead of passing the
> buffer-length around as a separate function argument and doing custom
> string operations?


Thank you, Andreas. I corrected the bug and also switched to pqexpbuffer
instead of my own work with the strings.

The new patch is attached.

>
> The multi-line history entries are not preserved between psql
> invocations. Bash does solve this by folding multi-line commands into
> a single line where possible. But I have to admit, this could be sold
> as another TODO item :-)
>

I also wanted this feature for a long time.
And I agree that it is rather simple to just remove the \n when writing to the
readline history file, but I don't think that's what everybody wants. I
think that people want to preserve the original formatting...

So in that case the solution can be just putting some symbol instead of \n
in the history file, and during the loading of that file replace it back
(that symbol can be zero byte for example). But I'm not sure that people
will like that solution too.


Regards,
    Sergey

*****************************************************
Sergey E. Koposov
Max-Planck Institut for Astronomy
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru

Attachment

pgsql-patches by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Skipping VACUUM of indexes when no work required
Next
From: Bruce Momjian
Date:
Subject: Re: TODO item -- Improve psql's handling of multi-line queries