1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +03:00

Add an optional missing_ok argument to SQL function current_setting().

This allows convenient checking for existence of a GUC from SQL, which is
particularly useful when dealing with custom variables.

David Christensen, reviewed by Jeevan Chalke
This commit is contained in:
Tom Lane
2015-07-02 16:40:55 -04:00
parent 7261172430
commit 10fb48d66d
9 changed files with 101 additions and 17 deletions

View File

@@ -16444,7 +16444,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
<indexterm>
<primary>current_setting</primary>
</indexterm>
<literal><function>current_setting(<parameter>setting_name</parameter>)</function></literal>
<literal><function>current_setting(<parameter>setting_name</parameter> [, <parameter>missing_ok</parameter> ])</function></literal>
</entry>
<entry><type>text</type></entry>
<entry>get current value of setting</entry>
@@ -16492,6 +16492,11 @@ SELECT current_setting('datestyle');
ISO, MDY
(1 row)
</programlisting>
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>