Re: Function `set_config` doesn't work in with query?

From: Zexuan Luo <spacewanderlzx(at)gmail(dot)com>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function `set_config` doesn't work in with query?
Date: 2019-01-04 10:57:08
Message-ID: CAADJU121Rc06LzaABDr_fF7FOyaJ8aNGfK3TVOQ94-e-yL9zNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you!

Something like
```
with t as (
select set_config('ns.blah', '1', false) as res
)
select res from t;
select current_setting('ns.blah');
```
works for me.

Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> 于2019年1月4日周五 下午6:27写道:
>
> >>>>> "Zexuan" == Zexuan Luo <spacewanderlzx(at)gmail(dot)com> writes:
>
> Zexuan> For instance:
> Zexuan> ```
> Zexuan> with t as (
> Zexuan> select set_config('blah', '1', false)
> Zexuan> )
> Zexuan> select current_setting('blah');
>
> A CTE containing a SELECT query which is not referenced anywhere will
> not be executed, even if it contains volatile functions. (CTEs
> containing INSERT/UPDATE/DELETE that are not referenced _will_ still be
> executed.)
>
> --
> Andrew (irc:RhodiumToad)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Güttler 2019-01-04 11:41:50 Use bytearray for blobs or not?
Previous Message Charles Clavadetscher 2019-01-04 10:56:22 RE: Potentially undocumented behaviour change in Postgres 11 concerning OLD record in an after insert trigger