Skip site navigation (1) Skip section navigation (2)

Re: psql slash command '\G'

From: Ian Barwick <barwick(at)gmx(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>,<pgsql-patches(at)postgresql(dot)org>
Subject: Re: psql slash command '\G'
Date: 2002-03-26 01:15:11
Message-ID: 200203260213.DAA06956@post.webmailer.de (view raw or flat)
Thread:
Lists: pgsql-patches
Peter Eisentraut writes:
> Ian Barwick writes:
> >   The proposed slash command '\G' performs the same function as
> >   the existing command '\g' (send query buffer to server and optionally
> >   results to a file or pipe) but silently toggles expanded output mode
> >   immediately before and immediately after sending the query buffer to
> >   the backend.
>
> Sorry, this strikes me as a very random solution to a very particular
> problem.  Tomorrow someone comes with a patch to do an implicit \a during
> \g -- what letter does he take?

Point taken - the solution is for a one-off case which does not provide
a useful framework for similar extensions. Proposal and patch withdrawn
for further consideration. See following.

> You say \x\g\x is too much typing? 

Yup. 

> Propose a macro processor. 

Why? What do you envisage? What advantages would this, and presumably the fair
amount of additional and / or re-coding associated, have for me (or anyone 
else) compared to a more specific solution as suggested below?

> You don't like the messages that are printed? 

I am perfectly happy with the messages printed...

> Propose a switch to turn them off.

... except in the situation described, where they are superfluous. Manually
toggling messages as well as expanded output does not help me.

(psql already has a command line switch -q or --quiet; I presume it would not
be difficult to add a counterpart slash command. It is not a priority for
me but I would be happy to add it if it is generally seen to be useful.)

> Or you could make a "conditional \x" that automatically switches to \x
> format if there are more than a certain number of columns in the result
> set.

No. This is letting the application try and second guess my intentions, which 
is dancing paperclip territory.


How about optional extensions to \g along the lines of

  \g{(a|H)|t|x|...}

where the specified output modes are implictly and silently (or possibly
non-silently if the command line flag -q / --quiet is set...) toggled before
and after query execution? For example, \gx would perform in the same
way as the initially suggested \G; \ga would do similar for aligned / none
aligned output. 

This doesn't collide with any existing functionality (there is nothing 
stopping anyone typing say \x\H\g\H\x to get temporary expanded mode HTML 
output and four extra lines of superfluous messages), can be made available 
for all valid output setting combinations, and doesn't "pollute" the slash 
command name space (although it doesn't help the output of \? any ;-).

Thoughts?


Ian Barwick



In response to

Responses

pgsql-patches by date

Next:From: Nicolas BazinDate: 2002-03-26 06:21:31
Subject: build of 7.2.1 on SCO Openserver and Unixware 7.1.1
Previous:From: Peter EisentrautDate: 2002-03-25 02:27:24
Subject: Re: psql slash command '\G'

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group