From: | Abelard Hoffman <abelardhoffman(at)gmail(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Testing truthiness of GUC variables? |
Date: | 2014-09-16 05:33:38 |
Message-ID: | CACEJHMja9rnvXbisV-3aL4gtH+rHe8TqcdTQOESqdQSkNGR+sA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Sep 15, 2014 at 5:39 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> Abelard Hoffman <abelardhoffman(at)gmail(dot)com> wrote:
>
> >> Boolean values can be written as on, off, true, false, yes, no,
> >> 1, 0 (all case-insensitive) or any unambiguous prefix of these.
> >
> > is there a built-in function I can call, given the value from
> > current_setting('myapp.audit'), that will test it using the same
> > logic?
>
> You can *set* a boolean setting with any of those, but that doesn't
> mean it will be stored as the string you used:
>
Thanks, but I meant for user defined variables:
test=# set myapp.foo = true;
SET
test=# show myapp.foo;
myapp.foo
-----------
true
(1 row)
test=# set myapp.foo = on;
SET
test=# show myapp.foo;
myapp.foo
-----------
on
(1 row)
I realize now though that all I need to do is cast it to bool:
test=# set myapp.foo = FA;
SET
test=# select current_setting('myapp.foo')::bool;
current_setting
-----------------
f
(1 row)
From | Date | Subject | |
---|---|---|---|
Next Message | Szymon Guz | 2014-09-16 07:30:03 | Re: Why isn't Java support part of Postgresql core? |
Previous Message | David G Johnston | 2014-09-16 01:18:41 | Re: pgcluu error |