psql \r and \e -- what does clearing the query buffer actually do?

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: psql \r and \e -- what does clearing the query buffer actually do?
Date: 2023-10-23 18:27:24
Message-ID: CAHyXU0zzvirqhp_4ioipOKRGFc8rvt1RO3sVXNJxzx-LHCdTzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

Couple things -- after unintentionally running a query for the (what feels
like-) millionth time, it suggested a review of psql query editing
behaviors. Starting with,

\r (clear 'query buffer'): Other than dutifully reporting that the query
buffer has been cleared, I cannot for the life of me detect any observable
behavior. If there is in fact one, the results are, with some forbearance,
unintuitive. Consider:
postgres=# \p
select 0;
postgres=# \r
Query buffer reset (cleared).
postgres=# \p
select 0;

Perhaps, it is reset, only to re-reset to last known prompt when prompt
returned, but,
\r\e
...claims to rest but the query buffer still contains the last executed
command, which will then run with :q! in vim.

Regarding \e, things mostly work sanely, except that there is no way to not
run a query except to explicitly write a blank buffer back, say with vim
:wq after deleting all the lines in the buffer.. However, if you do so,
the previously run query shows up again, for the next \e, which is odd. Is
this behavior intentional? Is there something I'm missing? Apologies if
this has been discussed, cursory search did not turn up results, psql,
query, buffer, etc not being selective terms.

merlin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2023-10-23 18:50:13 Re: psql \r and \e -- what does clearing the query buffer actually do?
Previous Message Francisco Olarte 2023-10-23 17:26:31 Re: Very newbie question