psql _ and \e -- what does clearing the query buffer actually do? - Mailing list pgsql-general

From Merlin Moncure
Subject psql _ and \e -- what does clearing the query buffer actually do?
Date
Msg-id CAHyXU0zzvirqhp_4ioipOKRGFc8rvt1RO3sVXNJxzx-LHCdTzA@mail.gmail.com
Whole thread Raw
Responses Re: psql _ and \e -- what does clearing the query buffer actually do?
List 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

pgsql-general by date:

Previous
From: Francisco Olarte
Date:
Subject: Re: Very newbie question
Next
From: Tom Lane
Date:
Subject: Re: psql _ and \e -- what does clearing the query buffer actually do?