Contents
pg_collation_is_visible()
A function for determining whether a collation is visible in the current search path
pg_collation_is_visible()
is a system function for determining whether a collation is visible in the current schema search path.
pg_collation_is_visible()
was added in PostgreSQL 9.1.
Usage
pg_collation_is_visible (collation
oid
) →boolean
The collation
parameter can be provided as a text value with the regcollation
OID alias containing the collation's name. In this case the name should be provided as a schema-qualified value (e.g. "someschema.somecollation
"), otherwise an ERROR
will be raised if the collation exists but is not visible in the current search path.
Change history
- PostgreSQL 9.1
- added (commit 414c5a2e)
Examples
Example usage for pg_collation_is_visible()
, assuming the following collation has been created:
postgres=# CREATE COLLATION collations.british_english (locale = 'en_GB.utf8'); CREATE COLLATION
dads
postgres=# SHOW search_path; search_path ----------------- "$user", public (1 row) postgres=# SELECT pg_collation_is_visible('collations.british_english'); ERROR: invalid input syntax for type oid: "collations.british_english" LINE 1: SELECT pg_collation_is_visible('collations.british_english')... postgres=# SET search_path TO public, collations; SET postgres=# SELECT pg_collation_is_visible('collations.british_english'::regcollation); pg_collation_is_visible ------------------------- t (1 row)
An ERROR
will be raised if the collation does not exist, or exists but is not schema-qualified and not in the current search path:
postgres=# SELECT pg_collation_is_visible('collations.foo'::regcollation); ERROR: collation "collations.foo" for encoding "UTF8" does not exist LINE 1: SELECT pg_collation_is_visible('collations.foo'::regcollatio... postgres=# SHOW search_path; search_path ----------------- "$user", public (1 row) postgres=# SELECT pg_collation_is_visible('british_english'::regcollation); ERROR: collation "british_english" for encoding "UTF8" does not exist LINE 1: SELECT pg_collation_is_visible('british_english'::regcollati...
References
- PostgreSQL documentation: pg_collation_is_visible()
Categories
See also
pg_function_is_visible(), pg_opclass_is_visible(), pg_operator_is_visible(), pg_opfamily_is_visible(), pg_table_is_visible(), pg_type_is_visible()