Please clarify docs on user-defined settings for SET and RESET

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: jens(dot)troeger(at)light-speed(dot)de
Subject: Please clarify docs on user-defined settings for SET and RESET
Date: 2025-04-22 05:57:23
Message-ID: 174530144397.671.6924146579716093042@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/sql-set.html
Description:

Hello,

I'm reading through and playing with the SET and RESET docs and I'm somewhat
unclear about the behavior of arbitrary user settings that *don't* have a
session default.

For example a user defined setting is not available:

> psql -h localhost -U postgres
psql (14.17)
Type "help" for help.

postgres=# select current_setting('foo.bar');
ERROR: unrecognized configuration parameter "foo.bar"
postgres=# select current_setting('foo.bar', true);
current_setting
-----------------

(1 row)

postgres=# select current_setting('foo.bar', true) is null;
?column?
----------
t
(1 row)

And then I set it:

postgres=# set foo.bar = 'foo!bar';
SET
postgres=# select current_setting('foo.bar');
current_setting
-----------------
foo!bar
(1 row)

And then I reset it to… what?

postgres=# reset foo.bar;
RESET
postgres=# select current_setting('foo.bar');
current_setting
-----------------

(1 row)

postgres=# select current_setting('foo.bar') = '';
?column?
----------
t
(1 row)

It seems that the assumed/implied default value for settings that did not
exist for a session is the empty string? It would be useful to document that
behavior explicitly.

We can take this further:

> psql -h localhost -U postgres
psql (14.17)
Type "help" for help.

postgres=# select current_setting('foo.bar', true) is null;
?column?
----------
t
(1 row)

postgres=# select current_setting('foo.bar', true) = '';
?column?
----------

(1 row)

postgres=# reset foo.bar; -- Same as: SET foo.bar TO DEFAULT
RESET
postgres=# select current_setting('foo.bar', true) is null;
?column?
----------
f
(1 row)

postgres=# select current_setting('foo.bar', true) = '';
?column?
----------
t
(1 row)

Note how the value & type of the user setting changes, somewhat unexpectedly
(to me).

Furthermore, it seems impossible to actually *remove* such a user defined
settings completely, correct? That too, I miss stated explicitly in the
documentation.

Much thanks!
Jens

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message David G. Johnston 2025-04-22 13:47:42 Re: Please clarify docs on user-defined settings for SET and RESET
Previous Message Tom Lane 2025-04-19 19:25:48 Re: Dependency Tracking