Re: Improve documentation for current_setting function

Bruce Momjian <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.documentation
Message-ID <[email protected]>
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  <[email protected]>        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 +
current_setting.diff (text/x-diff, 824 B)
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>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.