psql and pset without any arguments

Lists: pgsql-hackers
From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: psql and pset without any arguments
Date: 2013-06-28 23:08:16
Message-ID: 51CE1760.3020208@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

I was looking at psql 8.3 documention about \pset options and saw that
there was the following note :

"Note: It is an error to call \pset without any arguments. In the
future this case might show the current status of all printing options."

I looked backward and forward to find that this note is present in all
versions since 7.1 up to 9.3, maybe it is time to add this little feature.

I've attached a patch to add the usage of the \pset command without any
arguments to displays current status of all printing options instead of
the error message. Here is a sample output:

(postgres(at)[local]:5494) [postgres] > \pset
Output format is aligned.
Border style is 2.
Expanded display is used automatically.
Null display is "NULL".
Field separator is "|".
Tuples only is off.
Title is unset.
Table attributes unset.
Line style is unicode.
Pager is used for long output.
Record separator is <newline>.
(postgres(at)[local]:5494) [postgres] >

To avoid redundant code I've added a new method printPsetInfo() so that
do_pset() and exec_command() will used the same output message, they are
all in src/bin/psql/command.c. For example:

(postgres(at)[local]:5494) [postgres] > \pset null 'NULL'
Null display is "NULL".
(postgres(at)[local]:5494) [postgres] >

The patch print all variables information from struct printTableOpt when
\pset is given without any arguments and also update documentation.

Let me know if there's any additional work to do on this basic patch or
something that I've omitted.

Best regards,

--
Gilles Darold
http://dalibo.com - http://dalibo.org

Attachment Content-Type Size
psql_pset-v1.patch text/x-patch 11.6 KB

From: Marc Mamin <M(dot)Mamin(at)intershop(dot)de>
To: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql and pset without any arguments
Date: 2013-06-29 11:02:00
Message-ID: B6F6FD62F2624C4C9916AC0175D56D880CE00E0E@jenmbs01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


>Von: pgsql-hackers-owner(at)postgresql(dot)org [pgsql-hackers-owner(at)postgresql(dot)org]&quot; im Auftrag von &quot;Gilles Darold [gilles(dot)darold(at)dalibo(dot)com]

>I was looking at psql 8.3 documention about \pset options and saw that
>there was the following note :
>
> "Note: It is an error to call \pset without any arguments. In the
>future this case might show the current status of all printing options."
>
>I looked backward and forward to find that this note is present in all
>versions since 7.1 up to 9.3, maybe it is time to add this little feature.
>
>I've attached a patch to add the usage of the \pset command without any
>arguments to displays current status of all printing options instead of
>the error message. Here is a sample output:
>
> (postgres(at)[local]:5494) [postgres] > \pset
> Output format is aligned.
> Border style is 2.
> Expanded display is used automatically.
> Null display is "NULL".
> Field separator is "|".
> Tuples only is off.
> Title is unset.
> Table attributes unset.
> Line style is unicode.
> Pager is used for long output.
> Record separator is <newline>.
> (postgres(at)[local]:5494) [postgres] >

Hello,
this is a nice additional feature.
As a user (not a hacker), I would prefer to see the real parameter name instead of the "display name".

e.g.
Border style is 2.
=>
border = 2

without this, the user would not know out of the fly which parameter to modify...

best regards,
Marc Mamin

>To avoid redundant code I've added a new method printPsetInfo() so that
>do_pset() and exec_command() will used the same output message, they are
>all in src/bin/psql/command.c. For example:
>
> (postgres(at)[local]:5494) [postgres] > \pset null 'NULL'
> Null display is "NULL".
> (postgres(at)[local]:5494) [postgres] >
>
>The patch print all variables information from struct printTableOpt when
>\pset is given without any arguments and also update documentation.
>
>Let me know if there's any additional work to do on this basic patch or
>something that I've omitted.
>
>Best regards,
>
>--
>Gilles Darold
>http://dalibo.com - http://dalibo.org


From: "Erik Rijkers" <er(at)xs4all(dot)nl>
To: "Gilles Darold" <gilles(dot)darold(at)dalibo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql and pset without any arguments
Date: 2013-06-29 11:55:28
Message-ID: c5f1270dffdf93c5c78750e87e332b35.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, June 29, 2013 01:08, Gilles Darold wrote:
> Here is a sample output:
>
> (postgres(at)[local]:5494) [postgres] > \pset
> Output format is aligned.
> Border style is 2.
> Expanded display is used automatically.
> Null display is "NULL".
> Field separator is "|".
> Tuples only is off.
> Title is unset.
> Table attributes unset.
> Line style is unicode.
> Pager is used for long output.
> Record separator is <newline>.
> (postgres(at)[local]:5494) [postgres] >
>

+1

This seems handy. Maybe it could be improved
a bit with the keyboard shortcuts prefixed, like so:

(postgres(at)[local]:5494) [postgres] > \pset
\a Output format is aligned.
\x Expanded display is used automatically.
\f Field separator is "|".
\t Tuples only is off.
\C Title is unset.
\T Table attributes unset.
Border style is 2.
Line style is unicode.
Null display is "NULL".
Pager is used for long output.
Record separator is <newline>.

So that it also serves a reminder on how to subsequently
change them

Thanks,

Erik Rijkers


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Erik Rijkers <er(at)xs4all(dot)nl>
Cc: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql and pset without any arguments
Date: 2013-06-29 12:26:43
Message-ID: CAFj8pRB6myNFhH9x=AfuBqa-dqf1WqD4h8E_nTFF4OACA1ip4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2013/6/29 Erik Rijkers <er(at)xs4all(dot)nl>:
> On Sat, June 29, 2013 01:08, Gilles Darold wrote:
>> Here is a sample output:
>>
>> (postgres(at)[local]:5494) [postgres] > \pset
>> Output format is aligned.
>> Border style is 2.
>> Expanded display is used automatically.
>> Null display is "NULL".
>> Field separator is "|".
>> Tuples only is off.
>> Title is unset.
>> Table attributes unset.
>> Line style is unicode.
>> Pager is used for long output.
>> Record separator is <newline>.
>> (postgres(at)[local]:5494) [postgres] >
>>
>
> +1
>
> This seems handy. Maybe it could be improved
> a bit with the keyboard shortcuts prefixed, like so:
>
> (postgres(at)[local]:5494) [postgres] > \pset
> \a Output format is aligned.
> \x Expanded display is used automatically.
> \f Field separator is "|".
> \t Tuples only is off.
> \C Title is unset.
> \T Table attributes unset.
> Border style is 2.
> Line style is unicode.
> Null display is "NULL".
> Pager is used for long output.
> Record separator is <newline>.
>

it is less readable - and same info you can get with \?

Regards

Pavel

>
> So that it also serves a reminder on how to subsequently
> change them
>
>
> Thanks,
>
> Erik Rijkers
>
>
>
>
>
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers


From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: Erik Rijkers <er(at)xs4all(dot)nl>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql and pset without any arguments
Date: 2013-06-29 15:05:22
Message-ID: 51CEF7B2.8070300@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Le 29/06/2013 13:55, Erik Rijkers a écrit :
> On Sat, June 29, 2013 01:08, Gilles Darold wrote:
>> Here is a sample output:
>>
>> (postgres(at)[local]:5494) [postgres] > \pset
>> Output format is aligned.
>> Border style is 2.
>> Expanded display is used automatically.
>> Null display is "NULL".
>> Field separator is "|".
>> Tuples only is off.
>> Title is unset.
>> Table attributes unset.
>> Line style is unicode.
>> Pager is used for long output.
>> Record separator is <newline>.
>> (postgres(at)[local]:5494) [postgres] >
>>
> +1
>
> This seems handy. Maybe it could be improved
> a bit with the keyboard shortcuts prefixed, like so:
>
> (postgres(at)[local]:5494) [postgres] > \pset
> \a Output format is aligned.
> \x Expanded display is used automatically.
> \f Field separator is "|".
> \t Tuples only is off.
> \C Title is unset.
> \T Table attributes unset.
> Border style is 2.
> Line style is unicode.
> Null display is "NULL".
> Pager is used for long output.
> Record separator is <newline>.
>
>
> So that it also serves a reminder on how to subsequently
> change them

My first though was to print something like \set output, but why not
reuse the original code/output when \pset is used ?

This second choice has three main advantages :

* Information shown is the same everywhere
* Backward compatibility with \pset output
* Avoid code redundancy

About shortcut I'm agree with Pavel that it is less readable and already
in the help, \? is the big reminder :-)

Regards,

--
Gilles Darold
http://dalibo.com - http://dalibo.org


From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: psql and pset without any arguments
Date: 2013-09-02 09:45:59
Message-ID: 52245E57.1090503@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Patch added to current open commitfest under the Client section with title:

"Call \pset without any arguments displays current status of all
printing options"

Status: Need review.

Let me know if it should not be there.

Regards,

Le 29/06/2013 01:08, Gilles Darold a écrit :
> Hi,
>
> I was looking at psql 8.3 documention about \pset options and saw that
> there was the following note :
>
> "Note: It is an error to call \pset without any arguments. In the
> future this case might show the current status of all printing options."
>
> I looked backward and forward to find that this note is present in all
> versions since 7.1 up to 9.3, maybe it is time to add this little feature.
>
> I've attached a patch to add the usage of the \pset command without any
> arguments to displays current status of all printing options instead of
> the error message. Here is a sample output:
>
> (postgres(at)[local]:5494) [postgres] > \pset
> Output format is aligned.
> Border style is 2.
> Expanded display is used automatically.
> Null display is "NULL".
> Field separator is "|".
> Tuples only is off.
> Title is unset.
> Table attributes unset.
> Line style is unicode.
> Pager is used for long output.
> Record separator is <newline>.
> (postgres(at)[local]:5494) [postgres] >
>
> To avoid redundant code I've added a new method printPsetInfo() so that
> do_pset() and exec_command() will used the same output message, they are
> all in src/bin/psql/command.c. For example:
>
> (postgres(at)[local]:5494) [postgres] > \pset null 'NULL'
> Null display is "NULL".
> (postgres(at)[local]:5494) [postgres] >
>
> The patch print all variables information from struct printTableOpt when
> \pset is given without any arguments and also update documentation.
>
> Let me know if there's any additional work to do on this basic patch or
> something that I've omitted.
>
> Best regards,
>
--
Gilles Darold
http://dalibo.com - http://dalibo.org