4 The catalog pg_cast stores data type conversion paths, both built-in
7 It should be noted that pg_cast does not represent every type
8 conversion that the system knows how to perform; only those that cannot
9 be deduced from some generic rule. For example, casting between a
10 domain and its base type is not explicitly represented in pg_cast.
11 Another important exception is that “automatic I/O conversion casts”,
12 those performed using a data type's own I/O functions to convert to or
13 from text or other string types, are not explicitly represented in
16 Table 52.10. pg_cast Columns
26 castsource oid (references pg_type.oid)
28 OID of the source data type
30 casttarget oid (references pg_type.oid)
32 OID of the target data type
34 castfunc oid (references pg_proc.oid)
36 The OID of the function to use to perform this cast. Zero is stored if
37 the cast method doesn't require a function.
41 Indicates what contexts the cast can be invoked in. e means only as an
42 explicit cast (using CAST or :: syntax). a means implicitly in
43 assignment to a target column, as well as explicitly. i means
44 implicitly in expressions, as well as the other cases.
48 Indicates how the cast is performed. f means that the function
49 specified in the castfunc field is used. i means that the input/output
50 functions are used. b means that the types are binary-coercible, thus
51 no conversion is required.
53 The cast functions listed in pg_cast must always take the cast source
54 type as their first argument type, and return the cast destination type
55 as their result type. A cast function can have up to three arguments.
56 The second argument, if present, must be type integer; it receives the
57 type modifier associated with the destination type, or -1 if there is
58 none. The third argument, if present, must be type boolean; it receives
59 true if the cast is an explicit cast, false otherwise.
61 It is legitimate to create a pg_cast entry in which the source and
62 target types are the same, if the associated function takes more than
63 one argument. Such entries represent “length coercion functions” that
64 coerce values of the type to be legal for a particular type modifier
67 When a pg_cast entry has different source and target types and a
68 function that takes more than one argument, it represents converting
69 from one type to another and applying a length coercion in a single
70 step. When no such entry is available, coercion to a type that uses a
71 type modifier involves two steps, one to convert between data types and
72 a second to apply the modifier.