PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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-2026, 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/dependency.h"
24#include "catalog/genbki.h"
25#include "catalog/pg_cast_d.h" /* IWYU pragma: export */
26
27/* ----------------
28 * pg_cast definition. cpp turns this into
29 * typedef struct FormData_pg_cast
30 * ----------------
31 */
33
35{
36 Oid oid; /* oid */
37
38 /* source datatype for cast */
39 Oid castsource BKI_LOOKUP(pg_type);
40
41 /* destination datatype for cast */
42 Oid casttarget BKI_LOOKUP(pg_type);
43
44 /* cast function; 0 = binary coercible */
45 Oid castfunc BKI_LOOKUP_OPT(pg_proc);
46
47 /* contexts in which cast can be used */
48 char castcontext;
49
50 /* cast method */
51 char castmethod;
53
55
56/* ----------------
57 * Form_pg_cast corresponds to a pointer to a tuple with
58 * the format of pg_cast relation.
59 * ----------------
60 */
62
65
67
68#ifdef EXPOSE_TO_CLIENT_CODE
69
70/*
71 * The allowable values for pg_cast.castcontext are specified by this enum.
72 * Since castcontext is stored as a "char", we use ASCII codes for human
73 * convenience in reading the table. Note that internally to the backend,
74 * these values are converted to the CoercionContext enum (see primnodes.h),
75 * which is defined to sort in a convenient order; the ASCII codes don't
76 * have to sort in any special order.
77 */
78
79typedef enum CoercionCodes
80{
81 COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */
82 COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */
83 COERCION_CODE_EXPLICIT = 'e', /* explicit cast operation */
85
86/*
87 * The allowable values for pg_cast.castmethod are specified by this enum.
88 * Since castmethod is stored as a "char", we use ASCII codes for human
89 * convenience in reading the table.
90 */
91typedef enum CoercionMethod
92{
93 COERCION_METHOD_FUNCTION = 'f', /* use a function */
94 COERCION_METHOD_BINARY = 'b', /* types are binary-compatible */
95 COERCION_METHOD_INOUT = 'i', /* use input/output functions */
97
98#endif /* EXPOSE_TO_CLIENT_CODE */
99
100
103 Oid funcid,
106 char castcontext,
107 char castmethod,
108 DependencyType behavior);
109
110#endif /* PG_CAST_H */
DependencyType
Definition dependency.h:32
#define BEGIN_CATALOG_STRUCT
Definition genbki.h:37
#define DECLARE_UNIQUE_INDEX_PKEY(name, oid, oidmacro, tblname, decl)
Definition genbki.h:105
#define BKI_LOOKUP(catalog)
Definition genbki.h:65
#define END_CATALOG_STRUCT
Definition genbki.h:38
#define BKI_LOOKUP_OPT(catalog)
Definition genbki.h:66
#define DECLARE_UNIQUE_INDEX(name, oid, oidmacro, tblname, decl)
Definition genbki.h:104
#define CATALOG(name, oid, oidmacro)
Definition genbki.h:42
#define MAKE_SYSCACHE(name, idxname, nbuckets)
Definition genbki.h:146
ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, Oid incastid, Oid outcastid, char castcontext, char castmethod, DependencyType behavior)
Definition pg_cast.c:49
FormData_pg_cast
Definition pg_cast.h:52
END_CATALOG_STRUCT typedef FormData_pg_cast * Form_pg_cast
Definition pg_cast.h:61
unsigned int Oid
static int fb(int x)