Обсуждение: psql expanded auto

Поиск
Список
Период
Сортировка

psql expanded auto

От
Peter Eisentraut
Дата:
I have often found myself wanting that psql automatically switch between
normal and \x mode depending on the width of the output.  Would others
find this useful?

Attached is a crude demo patch.  Enable with \pset expanded auto.


Вложения

Re: psql expanded auto

От
Chris Browne
Дата:
peter_e@gmx.net (Peter Eisentraut) writes:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?

I haven't tested the patch, but that *does* sound generally useful.
It's no fun trying to get one's eyes to visually line up output that
spans 3 lines...
-- 
select 'cbbrowne' || '@' || 'gmail.com';
http://linuxdatabases.info/info/nonrdbms.html
"Very little is known about the War of 1812 because the Americans lost
it."  -- Eric Nicol


Re: psql expanded auto

От
Itagaki Takahiro
Дата:
On Sat, Dec 18, 2010 at 07:12, Peter Eisentraut <peter_e@gmx.net> wrote:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?

+1

> Attached is a crude demo patch.  Enable with \pset expanded auto.

How about adding not only "auto" but also "on" and "off" as arguments
for \x?  If not specified, the default behavior will be still "toggle".

--
Itagaki Takahiro


Re: psql expanded auto

От
Bruce Momjian
Дата:
Peter Eisentraut wrote:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?
> 
> Attached is a crude demo patch.  Enable with \pset expanded auto.

It is a TODO:
Add auto-expanded mode so expanded output is used if the row length iswider than the screen width.    Consider using
auto-expandedmode for backslash commands like \df+. 
 

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: psql expanded auto

От
Bruce Momjian
Дата:
I have added a link to this on the TODO list:
Add "auto" expanded mode that outputs in expanded format if "wrapped"mode can't wrap the output to the screen width
*Re: psql wrapped format default for backslash-d commands    *
http://archives.postgresql.org/pgsql-hackers/2010-12/msg01638.php
 

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?
> 
> Attached is a crude demo patch.  Enable with \pset expanded auto.
> 

[ Attachment, skipping... ]

> 
> -- 
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +


Re: psql expanded auto

От
Peter Eisentraut
Дата:
I wrote:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?
>
> Attached is a crude demo patch.  Enable with \pset expanded auto.

Here is a finalized patch for this.  The first hunk of the patch is the
documentation change, so you can see there how it's supposed to work.
Let me know what you think.


Вложения

Re: psql expanded auto

От
Jan Lentfer
Дата:
I have not tried the patch (yet), but Informix'sl dbacess would do about 
the same - and it's something I really missed.

Jan
-- 
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.



Re: psql expanded auto

От
Dimitri Fontaine
Дата:
Peter Eisentraut <peter_e@gmx.net> writes:
> Here is a finalized patch for this.  The first hunk of the patch is the
> documentation change, so you can see there how it's supposed to work.
> Let me know what you think.

+1

Regards,
-- 
Dimitri Fontaine
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support


Re: psql expanded auto

От
Noah Misch
Дата:
On Tue, Nov 01, 2011 at 06:22:47AM +0200, Peter Eisentraut wrote:
> I wrote:
> > I have often found myself wanting that psql automatically switch between
> > normal and \x mode depending on the width of the output.  Would others
> > find this useful?
> > 
> > Attached is a crude demo patch.  Enable with \pset expanded auto.
> 
> Here is a finalized patch for this.  The first hunk of the patch is the
> documentation change, so you can see there how it's supposed to work.
> Let me know what you think.

+1.  I'm anticipating liking this enough to put it in ".psqlrc".


Perhaps this message should change to just "Target width is 120.", since it now
applies to more than just the wrapped format:

[local] test=# \pset columns 120
Target width for "wrapped" format is 120.

Similarly, psql documentation for "\pset columns" and the COLUMNS environment
variable should note expanded auto in addition to the wrapped format.


For "\pset format wrapped", we only use $COLUMNS when the output is a tty.  I'm
thinking it's best, although not terribly important, to apply the same rule to
this feature.

Thanks,
nm


Re: psql expanded auto

От
Peter Geoghegan
Дата:
On 17 December 2010 22:12, Peter Eisentraut <peter_e@gmx.net> wrote:
> I have often found myself wanting that psql automatically switch between
> normal and \x mode depending on the width of the output.  Would others
> find this useful?

+1

Sounds like a very good idea.


--
Peter Geoghegan       http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training and Services


Re: psql expanded auto

От
Peter Eisentraut
Дата:
On fre, 2011-11-04 at 07:34 -0400, Noah Misch wrote:
> For "\pset format wrapped", we only use $COLUMNS when the output is a
> tty.  I'm thinking it's best, although not terribly important, to
> apply the same rule to this feature.

I think it does work that way.  There is only one place where the
environment variable is queries, and it's used for both wrapped format
and expanded auto format.



Re: psql expanded auto

От
Noah Misch
Дата:
On Sat, Nov 05, 2011 at 04:53:56PM +0200, Peter Eisentraut wrote:
> On fre, 2011-11-04 at 07:34 -0400, Noah Misch wrote:
> > For "\pset format wrapped", we only use $COLUMNS when the output is a
> > tty.  I'm thinking it's best, although not terribly important, to
> > apply the same rule to this feature.
> 
> I think it does work that way.  There is only one place where the
> environment variable is queries, and it's used for both wrapped format
> and expanded auto format.

You're correct; given output to a non-tty and no use of \pset columns,
output_columns always becomes zero.  This makes wrapped format never wrap, but
it makes expanded auto mode always expand.  Would it be more consistent to never
expand when output_columns == 0?  That is, make these give the same output:

psql -X -P expanded=auto -c "select 'a' as a"
psql -X -P expanded=auto -c "select 'a' as a" | cat

I just noticed: the help text for \x in slashUsage() will also need an update.


Re: psql expanded auto

От
Peter Eisentraut
Дата:
On lör, 2011-11-05 at 12:26 -0400, Noah Misch wrote:
> On Sat, Nov 05, 2011 at 04:53:56PM +0200, Peter Eisentraut wrote:
> > On fre, 2011-11-04 at 07:34 -0400, Noah Misch wrote:
> > > For "\pset format wrapped", we only use $COLUMNS when the output is a
> > > tty.  I'm thinking it's best, although not terribly important, to
> > > apply the same rule to this feature.
> >
> > I think it does work that way.  There is only one place where the
> > environment variable is queries, and it's used for both wrapped format
> > and expanded auto format.
>
> You're correct; given output to a non-tty and no use of \pset columns,
> output_columns always becomes zero.  This makes wrapped format never wrap, but
> it makes expanded auto mode always expand.  Would it be more consistent to never
> expand when output_columns == 0?  That is, make these give the same output:
>
> psql -X -P expanded=auto -c "select 'a' as a"
> psql -X -P expanded=auto -c "select 'a' as a" | cat
>
> I just noticed: the help text for \x in slashUsage() will also need an update.

Here is an updated patch that addresses all the issues you pointed out.


Вложения

Re: psql expanded auto

От
Noah Misch
Дата:
On Tue, Nov 08, 2011 at 06:36:52AM +0200, Peter Eisentraut wrote:
> Here is an updated patch that addresses all the issues you pointed out.

Looks ready to me.  Thanks.