BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
Date
Msg-id 18544-60e74dd413b155f1@postgresql.org
Whole thread Raw
Responses Re: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
Re: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18544
Logged by:          Hayden Sim
Email address:      haydenwillsim@gmail.com
PostgreSQL version: 16.3
Operating system:   Docker Image (Ubuntu 24.04)
Description:

When a connection is initialised, calling `SELECT
current_setting('hasura.user', 't');`, as expected will return a NULL.
However if you call `SET "hasura.user" TO DEFAULT;`, this will actually
intitialise the value to an empty string. 
Note this only occurs when using a period in the config name.

This can be seen in the following logs:
```
psql (16.3 (Ubuntu 16.3-0ubuntu0.24.04.1))
Type "help" for help.

postgres=# \pset null [NULL]
Null display is "[NULL]".
postgres=# SELECT current_setting('server_version_num');
 current_setting
-----------------
 160003
(1 row)

postgres=# SELECT current_setting('foo');
ERROR:  unrecognized configuration parameter "foo"
postgres=# SET "foo" TO DEFAULT;
ERROR:  unrecognized configuration parameter "foo"
postgres=# SELECT current_setting('hasura.user');
ERROR:  unrecognized configuration parameter "hasura.user"
postgres=# SET "hasura.user" TO DEFAULT;
SET
postgres=# SELECT current_setting('hasura.user');
 current_setting
-----------------

(1 row)
```

This presents a huge problem, since even when called inside a transaction
and using `SET LOCAL`. The newly corrupted config value will affect the
session even after ROLLBACK. This can be seen here:
```
psql (16.3 (Ubuntu 16.3-0ubuntu0.24.04.1))
Type "help" for help.

postgres=# SELECT current_setting('server_version_num');
 current_setting
-----------------
 160003
(1 row)

postgres=# \pset null [NULL]
Null display is "[NULL]".
postgres=# SELECT current_setting('hasura.user', 't');
 current_setting
-----------------
 [NULL]
(1 row)

postgres=# BEGIN;
BEGIN
postgres=*# SELECT current_setting('hasura.user', 't');
 current_setting
-----------------
 [NULL]
(1 row)

postgres=*# SET LOCAL "hasura.user" TO DEFAULT;
SET
postgres=*# SELECT current_setting('hasura.user', 't');
 current_setting
-----------------

(1 row)

postgres=*# ROLLBACK;
ROLLBACK
postgres=# SELECT current_setting('hasura.user', 't');
 current_setting
-----------------

(1 row)

postgres=# SELECT current_setting('hasura.user');
 current_setting
-----------------

(1 row)
```

Thank you!
Hayden


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18543: Mistake in docs example
Next
From: Aleksander Alekseev
Date:
Subject: Re: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name