From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: xyh@nvn.xyz <xyh@nvn.xyz>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14916: psql \r is invalid in PostgreSQL 10
Date: Fri, 17 Nov 2017 09:53:36 -0500
Message-ID: <21696.1510930416@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwbtFAxDdGJAS+qEfUxHPF1Qho+CHkiL7H_ir2ov4r5hQw@mail.gmail.com>
References: <20171117025734.1473.85669@wrigleys.postgresql.org>
<25085.1510890187@sss.pgh.pa.us>
<CAKFQuwbtFAxDdGJAS+qEfUxHPF1Qho+CHkiL7H_ir2ov4r5hQw@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Thursday, November 16, 2017, Tom Lane <tgl@sss.pgh.pa.us
> <javascript:_e(%7B%7D,'cvml','tgl@sss.pgh.pa.us');>> wrote:
>> Please say why you think this is "invalid". I'm pretty sure
>> it was an intentional behavioral change (associated with the
>> rewrite to support \if). In any case it's not obviously worse
>> than before. \r is supposed to clear the current query input
>> string; it says nothing about deleting history.
> Actually, \r is behaving the same. The behavior of \p has been changed (at
> least per the docs) to print the last executed query if the current buffer
> is empty. This behavior change doesn't seem to be in the release notes.
No, it's always done that; the docs are just more clear about it now
(cf. commit 68dba97a4). This works the same in all versions of psql
back to perhaps 7.0:
regression=# select 2+2;
?column?
----------
4
(1 row)
regression=# \p
select 2+2;
and for that matter so does this:
regression=# select 2+2;
?column?
----------
4
(1 row)
regression=# \p
select 2+2;
regression=# select 2+1
regression-# \r
Query buffer reset (cleared).
regression=# \p
select 2+2;
regression=# \g
?column?
----------
4
(1 row)
What's different is that \r used to be willing to clear the previous-query
buffer if the current-query buffer was empty:
regression=# select 2+2;
?column?
----------
4
(1 row)
regression=# \p
select 2+2;
regression=# \r
Query buffer reset (cleared).
regression=# \p
Query buffer is empty.
regression=# \g
regression=#
That was surprising, undocumented, and (AFAICT) an accidental result of
some weird coding rather than anything the code actually intended to do.
So we changed it:
regression=# select 2+2;
?column?
----------
4
(1 row)
regression=# \r
Query buffer reset (cleared).
regression=# \p
select 2+2;
regression=# \g
?column?
----------
4
(1 row)
There was nothing to document since the docs never explained the old
behavior anyway. Maybe there should have been a release note entry
about it, but I don't see how such an entry could be much shorter
than what I just wrote, and it didn't seem worth it.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, xyh@nvn.xyz
Subject: Re: BUG #14916: psql \r is invalid in PostgreSQL 10
In-Reply-To: <21696.1510930416@sss.pgh.pa.us>
References: <20171117025734.1473.85669@wrigleys.postgresql.org> <25085.1510890187@sss.pgh.pa.us> <CAKFQuwbtFAxDdGJAS+qEfUxHPF1Qho+CHkiL7H_ir2ov4r5hQw@mail.gmail.com> <21696.1510930416@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox