1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * pg_cast.h |
4 | * definition of the "type casts" system catalog (pg_cast) |
5 | * |
6 | * As of Postgres 8.0, pg_cast describes not only type coercion functions |
7 | * but also length coercion functions. |
8 | * |
9 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
10 | * Portions Copyright (c) 1994, Regents of the University of California |
11 | * |
12 | * src/include/catalog/pg_cast.h |
13 | * |
14 | * NOTES |
15 | * The Catalog.pm module reads this file and derives schema |
16 | * information. |
17 | * |
18 | *------------------------------------------------------------------------- |
19 | */ |
20 | #ifndef PG_CAST_H |
21 | #define PG_CAST_H |
22 | |
23 | #include "catalog/genbki.h" |
24 | #include "catalog/pg_cast_d.h" |
25 | |
26 | /* ---------------- |
27 | * pg_cast definition. cpp turns this into |
28 | * typedef struct FormData_pg_cast |
29 | * ---------------- |
30 | */ |
31 | CATALOG(pg_cast,2605,CastRelationId) |
32 | { |
33 | Oid oid; /* oid */ |
34 | |
35 | /* source datatype for cast */ |
36 | Oid castsource BKI_LOOKUP(pg_type); |
37 | |
38 | /* destination datatype for cast */ |
39 | Oid casttarget BKI_LOOKUP(pg_type); |
40 | |
41 | /* cast function; 0 = binary coercible */ |
42 | Oid castfunc BKI_LOOKUP(pg_proc); |
43 | |
44 | /* contexts in which cast can be used */ |
45 | char castcontext; |
46 | |
47 | /* cast method */ |
48 | char castmethod; |
49 | } FormData_pg_cast; |
50 | |
51 | /* ---------------- |
52 | * Form_pg_cast corresponds to a pointer to a tuple with |
53 | * the format of pg_cast relation. |
54 | * ---------------- |
55 | */ |
56 | typedef FormData_pg_cast *Form_pg_cast; |
57 | |
58 | #ifdef EXPOSE_TO_CLIENT_CODE |
59 | |
60 | /* |
61 | * The allowable values for pg_cast.castcontext are specified by this enum. |
62 | * Since castcontext is stored as a "char", we use ASCII codes for human |
63 | * convenience in reading the table. Note that internally to the backend, |
64 | * these values are converted to the CoercionContext enum (see primnodes.h), |
65 | * which is defined to sort in a convenient order; the ASCII codes don't |
66 | * have to sort in any special order. |
67 | */ |
68 | |
69 | typedef enum CoercionCodes |
70 | { |
71 | COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */ |
72 | COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */ |
73 | COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */ |
74 | } CoercionCodes; |
75 | |
76 | /* |
77 | * The allowable values for pg_cast.castmethod are specified by this enum. |
78 | * Since castmethod is stored as a "char", we use ASCII codes for human |
79 | * convenience in reading the table. |
80 | */ |
81 | typedef enum CoercionMethod |
82 | { |
83 | COERCION_METHOD_FUNCTION = 'f', /* use a function */ |
84 | COERCION_METHOD_BINARY = 'b', /* types are binary-compatible */ |
85 | COERCION_METHOD_INOUT = 'i' /* use input/output functions */ |
86 | } CoercionMethod; |
87 | |
88 | #endif /* EXPOSE_TO_CLIENT_CODE */ |
89 | |
90 | #endif /* PG_CAST_H */ |
91 | |