Unexpected behaviour: it was documented to return the same value

2025-07-07 Thread PG Doc comments form
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/functions-admin.html
Description:

set_config ( setting_name text, new_value text, is_local boolean ) → text
Sets the parameter setting_name to new_value, and returns that value. If
is_local is true, the new value will only apply during the current
transaction. If you want the new value to apply for the rest of the current
session, use false instead. This function corresponds to the SQL command
SET.
set_config('log_statement_stats', 'off', false) → off
```
invoice=> select set_config( 'app.asdf', null, false ) is null;
 ?column?
--
 f
(1 row)
invoice=> select set_config( 'app.asdf', null, false ) = '';
 ?column?
--
 t
(1 row)
```
Expected: because I provided NULL value I expect to receive NULL as result
Actual: but function returns the empty string instead.
It would be better to follow documented behaviour, if it will not be
possible to fix it, please at least document that.
Thank you.


Re: Unexpected behaviour: it was documented to return the same value

2025-07-07 Thread David G. Johnston
On Mon, Jul 7, 2025 at 6:51 AM David G. Johnston 
wrote:

> On Saturday, July 5, 2025, PG Doc comments form 
> wrote:
>
>> The following documentation comment has been logged on the website:
>>
>> Page: https://www.postgresql.org/docs/17/functions-admin.html
>> Description:
>>
>
Yeah, this clarification just wasn't back-patched.

https://www.postgresql.org/docs/18/functions-admin.html#FUNCTIONS-ADMIN-SET

"set_config accepts the NULL value for new_value, but as settings cannot be
null, it is interpreted as a request to reset the setting to its default
value."

David J.


Re: Unexpected behaviour: it was documented to return the same value

2025-07-07 Thread David G. Johnston
On Saturday, July 5, 2025, PG Doc comments form 
wrote:

> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/17/functions-admin.html
> Description:
>
> set_config ( setting_name text, new_value text, is_local boolean ) → text
> Sets the parameter setting_name to new_value, and returns that value. If
> is_local is true, the new value will only apply during the current
> transaction. If you want the new value to apply for the rest of the current
> session, use false instead. This function corresponds to the SQL command
> SET.
> set_config('log_statement_stats', 'off', false) → off
> ```
> invoice=> select set_config( 'app.asdf', null, false ) is null;
>  ?column?
> --
>  f
> (1 row)
> invoice=> select set_config( 'app.asdf', null, false ) = '';
>  ?column?
> --
>  t
> (1 row)
> ```
> Expected: because I provided NULL value I expect to receive NULL as result
> Actual: but function returns the empty string instead.
> It would be better to follow documented behaviour, if it will not be
> possible to fix it, please at least document that.


There are pending patch(es?) in this area, I see to what extent this
specific wording is covered (not sure we are back-patching the new wording
either…).  The main point to remember is that a configuration setting can
never take on the null value.  All customized setting placeholders *that
exist* are text typed with a non-null value defaulting to the empty string.

David J.