From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | Craig Ringer <craig(at)2ndquadrant(dot)com>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposal: session server side variables |
Date: | 2016-12-31 17:57:07 |
Message-ID: | CAFj8pRAWhhDkbq4k_aCOZeTNj0tg2bE370=J2_9dVSHfueWK+A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
> If you do not have expectations, then all is fine.
>
> (1) Having some kind of variable, especially in interactive mode, allows to
>>> manipulate previous results and reuse them later, without having to
>>> resort
>>> to repeated sub-queries or to retype non trivial values.
>>>
>>> Client side psql :-variables are untyped and unescaped, thus not very
>>> convenient for this purpose.
>>>
>>
>> You can currently (ab)use user defined GUCs for this.
>>
>
> How? It seems that I have missed the syntax to assign the result of a
> query to a user-defined guc, and to reuse it simply in a query.
>
>
postgres=# select set_config('myvar.text', (select
current_timestamp::text), false);
+-------------------------------+
| set_config |
+-------------------------------+
| 2016-12-31 18:56:42.894246+01 |
+-------------------------------+
(1 row)
Time: 0,448 ms
postgres=# select current_setting('myvar.text');
+-------------------------------+
| current_setting |
+-------------------------------+
| 2016-12-31 18:56:42.894246+01 |
+-------------------------------+
(1 row)
--
> Fabien.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-12-31 18:00:40 | Re: safer node casting |
Previous Message | Fabien COELHO | 2016-12-31 17:46:32 | Re: proposal: session server side variables |