pg_cast — PostgreSQL system catalog

The PostgreSQL pg_cast system catalog: full column reference (names, types, descriptions), catalog relationships and version support.

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):

  • oid oid
    Row identifier
  • castsource oid references pg_type.oid
    OID of the source data type
  • casttarget oid references pg_type.oid
    OID of the target data type
  • castfunc oid references pg_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.
  • castcontext char
    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.
  • castmethod char
    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.