Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / include / catalog / pg_cast.h
blob44e92b34826138b961e1b182dcf1fe3b72d2960b
1 /*-------------------------------------------------------------------------
3 * pg_cast.h
4 * definition of the system "type casts" relation (pg_cast)
5 * along with the relation's initial contents.
7 * As of Postgres 8.0, pg_cast describes not only type coercion functions
8 * but also length coercion functions.
11 * Copyright (c) 2002-2008, PostgreSQL Global Development Group
13 * $PostgreSQL$
15 * NOTES
16 * the genbki.sh script reads this file and generates .bki
17 * information from the DATA() statements.
19 *-------------------------------------------------------------------------
21 #ifndef PG_CAST_H
22 #define PG_CAST_H
24 #include "catalog/genbki.h"
26 /* ----------------
27 * pg_cast definition. cpp turns this into
28 * typedef struct FormData_pg_cast
29 * ----------------
31 #define CastRelationId 2605
33 CATALOG(pg_cast,2605)
35 Oid castsource; /* source datatype for cast */
36 Oid casttarget; /* destination datatype for cast */
37 Oid castfunc; /* cast function; 0 = binary coercible */
38 char castcontext; /* contexts in which cast can be used */
39 } FormData_pg_cast;
41 typedef FormData_pg_cast *Form_pg_cast;
44 * The allowable values for pg_cast.castcontext are specified by this enum.
45 * Since castcontext is stored as a "char", we use ASCII codes for human
46 * convenience in reading the table. Note that internally to the backend,
47 * these values are converted to the CoercionContext enum (see primnodes.h),
48 * which is defined to sort in a convenient order; the ASCII codes don't
49 * have to sort in any special order.
52 typedef enum CoercionCodes
54 COERCION_CODE_IMPLICIT = 'i', /* coercion in context of expression */
55 COERCION_CODE_ASSIGNMENT = 'a', /* coercion in context of assignment */
56 COERCION_CODE_EXPLICIT = 'e' /* explicit cast operation */
57 } CoercionCodes;
60 /* ----------------
61 * compiler constants for pg_cast
62 * ----------------
64 #define Natts_pg_cast 4
65 #define Anum_pg_cast_castsource 1
66 #define Anum_pg_cast_casttarget 2
67 #define Anum_pg_cast_castfunc 3
68 #define Anum_pg_cast_castcontext 4
70 /* ----------------
71 * initial contents of pg_cast
73 * Note: this table has OIDs, but we don't bother to assign them manually,
74 * since nothing needs to know the specific OID of any built-in cast.
75 * ----------------
79 * Numeric category: implicit casts are allowed in the direction
80 * int2->int4->int8->numeric->float4->float8, while casts in the
81 * reverse direction are assignment-only.
83 DATA(insert ( 20 21 714 a ));
84 DATA(insert ( 20 23 480 a ));
85 DATA(insert ( 20 700 652 i ));
86 DATA(insert ( 20 701 482 i ));
87 DATA(insert ( 20 1700 1781 i ));
88 DATA(insert ( 21 20 754 i ));
89 DATA(insert ( 21 23 313 i ));
90 DATA(insert ( 21 700 236 i ));
91 DATA(insert ( 21 701 235 i ));
92 DATA(insert ( 21 1700 1782 i ));
93 DATA(insert ( 23 20 481 i ));
94 DATA(insert ( 23 21 314 a ));
95 DATA(insert ( 23 700 318 i ));
96 DATA(insert ( 23 701 316 i ));
97 DATA(insert ( 23 1700 1740 i ));
98 DATA(insert ( 700 20 653 a ));
99 DATA(insert ( 700 21 238 a ));
100 DATA(insert ( 700 23 319 a ));
101 DATA(insert ( 700 701 311 i ));
102 DATA(insert ( 700 1700 1742 a ));
103 DATA(insert ( 701 20 483 a ));
104 DATA(insert ( 701 21 237 a ));
105 DATA(insert ( 701 23 317 a ));
106 DATA(insert ( 701 700 312 a ));
107 DATA(insert ( 701 1700 1743 a ));
108 DATA(insert ( 1700 20 1779 a ));
109 DATA(insert ( 1700 21 1783 a ));
110 DATA(insert ( 1700 23 1744 a ));
111 DATA(insert ( 1700 700 1745 i ));
112 DATA(insert ( 1700 701 1746 i ));
114 /* Allow explicit coercions between int4 and bool */
115 DATA(insert ( 23 16 2557 e ));
116 DATA(insert ( 16 23 2558 e ));
119 * OID category: allow implicit conversion from any integral type (including
120 * int8, to support OID literals > 2G) to OID, as well as assignment coercion
121 * from OID to int4 or int8. Similarly for each OID-alias type. Also allow
122 * implicit coercions between OID and each OID-alias type, as well as
123 * regproc<->regprocedure and regoper<->regoperator. (Other coercions
124 * between alias types must pass through OID.) Lastly, there are implicit
125 * casts from text and varchar to regclass, which exist mainly to support
126 * legacy forms of nextval() and related functions.
128 DATA(insert ( 20 26 1287 i ));
129 DATA(insert ( 21 26 313 i ));
130 DATA(insert ( 23 26 0 i ));
131 DATA(insert ( 26 20 1288 a ));
132 DATA(insert ( 26 23 0 a ));
133 DATA(insert ( 26 24 0 i ));
134 DATA(insert ( 24 26 0 i ));
135 DATA(insert ( 20 24 1287 i ));
136 DATA(insert ( 21 24 313 i ));
137 DATA(insert ( 23 24 0 i ));
138 DATA(insert ( 24 20 1288 a ));
139 DATA(insert ( 24 23 0 a ));
140 DATA(insert ( 24 2202 0 i ));
141 DATA(insert ( 2202 24 0 i ));
142 DATA(insert ( 26 2202 0 i ));
143 DATA(insert ( 2202 26 0 i ));
144 DATA(insert ( 20 2202 1287 i ));
145 DATA(insert ( 21 2202 313 i ));
146 DATA(insert ( 23 2202 0 i ));
147 DATA(insert ( 2202 20 1288 a ));
148 DATA(insert ( 2202 23 0 a ));
149 DATA(insert ( 26 2203 0 i ));
150 DATA(insert ( 2203 26 0 i ));
151 DATA(insert ( 20 2203 1287 i ));
152 DATA(insert ( 21 2203 313 i ));
153 DATA(insert ( 23 2203 0 i ));
154 DATA(insert ( 2203 20 1288 a ));
155 DATA(insert ( 2203 23 0 a ));
156 DATA(insert ( 2203 2204 0 i ));
157 DATA(insert ( 2204 2203 0 i ));
158 DATA(insert ( 26 2204 0 i ));
159 DATA(insert ( 2204 26 0 i ));
160 DATA(insert ( 20 2204 1287 i ));
161 DATA(insert ( 21 2204 313 i ));
162 DATA(insert ( 23 2204 0 i ));
163 DATA(insert ( 2204 20 1288 a ));
164 DATA(insert ( 2204 23 0 a ));
165 DATA(insert ( 26 2205 0 i ));
166 DATA(insert ( 2205 26 0 i ));
167 DATA(insert ( 20 2205 1287 i ));
168 DATA(insert ( 21 2205 313 i ));
169 DATA(insert ( 23 2205 0 i ));
170 DATA(insert ( 2205 20 1288 a ));
171 DATA(insert ( 2205 23 0 a ));
172 DATA(insert ( 26 2206 0 i ));
173 DATA(insert ( 2206 26 0 i ));
174 DATA(insert ( 20 2206 1287 i ));
175 DATA(insert ( 21 2206 313 i ));
176 DATA(insert ( 23 2206 0 i ));
177 DATA(insert ( 2206 20 1288 a ));
178 DATA(insert ( 2206 23 0 a ));
179 DATA(insert ( 26 3734 0 i ));
180 DATA(insert ( 3734 26 0 i ));
181 DATA(insert ( 20 3734 1287 i ));
182 DATA(insert ( 21 3734 313 i ));
183 DATA(insert ( 23 3734 0 i ));
184 DATA(insert ( 3734 20 1288 a ));
185 DATA(insert ( 3734 23 0 a ));
186 DATA(insert ( 26 3769 0 i ));
187 DATA(insert ( 3769 26 0 i ));
188 DATA(insert ( 20 3769 1287 i ));
189 DATA(insert ( 21 3769 313 i ));
190 DATA(insert ( 23 3769 0 i ));
191 DATA(insert ( 3769 20 1288 a ));
192 DATA(insert ( 3769 23 0 a ));
193 DATA(insert ( 25 2205 1079 i ));
194 DATA(insert ( 1043 2205 1079 i ));
197 * String category
199 DATA(insert ( 25 1042 0 i ));
200 DATA(insert ( 25 1043 0 i ));
201 DATA(insert ( 1042 25 401 i ));
202 DATA(insert ( 1042 1043 401 i ));
203 DATA(insert ( 1043 25 0 i ));
204 DATA(insert ( 1043 1042 0 i ));
205 DATA(insert ( 18 25 946 i ));
206 DATA(insert ( 18 1042 860 a ));
207 DATA(insert ( 18 1043 946 a ));
208 DATA(insert ( 19 25 406 i ));
209 DATA(insert ( 19 1042 408 a ));
210 DATA(insert ( 19 1043 1401 a ));
211 DATA(insert ( 25 18 944 a ));
212 DATA(insert ( 1042 18 944 a ));
213 DATA(insert ( 1043 18 944 a ));
214 DATA(insert ( 25 19 407 i ));
215 DATA(insert ( 1042 19 409 i ));
216 DATA(insert ( 1043 19 1400 i ));
218 /* Allow explicit coercions between int4 and "char" */
219 DATA(insert ( 18 23 77 e ));
220 DATA(insert ( 23 18 78 e ));
223 * Datetime category
225 DATA(insert ( 702 1082 1179 a ));
226 DATA(insert ( 702 1083 1364 a ));
227 DATA(insert ( 702 1114 2023 i ));
228 DATA(insert ( 702 1184 1173 i ));
229 DATA(insert ( 703 1186 1177 i ));
230 DATA(insert ( 1082 1114 2024 i ));
231 DATA(insert ( 1082 1184 1174 i ));
232 DATA(insert ( 1083 1186 1370 i ));
233 DATA(insert ( 1083 1266 2047 i ));
234 DATA(insert ( 1114 702 2030 a ));
235 DATA(insert ( 1114 1082 2029 a ));
236 DATA(insert ( 1114 1083 1316 a ));
237 DATA(insert ( 1114 1184 2028 i ));
238 DATA(insert ( 1184 702 1180 a ));
239 DATA(insert ( 1184 1082 1178 a ));
240 DATA(insert ( 1184 1083 2019 a ));
241 DATA(insert ( 1184 1114 2027 a ));
242 DATA(insert ( 1184 1266 1388 a ));
243 DATA(insert ( 1186 703 1194 a ));
244 DATA(insert ( 1186 1083 1419 a ));
245 DATA(insert ( 1266 1083 2046 a ));
246 /* Cross-category casts between int4 and abstime, reltime */
247 DATA(insert ( 23 702 0 e ));
248 DATA(insert ( 702 23 0 e ));
249 DATA(insert ( 23 703 0 e ));
250 DATA(insert ( 703 23 0 e ));
253 * Geometric category
255 DATA(insert ( 601 600 1532 e ));
256 DATA(insert ( 602 600 1533 e ));
257 DATA(insert ( 602 604 1449 a ));
258 DATA(insert ( 603 600 1534 e ));
259 DATA(insert ( 603 601 1541 e ));
260 DATA(insert ( 603 604 1448 a ));
261 DATA(insert ( 603 718 1479 e ));
262 DATA(insert ( 604 600 1540 e ));
263 DATA(insert ( 604 602 1447 a ));
264 DATA(insert ( 604 603 1446 e ));
265 DATA(insert ( 604 718 1474 e ));
266 DATA(insert ( 718 600 1416 e ));
267 DATA(insert ( 718 603 1480 e ));
268 DATA(insert ( 718 604 1544 e ));
271 * INET category
273 DATA(insert ( 650 869 0 i ));
274 DATA(insert ( 869 650 1715 a ));
277 * BitString category
279 DATA(insert ( 1560 1562 0 i ));
280 DATA(insert ( 1562 1560 0 i ));
281 /* Cross-category casts between bit and int4, int8 */
282 DATA(insert ( 20 1560 2075 e ));
283 DATA(insert ( 23 1560 1683 e ));
284 DATA(insert ( 1560 20 2076 e ));
285 DATA(insert ( 1560 23 1684 e ));
288 * Cross-category casts to and from TEXT
290 * We need entries here only for a few specialized cases where the behavior
291 * of the cast function differs from the datatype's I/O functions. Otherwise,
292 * parse_coerce.c will generate CoerceViaIO operations without any prompting.
294 * Note that the castcontext values specified here should be no stronger than
295 * parse_coerce.c's automatic casts ('a' to text, 'e' from text) else odd
296 * behavior will ensue when the automatic cast is applied instead of the
297 * pg_cast entry!
299 DATA(insert ( 650 25 730 a ));
300 DATA(insert ( 869 25 730 a ));
301 DATA(insert ( 16 25 2971 a ));
302 DATA(insert ( 142 25 0 a ));
303 DATA(insert ( 25 142 2896 e ));
306 * Cross-category casts to and from VARCHAR
308 * We support all the same casts as for TEXT.
310 DATA(insert ( 650 1043 730 a ));
311 DATA(insert ( 869 1043 730 a ));
312 DATA(insert ( 16 1043 2971 a ));
313 DATA(insert ( 142 1043 0 a ));
314 DATA(insert ( 1043 142 2896 e ));
317 * Cross-category casts to and from BPCHAR
319 * We support all the same casts as for TEXT.
321 DATA(insert ( 650 1042 730 a ));
322 DATA(insert ( 869 1042 730 a ));
323 DATA(insert ( 16 1042 2971 a ));
324 DATA(insert ( 142 1042 0 a ));
325 DATA(insert ( 1042 142 2896 e ));
328 * Length-coercion functions
330 DATA(insert ( 1042 1042 668 i ));
331 DATA(insert ( 1043 1043 669 i ));
332 DATA(insert ( 1083 1083 1968 i ));
333 DATA(insert ( 1114 1114 1961 i ));
334 DATA(insert ( 1184 1184 1967 i ));
335 DATA(insert ( 1186 1186 1200 i ));
336 DATA(insert ( 1266 1266 1969 i ));
337 DATA(insert ( 1560 1560 1685 i ));
338 DATA(insert ( 1562 1562 1687 i ));
339 DATA(insert ( 1700 1700 1703 i ));
341 #endif /* PG_CAST_H */