PostgreSQL Source Code  git master
pg_cast.h
Go to the documentation of this file.
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-2018, 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  /* source datatype for cast */
34  Oid castsource BKI_LOOKUP(pg_type);
35 
36  /* destination datatype for cast */
37  Oid casttarget BKI_LOOKUP(pg_type);
38 
39  /* cast function; 0 = binary coercible */
40  Oid castfunc BKI_LOOKUP(pg_proc);
41 
42  /* contexts in which cast can be used */
43  char castcontext;
44 
45  /* cast method */
46  char castmethod;
48 
49 /* ----------------
50  * Form_pg_cast corresponds to a pointer to a tuple with
51  * the format of pg_cast relation.
52  * ----------------
53  */
55 
56 #ifdef EXPOSE_TO_CLIENT_CODE
57 
58 /*
59  * The allowable values for pg_cast.castcontext are specified by this enum.
60  * Since castcontext is stored as a "char", we use ASCII codes for human
61  * convenience in reading the table. Note that internally to the backend,
62  * these values are converted to the CoercionContext enum (see primnodes.h),
63  * which is defined to sort in a convenient order; the ASCII codes don't
64  * have to sort in any special order.
65  */
66 
67 typedef enum CoercionCodes
68 {
69  COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */
70  COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */
71  COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */
72 } CoercionCodes;
73 
74 /*
75  * The allowable values for pg_cast.castmethod are specified by this enum.
76  * Since castmethod is stored as a "char", we use ASCII codes for human
77  * convenience in reading the table.
78  */
79 typedef enum CoercionMethod
80 {
81  COERCION_METHOD_FUNCTION = 'f', /* use a function */
82  COERCION_METHOD_BINARY = 'b', /* types are binary-compatible */
83  COERCION_METHOD_INOUT = 'i' /* use input/output functions */
84 } CoercionMethod;
85 
86 #endif /* EXPOSE_TO_CLIENT_CODE */
87 
88 #endif /* PG_CAST_H */
unsigned int Oid
Definition: postgres_ext.h:31
CATALOG(pg_cast, 2605, CastRelationId)
Definition: pg_cast.h:31
FormData_pg_cast
Definition: pg_cast.h:47
FormData_pg_cast * Form_pg_cast
Definition: pg_cast.h:54
#define BKI_LOOKUP(catalog)
Definition: genbki.h:38