October 14th, 2013 by depesz | Tags: , , , , | 5 comments »
Did it help? If yes - maybe you can help me?

On 3rd of October, Robert Haas committed patch:

psql: Make \pset without arguments show all settings.
 
Gilles Darold, reviewed by Pavel Stehule

I am sucker for psql enhancements. That's mostly because I am using psql all the time, so any bit of change has huge effect on me.

When you're in psql, you have at least three different “set" commands:

  • SET – changes settings on server side – so called GUCs
  • \pset – changes output formatting of results
  • \set – changes behavior of psql, or sets custom variables

For the first and second – we had a way to see all settings – “SHOW ALL" or “\set".

But there was no such way for \pset. Now, we have it (well, we'll have it, once 9.4 will get released).

How this works? That's simple:

$ \pset
Border style (border) is 1.
Target width (columns) unset.
Expanded display (expanded) is off.
Field separator (fieldsep) is "|".
Default footer (footer) is on.
Output format (format) is aligned.
Line style (linestyle) is ascii.
Null display (null) is "[null]".
Locale-adjusted numeric output (numericlocale) is off.
Pager (pager) is always used.
Record separator (recordsep) is <newline>.
Table attributes (tableattr) unset.
Title (title) unset.
Tuples only (tuples_only) is off.

Is it good? Well, it's definitely better than nothing. I would prefer to get the output like:

 Name          | Setting     | Description
---------------+-------------+--------------------------------
 border        | 1           | Border style
 columns       | unset       | Target width
 expanded      | off         | Expanded display
 fieldsep      | "|"         | Field separator
 footer        | on          | Default footer
 format        | aligned     | Output format
 linestyle     | ascii       | Line style
 null          | "[null]"    | Null display
 numericlocale | off         | Locale-adjusted numeric output
 pager         | always used | Pager
 recordsep     | <newline>   | Record separator
 tableattr     | unset       | Table attributes
 title         | unset       | Title
 tuples_only   | off         | Tuples only

But even as is, it's helpful. Thanks guys.

  1. 5 comments

  2. Oct 14, 2013

    All data are on client side, so we cannot to use a tabular infrastructure 🙁

  3. # Ross Reedstrom
    Oct 14, 2013

    +1 for discoverability! As to the tabular format, being client side just means you don’t get it for free w/ reusing the results tabular format.

  4. # Andreas
    Oct 14, 2013

    I have to agree on that the tabular output would be way better. The current output is barely readable.

  5. # Daniel
    Oct 30, 2013

    Why not follow \set and just return:
    border = 1
    columns = ‘unset’
    expanded = ‘off’

    Shell scripters will thank you!

    Or maybe even json
    {
    ‘border’: 1,
    ‘columns’: ‘unset’,
    ‘expanded’: ‘off’
    }

    Programmers will thank you!

  6. # GILLES
    Nov 1, 2013

    Those informations are psql specific settings. They are variables used to specifies printing options and they are defined at client side. The tabular structure may confuse users because this is the default infrastructure used to display settings or queries results from server side.

    I don’t see any interest for programmers to have those informations in a more structured manner. Also unset is not a value, it just says that the variable is not set.

    The name of the variable is just recalled into the message for convenience but this is the same message used when a printing option is set. Not sure that we also want a tabular infrastructure to display the result of the variable definition.

Sorry, comments for this post are disabled.