Skip site navigation (1) Skip section navigation (2)

Suggested fix for \p and \r in psql

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Suggested fix for \p and \r in psql
Date: 2017-04-02 13:22:04
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers

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;
(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;
(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:
Twitter: @DanielVerite

Attachment: psql-query-buffer.diff
Description: text/x-patch (5.0 KB)


pgsql-hackers by date

Next:From: Konstantin KnizhnikDate: 2017-04-02 13:30:24
Subject: FDW and parallel execution
Previous:From: Fabien COELHODate: 2017-04-02 13:14:46
Subject: Re: Variable substitution in psql backtick expansion

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group