BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: haydenwillsim(at)gmail(dot)com
Subject: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
Date: 2024-07-18 09:34:25
Message-ID: 18544-60e74dd413b155f1@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 18544
Logged by: Hayden Sim
Email address: haydenwillsim(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Aleksander Alekseev 2024-07-18 11:46:41 Re: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
Previous Message Tom Lane 2024-07-17 19:03:06 Re: BUG #18543: Mistake in docs example