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

From Andreas Seltenreich
Subject Re: TODO item -- Improve psql's handling of multi-line queries
Date
Msg-id 87hd9kheof.fsf@gate450.dyndns.org
Whole thread Raw
In response to Re: TODO item -- Improve psql's handling of multi-line  ("Sergey E. Koposov" <math@sai.msu.ru>)
Responses Re: TODO item -- Improve psql's handling of multi-line  ("Sergey E. Koposov" <math@sai.msu.ru>)
List pgsql-patches
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:

--8<---------------cut here---------------start------------->8---
nnpg=# select
nnpg-#   something_i_would_rather_not_submit_yet
nnpg-# -- <control-c>
nnpg=# select 1;
 ?column?
----------
        1
(1 row)

nnpg=# -- <control-p> will now yield the following history entry
nnpg=# select
  something_i_would_rather_not_submit_yet
select 1;
--8<---------------cut here---------------end--------------->8---

Some more comments:

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?

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 :-)

regards,
Andreas

pgsql-patches by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Skipping VACUUM of indexes when no work required
Next
From: Nicolas Barbier
Date:
Subject: Re: Patch to allow contrib/pgbench files to have blank lines