Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX91u-0007P7-Er for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Jan 2017 16:05:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cX91u-0000g9-1l for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Jan 2017 16:05:38 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cX90U-0006Zu-29 for pgsql-hackers@postgresql.org; Fri, 27 Jan 2017 16:04:10 +0000 Received: from tamriel.snowman.net ([72.66.115.51]) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cX90Q-0005LB-Q8 for pgsql-hackers@postgresql.org; Fri, 27 Jan 2017 16:04:08 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 7C4915F794; Fri, 27 Jan 2017 11:03:05 -0500 (EST) Date: Fri, 27 Jan 2017 11:03:05 -0500 From: Stephen Frost To: "David G. Johnston" Cc: Alvaro Herrera , D'Arcy Cain , "pgsql-hackers@postgresql.org" Subject: Re: One-shot expanded output in psql using \G Message-ID: <20170127160305.GH9812@tamriel.snowman.net> References: <8b8068d9-b218-06c6-6b98-8d7f1a365449@druid.net> <20170127152609.hsjdr5cetlxm47ke@alvherre.pgsql> <20170127153116.GF9812@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wqvBK6syLSinht8o" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-91-generic (x86_64) X-Uptime: 10:54:47 up 202 days, 17:19, 7 users, load average: 0.09, 0.11, 0.10 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -5.1 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --wqvBK6syLSinht8o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * David G. Johnston (david.g.johnston@gmail.com) wrote: > On Fri, Jan 27, 2017 at 8:31 AM, Stephen Frost wrote: >=20 > > * Alvaro Herrera (alvherre@2ndquadrant.com) wrote: > > > D'Arcy Cain wrote: > > > > > > > I am a pretty heavy user of psql but I don't think that that would = be > > so > > > > helpful. I assume you mean a new option, let's call it "\X" the > > causes the > > > > next query to be expanded. I type "\X" then a query. I realize th= at > > I made > > > > a mistake and have to redo the query so I have to type "\X" again. = If > > I > > > > forget then I have to run the query yet again. > > > > > > I think the suggestion is that \G replaces \g (which is the same thing > > > as the semicolon). So you would do this: > > > > > > SELECT * FROM table WHERE table_status =3D 1; % get a short list; nor= mal > > output > > > SELECT * FROM table WHERE table_id =3D 123 \G % drill down to one ID > > > > Uh, I figured it was more like \g, which just re-runs the last query.. > > As in, you'd do: > > > > table pg_proc; % blargh, I can't read it like this > > \G % ahh, much nicer > > >=20 > This information surprised me. It was unexpected that the last > successfully executed query remains in the query buffer until the next SQL > (and not meta) command is started. I was expecting that as soon as result > was returned to the screen the current query buffer would be cleared in > preparation for the next query. Well, I did get the impression that you weren't thinking about that, which is actually kind of surpirsing to me. Lots of things work on "the current query buffer", which is the last query (successful or not, to be clear..): \crosstabview \e \g \gexec \gset \p \w \watch It's not entirely clear to me why the docs sometimes say "current query buffer" and somtimes say "current query input buffer". > A sentence or two describing this behavior (or, more generally the query > buffer itself), probably placed at the end of the "Entering SQL Commands" > section, would help to make this common knowledge. Generally speaking, I agree that we should be more consistent in the docs, use one term where we mean one thing, and define that term somewhere. Thanks! Stephen --wqvBK6syLSinht8o Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJYi285AAoJEO1sijiDR2RVEYIP/1m/iapjGO9YJNR1WMXR1IDk fd/GnJtrRXL5BUF0gNv1yX2NTcH0Aee61bLulKZJClSGm35qzg4sgLf3edfBf6Pu l+s+KavkfroC6648ow/zVRIKNW7B4xYJ2m9+4t3iGXl1kcQb5p13O3ZCScNXQF0L 434HDtt7s23pSl/5a8jy3nyUD7nZhWGBtXviXLA36ivAQY9brJijBdY48CLATmqD E52nlTLgnc+/jJ+nbjtakyyO6u6JcjbFsG0wxMHwRels7ma5T9A4C2/lMjaUuPN9 ouK+E/3KAQb8/Ryzlujs/ngWbgZ2RZm1tjKrNzJLoWl7GXy1BKWPBp3asyc5E8mm gx3eXyV4Acnx9wB/LEwQW0o/2gSGy4wRjliEF9jXx9nSmp1KEecB9/2azWECgHUw OgTf80r3PNQW2G5XEaey3aTpQFFAMlOiJRJZNEek3BaRnxR1vFfopOOSSExYXpBU YptAI+Uoiy2N/BKqX5m8oPmOcRel1ii7dO9i/ZGuVRFdL4tZ2X3VWl39SZb4qkfK cvk8WP1gUUDTL9ctePr4BURUkCr4/NVHW6xmoobIz1a1d7gBKx3JjgFmliQQuju+ uMBSAtQtyYphOuIKN8FqM86WtByfxOPres9mkmh6ruCNNCf0l2pDwuA5IvfMvRl4 g1JoMX2LlBymyc43n3Ia =uBwL -----END PGP SIGNATURE----- --wqvBK6syLSinht8o--