Обсуждение: psql expanded auto
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.
Вложения
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
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
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. +
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. +
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.
Вложения
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.
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
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
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
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.
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.
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.
Вложения
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.