pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Improve documentation for current_setting function
4+ messages / 3 participants
[nested] [flat]

* Improve documentation for current_setting function
@ 2019-02-20 12:59 PG Doc comments form <noreply@postgresql.org>
  2019-02-22 01:39 ` Re: Improve documentation for current_setting function Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Doc comments form @ 2019-02-20 12:59 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: kes-kes@yandex.ru

The following documentation comment has been logged on the website:

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

Hi.

Doc is not clear about what is returned if current_setting(
'app.not_existent', true ) is called.

Does it return empty string '', because return type is 'text' or it return
NULL, because 'app.not_existent' does not exist

Thank you.


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Improve documentation for current_setting function
  2019-02-20 12:59 Improve documentation for current_setting function PG Doc comments form <noreply@postgresql.org>
@ 2019-02-22 01:39 ` Bruce Momjian <bruce@momjian.us>
  2019-02-22 09:43   ` Re: Improve documentation for current_setting function Eugen Konkov <kes-kes@yandex.ru>
  0 siblings, 1 reply; 4+ messages in thread

From: Bruce Momjian @ 2019-02-22 01:39 UTC (permalink / raw)
  To: kes-kes@yandex.ru; pgsql-docs@lists.postgresql.org

On Wed, Feb 20, 2019 at 12:59:45PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/11/functions-admin.html
> Description:
> 
> Hi.
> 
> Doc is not clear about what is returned if current_setting(
> 'app.not_existent', true ) is called.
> 
> Does it return empty string '', because return type is 'text' or it return
> NULL, because 'app.not_existent' does not exist

Testing shows:

	SELECT current_setting('asdf', true);
	 current_setting
	-----------------
	
	
	\pset null (null)
	
	SELECT current_setting('asdf', true);
	 current_setting
	-----------------
-->	 (null)

How do you like the attached patch, which clarifies this?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +

Attachments:

current_setting.diff (text/x-diff, 823B) download diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index 86ff4e5..f638c6d *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** SELECT current_setting('datestyle'); *** 18722,18728 **** If there is no setting named <parameter>setting_name</parameter>, <function>current_setting</function> throws an error unless <parameter>missing_ok</parameter> is supplied and is ! <literal>true</literal>. </para> <para> --- 18722,18729 ---- If there is no setting named <parameter>setting_name</parameter>, <function>current_setting</function> throws an error unless <parameter>missing_ok</parameter> is supplied and is ! <literal>true</literal>, in which case a missing parameter returns ! NULL. </para> <para>
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: Improve documentation for current_setting function
  2019-02-20 12:59 Improve documentation for current_setting function PG Doc comments form <noreply@postgresql.org>
  2019-02-22 01:39 ` Re: Improve documentation for current_setting function Bruce Momjian <bruce@momjian.us>
@ 2019-02-22 09:43   ` Eugen Konkov <kes-kes@yandex.ru>
  2019-02-22 20:29     ` Re: Improve documentation for current_setting function Bruce Momjian <bruce@momjian.us>
  0 siblings, 1 reply; 4+ messages in thread

From: Eugen Konkov @ 2019-02-22 09:43 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; pgsql-docs@lists.postgresql.org

Hello Bruce,

> How do you like the attached patch, which clarifies this?

>>in which case a missing parameter returns
>>!     NULL.

not  always. It can be NULL or empty string. It depends if the current
session is new or after finished transaction which makes 'local' changes
to setting

Take into account these steps: https://www.postgresql.org/message-id/15646-0d3caee9f6266f60%40postgresql.org

From  my  user point of view. if the boot value before transaction was
NULL then after transaction it MUST stay NULL and not empty string.

This  will  be  consistent with that if I open new parallel session it
will return NULL.

Also I see NULL value (if setting was not defined) is useful.


Also this:
set_config( 'my.name', NULL )
must  set 'my.name' to NULL or must issue warning about NULL is turned
into empty string.

Personally  I  dislike  that  NULL  is converted to empty string. This
looks ugly. =(

-- 
Best regards,
Eugen Konkov





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Improve documentation for current_setting function
  2019-02-20 12:59 Improve documentation for current_setting function PG Doc comments form <noreply@postgresql.org>
  2019-02-22 01:39 ` Re: Improve documentation for current_setting function Bruce Momjian <bruce@momjian.us>
  2019-02-22 09:43   ` Re: Improve documentation for current_setting function Eugen Konkov <kes-kes@yandex.ru>
@ 2019-02-22 20:29     ` Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2019-02-22 20:29 UTC (permalink / raw)
  To: Eugen Konkov <kes-kes@yandex.ru>; +Cc: pgsql-docs@lists.postgresql.org

On Fri, Feb 22, 2019 at 11:43:54AM +0200, Eugen Konkov wrote:
> Hello Bruce,
> 
> > How do you like the attached patch, which clarifies this?
> 
> >>in which case a missing parameter returns
> >>!     NULL.
> 
> not  always. It can be NULL or empty string. It depends if the current
> session is new or after finished transaction which makes 'local' changes
> to setting
> 
> Take into account these steps: https://www.postgresql.org/message-id/15646-0d3caee9f6266f60%40postgresql.org

Yes, I saw that recent thread.

> From  my  user point of view. if the boot value before transaction was
> NULL then after transaction it MUST stay NULL and not empty string.
> 
> This  will  be  consistent with that if I open new parallel session it
> will return NULL.
> 
> Also I see NULL value (if setting was not defined) is useful.
> 
> 
> Also this:
> set_config( 'my.name', NULL )
> must  set 'my.name' to NULL or must issue warning about NULL is turned
> into empty string.
> 
> Personally  I  dislike  that  NULL  is converted to empty string. This
> looks ugly. =(

Understood.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-02-22 20:29 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20 12:59 Improve documentation for current_setting function PG Doc comments form <noreply@postgresql.org>
2019-02-22 01:39 ` Bruce Momjian <bruce@momjian.us>
2019-02-22 09:43   ` Eugen Konkov <kes-kes@yandex.ru>
2019-02-22 20:29     ` Bruce Momjian <bruce@momjian.us>

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