CURRENT_SETTING
CURRENT_SETTING returns the current value of the specified configuration parameter.
This function is equivalent to the SHOW command.
Syntax
current_setting('parameter')
The following statement returns the current value of the specified session context variable.
current_setting('variable_name') current_setting('variable_name'[, error_if_undefined])
Arguments
- parameter
-
Parameter value to display. For a list of configuration parameters, see Configuration reference
- variable_name
-
The name of the variable to display. This must be a string constant for session context variables.
- error_if_undefined
-
(Optional) A boolean value that specifies the behavior if the variable name doesn't exist. When error_if_undefined is set to
TRUE
, which is the default, Amazon Redshift throws an error. When error_if_undefined is set toFALSE
, Amazon Redshift returnsNULL
. Amazon Redshift supports the error_if_undefined parameter only for session context variables. This can't be used when the input is a configuration parameter.
Return type
Returns a CHAR
or VARCHAR
string.
Examples
To return the current setting for the query_group
parameter, use the following example.
SELECT CURRENT_SETTING('query_group');
+-----------------+ | current_setting | +-----------------+ | unset | +-----------------+
To return the current setting for the variable app_context.user_id
, use the following example.
SELECT CURRENT_SETTING('app_context.user_id', FALSE);