From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: kes-kes@yandex.ru
Subject: BUG #15646: Inconsistent behavior for current_setting/set_config
Date: Wed, 20 Feb 2019 16:10:56 +0000
Message-ID: <15646-0d3caee9f6266f60@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15646
Logged by: Eugen Konkov
Email address: kes-kes@yandex.ru
PostgreSQL version: 10.4
Operating system: (Debian 10.4-2.pgdg90+1)
Description:
Hi.
[documentation](https://www.postgresql.org/docs/11/functions-admin.html#FUNCTIONS-ADMIN-SET)
describes that:
>set_config sets the parameter setting_name to new_value. If is_local is
true, the new value will only apply to the current transaction.
Thus if I rollback transaction original value should be available.
But current behavior returns empty string instead of NULL (the initial
value) after transaction is rolled back. When I restart session, NULL is
returned again as it is expected.
( I expect NULL just because 'my.app_period' is not configuration variable
is not defined yet. The documentation (link provided above) does not cover
what should be returned)
How to reproduce steps:
$ make dbshell
psql -h databases -p 5433 -U tucha tucha ||:
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 10.4 (Debian
10.4-2.pgdg90+1))
Type "help" for help.
We start a new session and check setting value before transaction. It is
NULL:
tucha=> select current_setting( 'my.app_period', true ) is null;
?column?
----------
t
(1 row)
We start transaction and change the setting value:
tucha=> begin;
BEGIN
tucha=> select set_config( 'my.app_period', 'some value', true );
set_config
------------
some value
(1 row)
We can see that value is changed. It is NOT NULL:
tucha=> select current_setting( 'my.app_period', true ) is null;
?column?
----------
f
(1 row)
tucha=> select current_setting( 'my.app_period', true );
current_setting
-----------------
some value
(1 row)
Here I finish transaction (it has no matter how: commit/rollback):
tucha=> rollback;
ROLLBACK
Here we can see that setting value is different from value that was before
transaction
tucha=> select current_setting( 'my.app_period', true ) is null;
?column?
----------
f
(1 row)
tucha=> \q
When I restart session I get NULL again (as expected):
kes@work ~/t $ make dbshell
psql -h databases -p 5433 -U tucha tucha ||:
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1), server 10.4 (Debian
10.4-2.pgdg90+1))
Type "help" for help.
tucha=> select current_setting( 'my.app_period', true ) is null;
?column?
----------
t
(1 row)
My database version:
tucha=> select version();
version
------------------------------------------------------------------------------------------
PostgreSQL 10.4 (Debian 10.4-2.pgdg90+1) on x86_64-pc-linux-gnu, compiled
by gcc (Debian
(1 row)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, kes-kes@yandex.ru
Subject: Re: BUG #15646: Inconsistent behavior for current_setting/set_config
In-Reply-To: <15646-0d3caee9f6266f60@postgresql.org>
References: <15646-0d3caee9f6266f60@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox