Updated on 2022-06-11 GMT+08:00

Configuration Settings Functions

Configuration setting functions are used for querying and modifying configuration parameters during running.

  • current_setting(setting_name)

    Description: Specifies the current setting.

    Return type: text

    Note: current_setting obtains the current setting of setting_name by query. It is equivalent to the SHOW statement. For example:

    1
    2
    3
    4
    5
    6
    SELECT current_setting('datestyle');
    
     current_setting
    -----------------
     ISO, MDY
    (1 row)
    
  • set_config(setting_name, new_value, is_local)

    Description: Sets the parameter and returns a new value.

    Return type: text

    Note: set_config sets the parameter setting_name to new_value. If is_local is true, the new value will only apply to the current transaction. If you want the new value to apply for the current session, use false instead. The function corresponds to the SET statement. For example:

    1
    2
    3
    4
    5
    6
    SELECT set_config('log_statement_stats', 'off', false);
    
     set_config
    ------------
     off
    (1 row)