Thread

  1. psql expanded auto

    Peter Eisentraut <peter_e@gmx.net> — 2010-12-17T22:12:50Z

    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.
    
    
  2. Re: psql expanded auto

    Chris Browne <cbbrowne@acm.org> — 2010-12-17T23:15:58Z

    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
    
    
  3. Re: psql expanded auto

    Itagaki Takahiro <itagaki.takahiro@gmail.com> — 2010-12-18T05:08:13Z

    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
    
    
  4. Re: psql expanded auto

    Bruce Momjian <bruce@momjian.us> — 2011-01-06T19:59:41Z

    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 is
    	wider than the screen width.
    	
    	    Consider using auto-expanded mode 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. +
    
    
  5. Re: psql expanded auto

    Bruce Momjian <bruce@momjian.us> — 2011-03-11T03:28:01Z

    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. +
    
    
  6. Re: psql expanded auto

    Peter Eisentraut <peter_e@gmx.net> — 2011-11-01T04:22:47Z

    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.
    
    
  7. Re: psql expanded auto

    Jan Lentfer <jan.lentfer@web.de> — 2011-11-01T09:21:25Z

    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.
    
    
    
  8. Re: psql expanded auto

    Dimitri Fontaine <dimitri@2ndquadrant.fr> — 2011-11-01T18:55:51Z

    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
    
    
  9. Re: psql expanded auto

    Noah Misch <noah@leadboat.com> — 2011-11-04T11:34:33Z

    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
    
    
  10. Re: psql expanded auto

    Peter Geoghegan <peter@2ndquadrant.com> — 2011-11-04T12:54:02Z

    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
    
    
  11. Re: psql expanded auto

    Peter Eisentraut <peter_e@gmx.net> — 2011-11-05T14:53:56Z

    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.
    
    
    
  12. Re: psql expanded auto

    Noah Misch <noah@leadboat.com> — 2011-11-05T16:26:27Z

    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.
    
    
  13. Re: psql expanded auto

    Peter Eisentraut <peter_e@gmx.net> — 2011-11-08T04:36:52Z

    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.
    
    
  14. Re: psql expanded auto

    Noah Misch <noah@leadboat.com> — 2011-11-10T23:53:13Z

    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.