Re: psql slash command '\G' - Mailing list pgsql-patches

From Ian Barwick
Subject Re: psql slash command '\G'
Date
Msg-id 200203260213.DAA06956@post.webmailer.de
Whole thread Raw
In response to Re: psql slash command '\G'  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: psql slash command '\G'  (Bernhard Herzog <bh@intevation.de>)
List 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



pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: psql slash command '\G'
Next
From: Bernhard Herzog
Date:
Subject: Re: psql slash command '\G'