On Thu, Apr 3, 2008 at 6:44 PM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:
> Bruce Momjian escribió:
>
>
> > It seems more helpful if there were \x option to use extended format
> > only when the output is too wide. TODO already has:
> >
> > o Add auto-expanded mode so expanded output is used if the row
> > length is wider than the screen width.
> >
> > Consider using auto-expanded mode for backslash commands like \df+.
>
> Some sort of "\x auto"? Sounds interesting ...
Hmm, seems doable.
While writing the \G patch I wanted to keep the changes to minimum, so it would
be clear what gets done. What I don't like about that patch is that
I've added in
struct _printTableOpt another bool "extend_once" after the "extend" bool.
I think there should be a format Enum, which would take values like NORMAL,
EXTENDED, and EXTENDED_ONCE -- but this would be a much more invasive patch.
Oh, and coincidentally its where AUTO format should go. :)
Now, assuming we want "\x auto" there are couple of things to discuss
before actually coding.
1. Adding "\x auto" changes how "\x" (and \pset). Currently we accept:\x - toggle between on and off\x off - turn
extendedformat off\x anything - turn extended format on.
if doing, auto we need to change it to something like,\x - toggle between on and off, if in "auto", toggle to "off"\x
on- extended format on\x off - extended format off\x auto - auto extended format\x anything else - extended format on
witha "depreciated" warning.
2. Do we want \G? I would say "yes". ;) But it should get discussed.
pgsql-general perhaps?
3. We should decide how each of the "commands" work in auto mode.
I think it should be something like: "if output is less or equal than
screen width -- use normal mode, else extended". I we have \g and \G,
they should be handled a bit differently in auto mode:";" -- perform automatic format adjustment"\g" -- force normal
mode(probably for file-output)"\G" -- force extended mode (probably for file-output).
I especially would like an opinion on this from you.
4. And as for using "\x" for the one-shot expanded output, I think it would
be possible to allow queries like: SELECT * FROM foo\x
...but I think fundamental problem with this approach is that it promotes
"\x" to be able to submit query. I don't think its a good idea.
Regards, Dawid