CURRENT_SETTING

Return the current value of a named configuration parameter.

Category: miscReturns: STRINGDialect: PostgreSql

Syntax

CURRENT_SETTING(name)

Description

## Overview Returns the current value of the named configuration parameter as a string. Use this function to read session or transaction state previously set with SET_CONFIG, or to inspect engine settings such as `timezone` and `search_path`. ## Behavior - Raises an error when the parameter name does not exist. - Always returns a string representation, even for numeric or boolean settings. - Deterministic for the duration of the current session or transaction state. - Side effect free. ## Compatibility - PG-compat alias for `current_setting` function.

Parameters

NameTypeDescription
nameSpecifies the name of the configuration parameter to retrieve. Must be a parameter that the engine recognizes, or a custom namespaced parameter previously set with SET_CONFIG.

Examples

-- Read the current search path
SELECT CURRENT_SETTING('search_path');
-- Check the timezone
SELECT CURRENT_SETTING('timezone');
-- Set and read a custom parameter
SELECT SET_CONFIG('app.tenant_id', '42', false);
SELECT CURRENT_SETTING('app.tenant_id');  -- '42'
-- Use a session-level setting inside a predicate
SELECT * FROM crm.catalog.customers WHERE tenant_id = CURRENT_SETTING('app.tenant_id');

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →