Contents
to_regcollation()
A function translating a collation name to an OID
to_regcollation()
is a system function for translating the name of a collation to its OID.
to_regcollation()
was added in PostgreSQL 13.
Usage
to_regcollation (text
) →regcollation
to_regcollation()
is equivalent to using the regcollation
object identifier type cast, but returns NULL
rather than raising an ERROR
if no matching collation is found.
The current search path is considered when evaluating the provided collation name.
The collation name is case-sensitive and will need to be quoted if it contains upper-case characters.
Change history
- PostgreSQL 16
- PostgreSQL 13
- added (commit a2b1faa0)
Examples
Basic usage example for to_regcollation()
:
postgres=# SELECT to_regcollation('pg_catalog."C"')::oid; to_regcollation ----------------- 950 (1 row)
NULL
is returned if the specified collation does not exist or is not found:
postgres=# SELECT to_regcollation('foo')::oid IS NULL; ?column? ---------- t (1 row)
If the specified collation is not visible in the current search path, it must be schema-qualified:
postgres=# SELECT to_regcollation('british_english'), to_regcollation('collations.british_english'); to_regcollation | to_regcollation -----------------+---------------------------- | collations.british_english (1 row)
References
- PostgreSQL documentation: System Catalog Information Functions
Categories
See also
regcollation, pg_collation_is_visible()