↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / System Catalogs

pg_cast

The catalog pg_cast stores data type conversion paths, both built-in and user-defined. It should be noted that pg_cast does not represent every type conversion that the system knows how to perform; only those that cannot be deduced from some generic rule. For example, casting between a domain and its base type is not explicitly represented in pg_cast. Another important exception is that “automatic I/O conversion casts”, those performed using a data type's own I/O functions to convert to or from text or other string types, are not explicitly represented in pg_cast.

English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

kind
catalog
lang
en
measured attributes
true
metadata release
18.6
runtime columns
oid, castsource, casttarget, castfunc, castcontext, castmethod
runtime verified
false
source
english-manual

Definition PG 18

The catalog pg_cast stores data type conversion paths, both built-in and user-defined. It should be noted that pg_cast does not represent every type conversion that the system knows how to perform; only those that cannot be deduced from some generic rule. For example, casting between a domain and its base type is not explicitly represented in pg_cast. Another important exception is that “automatic I/O conversion casts”, those performed using a data type's own I/O functions to convert to or from text or other string types, are not explicitly represented in pg_cast.

Catalog columns

ColumnTypeNullabilityDescription
oidoidNot nullRow identifier
castsourceoidNot nullOID of the source data type
casttargetoidNot nullOID of the target data type
castfuncoidNot nullThe OID of the function to use to perform this cast. Zero is stored if the cast method doesn't require a function.
castcontextcharNot nullIndicates 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.
castmethodcharNot nullIndicates 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.

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · catalog-bilingual-repair:6cdc0be5f76031f6786cf342fbde4ab538ba69c592f71b9c1e87d86d5776de4a

Text language: en · catalog-bilingual-repair:6cdc0be5f76031f6786cf342fbde4ab538ba69c592f71b9c1e87d86d5776de4a