Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFi1g-0008Pr-3D for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Nov 2017 14:53:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFi1e-0006UA-V6 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Nov 2017 14:53:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eFi1e-0006Tz-QE for pgsql-bugs@lists.postgresql.org; Fri, 17 Nov 2017 14:53:50 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eFi1b-0002Tx-AM for pgsql-bugs@postgresql.org; Fri, 17 Nov 2017 14:53:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vAHEraaW021697; Fri, 17 Nov 2017 09:53:36 -0500 From: Tom Lane To: "David G. Johnston" cc: "xyh@nvn.xyz" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #14916: psql \r is invalid in PostgreSQL 10 In-reply-to: References: <20171117025734.1473.85669@wrigleys.postgresql.org> <25085.1510890187@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Thu, 16 Nov 2017 20:51:56 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21695.1510930416.1@sss.pgh.pa.us> Date: Fri, 17 Nov 2017 09:53:36 -0500 Message-ID: <21696.1510930416@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "David G. Johnston" writes: > On Thursday, November 16, 2017, Tom Lane > 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