pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: haydenwillsim@gmail.com
Subject: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
Date: Thu, 18 Jul 2024 09:34:25 +0000
Message-ID: <18544-60e74dd413b155f1@postgresql.org> (raw)

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



view thread (7+ messages)  latest in thread

Message-ID: <18544-60e74dd413b155f1@postgresql.org>
Permalink:  ../18544-60e74dd413b155f1@postgresql.org/
Also on:    postgresql.org/message-id/18544-60e74dd413b155f1@postgresql.org

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, haydenwillsim@gmail.com
  Subject: Re: BUG #18544: Setting local config_parameter to DEFAULT behaves unexpectedly when using period in config name
  In-Reply-To: <18544-60e74dd413b155f1@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