Summary
The catalog pg_cast stores data type conversion paths, both built-in and user-defined.
(Description quoted from the official PostgreSQL documentation.)
Columns
The pg_cast system catalog exposes the following columns (names, types and descriptions are taken verbatim from the PostgreSQL documentation):
oidoid
Row identifiercastsourceoidreferencespg_type.oid
OID of the source data typecasttargetoidreferencespg_type.oid
OID of the target data typecastfuncoidreferencespg_proc.oid
The OID of the function to use to perform this cast. Zero is stored if the cast method doesn’t require a function.castcontextchar
Indicates what contexts the cast can be invoked in. e means only as an explicit cast (using CAST or :: syntax). a means implicitly in assignment to a target column, as well as explicitly. i means implicitly in expressions, as well as the other cases.castmethodchar
Indicates how the cast is performed. f means that the function specified in the castfunc field is used. i means that the input/output functions are used. b means that the types are binary-coercible, thus no conversion is required.
Related catalogs
This object references the following other system catalogs:
Version applicability
Present in PostgreSQL 17, 18, 19 (verified against each release’s documentation). This is a long-standing system object that also exists in earlier PostgreSQL releases.
Related & references
Reference: PostgreSQL documentation — pg_cast.