Re: TODO item -- Improve psql's handling of multi-line

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: TODO item -- Improve psql's handling of multi-line
Date: 2005-12-08 01:51:03
Message-ID: Pine.LNX.4.44.0512080442460.30096-200000@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sai(dot)msu(dot)ru

Attachment Content-Type Size
psql.patch text/plain 8.8 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-12-08 02:37:13 Re: TODO item -- Improve psql's handling of multi-line queries
Previous Message Simon Riggs 2005-12-07 22:24:07 Re: Skipping VACUUM of indexes when no work required