agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: jens.troeger@light-speed.de
Subject: Please clarify docs on user-defined settings for SET and RESET
Date: Tue, 22 Apr 2025 05:57:23 +0000
Message-ID: <174530144397.671.6924146579716093042@wrigleys.postgresql.org> (raw)

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


view thread (2+ messages)  latest in thread

Message-ID: <174530144397.671.6924146579716093042@wrigleys.postgresql.org>
Permalink:  ../174530144397.671.6924146579716093042@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/174530144397.671.6924146579716093042@wrigleys.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-docs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, jens.troeger@light-speed.de
  Subject: Re: Please clarify docs on user-defined settings for SET and RESET
  In-Reply-To: <174530144397.671.6924146579716093042@wrigleys.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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox