pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: D'Arcy Cain <darcy@druid.net>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: One-shot expanded output in psql using \G
Date: Fri, 27 Jan 2017 11:03:05 -0500
Message-ID: <20170127160305.GH9812@tamriel.snowman.net> (raw)
In-Reply-To: <CAKFQuwY7s9RAFy-05KH=ngQy-RYPfcWSuJBESkheTF0VFaw4yA@mail.gmail.com>
References: <8b8068d9-b218-06c6-6b98-8d7f1a365449@druid.net>
	<20170127152609.hsjdr5cetlxm47ke@alvherre.pgsql>
	<20170127153116.GF9812@tamriel.snowman.net>
	<CAKFQuwY7s9RAFy-05KH=ngQy-RYPfcWSuJBESkheTF0VFaw4yA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

* David G. Johnston (david.g.johnston@gmail.com) wrote:
> On Fri, Jan 27, 2017 at 8:31 AM, Stephen Frost <sfrost@snowman.net> wrote:
> 
> > * 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 that
> > 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 = 1; % get a short list; normal
> > output
> > > SELECT * FROM table WHERE table_id = 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
> >
> 
> 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

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (45+ messages)  latest in thread

Message-ID: <20170127160305.GH9812@tamriel.snowman.net>
Permalink:  ../20170127160305.GH9812@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20170127160305.GH9812@tamriel.snowman.net

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: sfrost@snowman.net, david.g.johnston@gmail.com, alvherre@2ndquadrant.com, darcy@druid.net
  Subject: Re: One-shot expanded output in psql using \G
  In-Reply-To: <20170127160305.GH9812@tamriel.snowman.net>

* 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