current_setting()
Returns the current value of a specified runtime parameter. This function corresponds to the SQL command SHOW
.
SHOW ALL
command to get the complete list of runtime parameters and corresponding descriptions.
has_table_privilege()
Checks if a user has access to a table in a specific way. You can identify the user by their name, their OID (pg_authid.oid), or by using public
to refer to the PUBLIC pseudo-role. If no argument is provided, it assumes the current user.
To specify the table, you can use its name or OID. If needed, you can schema-qualify the table name.
The desired access privilege type is specified as a text string. It must be one of the following values: SELECT
, INSERT
, UPDATE
, DELETE
, TRUNCATE
, REFERENCES
, or TRIGGER
. You can also add WITH GRANT OPTION
to test if the privilege is held with the grant option. If you want to check for multiple privilege types, you can list them separated by commas. The result will be true if any of the listed privileges is held. The case of the privilege string is not important, and you can have extra whitespace between privilege names, but not within them.
Syntax
Example
has_schema_privilege()
Checks if a user has access to a schema in a specific way. It has similar argument possibilities as the has_table_privilege
function.
The desired access privilege type should be a combination of CREATE
and/or USAGE
, such as “CREATE, USAGE”, or just a single privilege type like “CREATE” or “USAGE”.
Syntax
Example
has_any_column_privilege()
Checks if a user has access to any column of a table in a specific way. Currently, this function is identical to the has_table_privilege
function.
Syntax
Example
has_function_privilege()
Checks if a user has access to a function. If no user is provided, it assumes the current user.
Syntax
Example
rw_recovery_status()
Retrieves the current recovery status of the cluster. The return values can be one of STARTING
, RECOVERING
, or RUNNING
.
Syntax
Example
pg_is_in_recovery()
Checks if the PostgreSQL instance is currently in recovery mode.
Syntax
Example
set_config()
Syntax
setting_name
to new_value
, and returns that value. If is_local
is true
, the new value will only apply during the current transaction. If you want the new value to apply for the rest of the current session, use false
instead. This function corresponds to the SQL command SET.
Example
pg_indexes_size('table_name')
Returns the total size of all indexes associated with a particular table in bytes.
pg_table_size('table_name')
Returns the size of a table in bytes.
pg_stat_get_numscans('table_name')
Returns the total number of scans (sequential and index scans) performed on a specified table since the server was started.
This is a dummy function intended for compatibility with third-party tools. We keep it here only for reference and it will be eventually removed. Please do not use it in production environments or any important tasks.