Allow \pset to parse "on or off" for boolean values

Lists: pgsql-patches
From: "Chad Wagner" <chad(dot)wagner(at)gmail(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Allow \pset to parse "on or off" for boolean values
Date: 2007-02-18 18:00:58
Message-ID: 81961ff50702181000o2b15aed9g4098580a33ee73e9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

This is a TODO item:

o Allow psql \pset boolean variables to set to fixed values, rather
than toggle

Basically allows for:
test=# \pset expanded on
Expanded display is on.
test=# \pset footer off
Default footer is off.
test=# \pset footer
Default footer is on.
test=# \pset footer
Default footer is off.
test=# \pset footer
Default footer is on.

Basically the change is to check if value in do_pset is != NULL to call
ParseVariableBool to get a true/false and set the value directly, of the
second parameter is not provided then the "old logic" of toggling is
supported.

The pset variables that are adjusted are:
expanded
numericlocale
tuples_only
pager (supports on/off/always now)
footer

Attachment Content-Type Size
psql_pset_parsebool.diff application/octet-stream 8.8 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Chad Wagner <chad(dot)wagner(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Allow \pset to parse "on or off" for boolean values
Date: 2007-02-26 18:23:29
Message-ID: 200702261823.l1QINT322352@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

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

Chad Wagner wrote:
> This is a TODO item:
>
> o Allow psql \pset boolean variables to set to fixed values, rather
> than toggle
>
>
> Basically allows for:
> test=# \pset expanded on
> Expanded display is on.
> test=# \pset footer off
> Default footer is off.
> test=# \pset footer
> Default footer is on.
> test=# \pset footer
> Default footer is off.
> test=# \pset footer
> Default footer is on.
>
>
> Basically the change is to check if value in do_pset is != NULL to call
> ParseVariableBool to get a true/false and set the value directly, of the
> second parameter is not provided then the "old logic" of toggling is
> supported.
>
> The pset variables that are adjusted are:
> expanded
> numericlocale
> tuples_only
> pager (supports on/off/always now)
> footer

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Chad Wagner <chad(dot)wagner(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Allow \pset to parse "on or off" for boolean values
Date: 2007-03-03 17:23:49
Message-ID: 200703031723.l23HNnJ25253@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


I have applied a modified version of your patch, attached. You missed
the cases where \x and \t also need to support boolean constants. The
documentation lumped them all together, and they should be consistent
with the \pset behavior. You will see my change in the modified
do_pset() calls.

Thanks.

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

Chad Wagner wrote:
> This is a TODO item:
>
> o Allow psql \pset boolean variables to set to fixed values, rather
> than toggle
>
>
> Basically allows for:
> test=# \pset expanded on
> Expanded display is on.
> test=# \pset footer off
> Default footer is off.
> test=# \pset footer
> Default footer is on.
> test=# \pset footer
> Default footer is off.
> test=# \pset footer
> Default footer is on.
>
>
> Basically the change is to check if value in do_pset is != NULL to call
> ParseVariableBool to get a true/false and set the value directly, of the
> second parameter is not provided then the "old logic" of toggling is
> supported.
>
> The pset variables that are adjusted are:
> expanded
> numericlocale
> tuples_only
> pager (supports on/off/always now)
> footer

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 9.7 KB