pg_cast

A system catalogue table which stores data type conversion paths

pg_cast is a system catalogue table which stores data type conversion paths, both built-in and user-defined.

psql

\dC provides a list of available casts.

Definition by PostgreSQL version

pg_cast (PostgreSQL 13)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null |
 castsource  | oid    |           | not null |
 casttarget  | oid    |           | not null |
 castfunc    | oid    |           | not null |
 castcontext | "char" |           | not null |
 castmethod  | "char" |           | not null |
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 12)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default
-------------+--------+-----------+----------+---------
 oid         | oid    |           | not null |
 castsource  | oid    |           | not null |
 casttarget  | oid    |           | not null |
 castfunc    | oid    |           | not null |
 castcontext | "char" |           | not null |
 castmethod  | "char" |           | not null |
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 11)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default
-------------+--------+-----------+----------+---------
 castsource  | oid    |           | not null |
 casttarget  | oid    |           | not null |
 castfunc    | oid    |           | not null |
 castcontext | "char" |           | not null |
 castmethod  | "char" |           | not null |
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 10)

              Table "pg_catalog.pg_cast"
   Column    |  Type  | Collation | Nullable | Default
-------------+--------+-----------+----------+---------
 castsource  | oid    |           | not null |
 casttarget  | oid    |           | not null |
 castfunc    | oid    |           | not null |
 castcontext | "char" |           | not null |
 castmethod  | "char" |           | not null |
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.6)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.5)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.4)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.3)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.2)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.1)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 9.0)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 8.4)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
 castmethod  | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 8.3)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

pg_cast (PostgreSQL 8.2)

    Table "pg_catalog.pg_cast"
   Column    |  Type  | Modifiers
-------------+--------+-----------
 castsource  | oid    | not null
 casttarget  | oid    | not null
 castfunc    | oid    | not null
 castcontext | "char" | not null
Indexes:
    "pg_cast_oid_index" UNIQUE, btree (oid)
    "pg_cast_source_target_index" UNIQUE, btree (castsource, casttarget)
    

Documentation: pg_cast

Change history

Examples

List all xml casts in psql:

postgres=# SELECT castsource::regtype, casttarget::regtype, castfunc::regproc,
                  castcontext, castmethod
             FROM pg_catalog.pg_cast
             WHERE castsource = 'xml'::regtype OR casttarget = 'xml'::regtype
          ORDER BY castsource::regtype::TEXT;

    castsource     |    casttarget     | castfunc | castcontext | castmethod 
-------------------+-------------------+----------+-------------+------------
 character         | xml               | xml      | e           | f
 character varying | xml               | xml      | e           | f
 text              | xml               | xml      | e           | f
 xml               | text              | -        | a           | b
 xml               | character varying | -        | a           | b
 xml               | character         | -        | a           | b
(6 rows)

postgres=# \dC xml
                               List of casts
    Source type    |    Target type    |      Function      |   Implicit?   
-------------------+-------------------+--------------------+---------------
 character         | xml               | xml                | no
 character varying | xml               | xml                | no
 text              | xml               | xml                | no
 xml               | character         | (binary coercible) | in assignment
 xml               | character varying | (binary coercible) | in assignment
 xml               | text              | (binary coercible) | in assignment
(6 rows)
  • PostgreSQL documentation: pg_cast

Categories

System catalogue