Suggested fix for \p and \r in psql - Mailing list pgsql-hackers

From Daniel Verite
Subject Suggested fix for \p and \r in psql
Date
Msg-id 9b4ea968-753f-4b5f-b46c-d7d3bf7c8f90@manitou-mail.org
Whole thread Raw
Responses Re: Suggested fix for \p and \r in psql  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
  Hi,

I've noticed two issues with the query buffer post-commit e984ef5
(Support \if ... \elif ... \else ... \endif in psql scripting):

1. \p ignores the "previous buffer". Example:

postgres=# select 1;
 ?column?
----------
    1
(1 row)

postgres=# \p
Query buffer is empty.

That doesn't match the pre-commit behavior, and is not
consistent with \e or \w


2. \r keeps the "previous buffer". I think it should clear it. Example:

postgres=# select 1;
 ?column?
----------
    1
(1 row)

postgres=# select 2 \r
Query buffer reset (cleared).
postgres=# \w /tmp/buffer
postgres=# \! cat /tmp/buffer
select 1;

I suggest the attached fix, with a few new regression tests.


Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite

Attachment

pgsql-hackers by date:

Previous
From: Fabien COELHO
Date:
Subject: Re: Variable substitution in psql backtick expansion
Next
From: Konstantin Knizhnik
Date:
Subject: FDW and parallel execution