1 #----------------------------------------------------------------------
4 # Initial contents of the pg_cast system catalog.
6 # Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
7 # Portions Copyright (c) 1994, Regents of the University of California
9 # src/include/catalog/pg_cast.dat
11 #----------------------------------------------------------------------
15 # Note: this table has OIDs, but we don't bother to assign them manually,
16 # since nothing needs to know the specific OID of any built-in cast.
18 # Numeric category: implicit casts are allowed in the direction
19 # int2->int4->int8->numeric->float4->float8, while casts in the
20 # reverse direction are assignment-only.
21 { castsource
=> 'int8', casttarget
=> 'int2', castfunc
=> 'int2(int8)',
22 castcontext
=> 'a', castmethod
=> 'f' },
23 { castsource
=> 'int8', casttarget
=> 'int4', castfunc
=> 'int4(int8)',
24 castcontext
=> 'a', castmethod
=> 'f' },
25 { castsource
=> 'int8', casttarget
=> 'float4', castfunc
=> 'float4(int8)',
26 castcontext
=> 'i', castmethod
=> 'f' },
27 { castsource
=> 'int8', casttarget
=> 'float8', castfunc
=> 'float8(int8)',
28 castcontext
=> 'i', castmethod
=> 'f' },
29 { castsource
=> 'int8', casttarget
=> 'numeric', castfunc
=> 'numeric(int8)',
30 castcontext
=> 'i', castmethod
=> 'f' },
31 { castsource
=> 'int2', casttarget
=> 'int8', castfunc
=> 'int8(int2)',
32 castcontext
=> 'i', castmethod
=> 'f' },
33 { castsource
=> 'int2', casttarget
=> 'int4', castfunc
=> 'int4(int2)',
34 castcontext
=> 'i', castmethod
=> 'f' },
35 { castsource
=> 'int2', casttarget
=> 'float4', castfunc
=> 'float4(int2)',
36 castcontext
=> 'i', castmethod
=> 'f' },
37 { castsource
=> 'int2', casttarget
=> 'float8', castfunc
=> 'float8(int2)',
38 castcontext
=> 'i', castmethod
=> 'f' },
39 { castsource
=> 'int2', casttarget
=> 'numeric', castfunc
=> 'numeric(int2)',
40 castcontext
=> 'i', castmethod
=> 'f' },
41 { castsource
=> 'int4', casttarget
=> 'int8', castfunc
=> 'int8(int4)',
42 castcontext
=> 'i', castmethod
=> 'f' },
43 { castsource
=> 'int4', casttarget
=> 'int2', castfunc
=> 'int2(int4)',
44 castcontext
=> 'a', castmethod
=> 'f' },
45 { castsource
=> 'int4', casttarget
=> 'float4', castfunc
=> 'float4(int4)',
46 castcontext
=> 'i', castmethod
=> 'f' },
47 { castsource
=> 'int4', casttarget
=> 'float8', castfunc
=> 'float8(int4)',
48 castcontext
=> 'i', castmethod
=> 'f' },
49 { castsource
=> 'int4', casttarget
=> 'numeric', castfunc
=> 'numeric(int4)',
50 castcontext
=> 'i', castmethod
=> 'f' },
51 { castsource
=> 'float4', casttarget
=> 'int8', castfunc
=> 'int8(float4)',
52 castcontext
=> 'a', castmethod
=> 'f' },
53 { castsource
=> 'float4', casttarget
=> 'int2', castfunc
=> 'int2(float4)',
54 castcontext
=> 'a', castmethod
=> 'f' },
55 { castsource
=> 'float4', casttarget
=> 'int4', castfunc
=> 'int4(float4)',
56 castcontext
=> 'a', castmethod
=> 'f' },
57 { castsource
=> 'float4', casttarget
=> 'float8', castfunc
=> 'float8(float4)',
58 castcontext
=> 'i', castmethod
=> 'f' },
59 { castsource
=> 'float4', casttarget
=> 'numeric',
60 castfunc
=> 'numeric(float4)', castcontext
=> 'a', castmethod
=> 'f' },
61 { castsource
=> 'float8', casttarget
=> 'int8', castfunc
=> 'int8(float8)',
62 castcontext
=> 'a', castmethod
=> 'f' },
63 { castsource
=> 'float8', casttarget
=> 'int2', castfunc
=> 'int2(float8)',
64 castcontext
=> 'a', castmethod
=> 'f' },
65 { castsource
=> 'float8', casttarget
=> 'int4', castfunc
=> 'int4(float8)',
66 castcontext
=> 'a', castmethod
=> 'f' },
67 { castsource
=> 'float8', casttarget
=> 'float4', castfunc
=> 'float4(float8)',
68 castcontext
=> 'a', castmethod
=> 'f' },
69 { castsource
=> 'float8', casttarget
=> 'numeric',
70 castfunc
=> 'numeric(float8)', castcontext
=> 'a', castmethod
=> 'f' },
71 { castsource
=> 'numeric', casttarget
=> 'int8', castfunc
=> 'int8(numeric)',
72 castcontext
=> 'a', castmethod
=> 'f' },
73 { castsource
=> 'numeric', casttarget
=> 'int2', castfunc
=> 'int2(numeric)',
74 castcontext
=> 'a', castmethod
=> 'f' },
75 { castsource
=> 'numeric', casttarget
=> 'int4', castfunc
=> 'int4(numeric)',
76 castcontext
=> 'a', castmethod
=> 'f' },
77 { castsource
=> 'numeric', casttarget
=> 'float4',
78 castfunc
=> 'float4(numeric)', castcontext
=> 'i', castmethod
=> 'f' },
79 { castsource
=> 'numeric', casttarget
=> 'float8',
80 castfunc
=> 'float8(numeric)', castcontext
=> 'i', castmethod
=> 'f' },
81 { castsource
=> 'money', casttarget
=> 'numeric', castfunc
=> 'numeric(money)',
82 castcontext
=> 'a', castmethod
=> 'f' },
83 { castsource
=> 'numeric', casttarget
=> 'money', castfunc
=> 'money(numeric)',
84 castcontext
=> 'a', castmethod
=> 'f' },
85 { castsource
=> 'int4', casttarget
=> 'money', castfunc
=> 'money(int4)',
86 castcontext
=> 'a', castmethod
=> 'f' },
87 { castsource
=> 'int8', casttarget
=> 'money', castfunc
=> 'money(int8)',
88 castcontext
=> 'a', castmethod
=> 'f' },
90 # Allow explicit coercions between int4 and bool
91 { castsource
=> 'int4', casttarget
=> 'bool', castfunc
=> 'bool(int4)',
92 castcontext
=> 'e', castmethod
=> 'f' },
93 { castsource
=> 'bool', casttarget
=> 'int4', castfunc
=> 'int4(bool)',
94 castcontext
=> 'e', castmethod
=> 'f' },
96 # Allow explicit coercions between xid8 and xid
97 { castsource
=> 'xid8', casttarget
=> 'xid', castfunc
=> 'xid(xid8)',
98 castcontext
=> 'e', castmethod
=> 'f' },
100 # OID category: allow implicit conversion from any integral type (including
101 # int8, to support OID literals > 2G) to OID, as well as assignment coercion
102 # from OID to int4 or int8. Similarly for each OID-alias type. Also allow
103 # implicit coercions between OID and each OID-alias type, as well as
104 # regproc<->regprocedure and regoper<->regoperator. (Other coercions
105 # between alias types must pass through OID.) Lastly, there are implicit
106 # casts from text and varchar to regclass, which exist mainly to support
107 # legacy forms of nextval() and related functions.
108 { castsource
=> 'int8', casttarget
=> 'oid', castfunc
=> 'oid',
109 castcontext
=> 'i', castmethod
=> 'f' },
110 { castsource
=> 'int2', casttarget
=> 'oid', castfunc
=> 'int4(int2)',
111 castcontext
=> 'i', castmethod
=> 'f' },
112 { castsource
=> 'int4', casttarget
=> 'oid', castfunc
=> '0',
113 castcontext
=> 'i', castmethod
=> 'b' },
114 { castsource
=> 'oid', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
115 castcontext
=> 'a', castmethod
=> 'f' },
116 { castsource
=> 'oid', casttarget
=> 'int4', castfunc
=> '0',
117 castcontext
=> 'a', castmethod
=> 'b' },
118 { castsource
=> 'oid', casttarget
=> 'regproc', castfunc
=> '0',
119 castcontext
=> 'i', castmethod
=> 'b' },
120 { castsource
=> 'regproc', casttarget
=> 'oid', castfunc
=> '0',
121 castcontext
=> 'i', castmethod
=> 'b' },
122 { castsource
=> 'int8', casttarget
=> 'regproc', castfunc
=> 'oid',
123 castcontext
=> 'i', castmethod
=> 'f' },
124 { castsource
=> 'int2', casttarget
=> 'regproc', castfunc
=> 'int4(int2)',
125 castcontext
=> 'i', castmethod
=> 'f' },
126 { castsource
=> 'int4', casttarget
=> 'regproc', castfunc
=> '0',
127 castcontext
=> 'i', castmethod
=> 'b' },
128 { castsource
=> 'regproc', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
129 castcontext
=> 'a', castmethod
=> 'f' },
130 { castsource
=> 'regproc', casttarget
=> 'int4', castfunc
=> '0',
131 castcontext
=> 'a', castmethod
=> 'b' },
132 { castsource
=> 'regproc', casttarget
=> 'regprocedure', castfunc
=> '0',
133 castcontext
=> 'i', castmethod
=> 'b' },
134 { castsource
=> 'regprocedure', casttarget
=> 'regproc', castfunc
=> '0',
135 castcontext
=> 'i', castmethod
=> 'b' },
136 { castsource
=> 'oid', casttarget
=> 'regprocedure', castfunc
=> '0',
137 castcontext
=> 'i', castmethod
=> 'b' },
138 { castsource
=> 'regprocedure', casttarget
=> 'oid', castfunc
=> '0',
139 castcontext
=> 'i', castmethod
=> 'b' },
140 { castsource
=> 'int8', casttarget
=> 'regprocedure', castfunc
=> 'oid',
141 castcontext
=> 'i', castmethod
=> 'f' },
142 { castsource
=> 'int2', casttarget
=> 'regprocedure', castfunc
=> 'int4(int2)',
143 castcontext
=> 'i', castmethod
=> 'f' },
144 { castsource
=> 'int4', casttarget
=> 'regprocedure', castfunc
=> '0',
145 castcontext
=> 'i', castmethod
=> 'b' },
146 { castsource
=> 'regprocedure', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
147 castcontext
=> 'a', castmethod
=> 'f' },
148 { castsource
=> 'regprocedure', casttarget
=> 'int4', castfunc
=> '0',
149 castcontext
=> 'a', castmethod
=> 'b' },
150 { castsource
=> 'oid', casttarget
=> 'regoper', castfunc
=> '0',
151 castcontext
=> 'i', castmethod
=> 'b' },
152 { castsource
=> 'regoper', casttarget
=> 'oid', castfunc
=> '0',
153 castcontext
=> 'i', castmethod
=> 'b' },
154 { castsource
=> 'int8', casttarget
=> 'regoper', castfunc
=> 'oid',
155 castcontext
=> 'i', castmethod
=> 'f' },
156 { castsource
=> 'int2', casttarget
=> 'regoper', castfunc
=> 'int4(int2)',
157 castcontext
=> 'i', castmethod
=> 'f' },
158 { castsource
=> 'int4', casttarget
=> 'regoper', castfunc
=> '0',
159 castcontext
=> 'i', castmethod
=> 'b' },
160 { castsource
=> 'regoper', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
161 castcontext
=> 'a', castmethod
=> 'f' },
162 { castsource
=> 'regoper', casttarget
=> 'int4', castfunc
=> '0',
163 castcontext
=> 'a', castmethod
=> 'b' },
164 { castsource
=> 'regoper', casttarget
=> 'regoperator', castfunc
=> '0',
165 castcontext
=> 'i', castmethod
=> 'b' },
166 { castsource
=> 'regoperator', casttarget
=> 'regoper', castfunc
=> '0',
167 castcontext
=> 'i', castmethod
=> 'b' },
168 { castsource
=> 'oid', casttarget
=> 'regoperator', castfunc
=> '0',
169 castcontext
=> 'i', castmethod
=> 'b' },
170 { castsource
=> 'regoperator', casttarget
=> 'oid', castfunc
=> '0',
171 castcontext
=> 'i', castmethod
=> 'b' },
172 { castsource
=> 'int8', casttarget
=> 'regoperator', castfunc
=> 'oid',
173 castcontext
=> 'i', castmethod
=> 'f' },
174 { castsource
=> 'int2', casttarget
=> 'regoperator', castfunc
=> 'int4(int2)',
175 castcontext
=> 'i', castmethod
=> 'f' },
176 { castsource
=> 'int4', casttarget
=> 'regoperator', castfunc
=> '0',
177 castcontext
=> 'i', castmethod
=> 'b' },
178 { castsource
=> 'regoperator', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
179 castcontext
=> 'a', castmethod
=> 'f' },
180 { castsource
=> 'regoperator', casttarget
=> 'int4', castfunc
=> '0',
181 castcontext
=> 'a', castmethod
=> 'b' },
182 { castsource
=> 'oid', casttarget
=> 'regclass', castfunc
=> '0',
183 castcontext
=> 'i', castmethod
=> 'b' },
184 { castsource
=> 'regclass', casttarget
=> 'oid', castfunc
=> '0',
185 castcontext
=> 'i', castmethod
=> 'b' },
186 { castsource
=> 'int8', casttarget
=> 'regclass', castfunc
=> 'oid',
187 castcontext
=> 'i', castmethod
=> 'f' },
188 { castsource
=> 'int2', casttarget
=> 'regclass', castfunc
=> 'int4(int2)',
189 castcontext
=> 'i', castmethod
=> 'f' },
190 { castsource
=> 'int4', casttarget
=> 'regclass', castfunc
=> '0',
191 castcontext
=> 'i', castmethod
=> 'b' },
192 { castsource
=> 'regclass', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
193 castcontext
=> 'a', castmethod
=> 'f' },
194 { castsource
=> 'regclass', casttarget
=> 'int4', castfunc
=> '0',
195 castcontext
=> 'a', castmethod
=> 'b' },
196 { castsource
=> 'oid', casttarget
=> 'regcollation', castfunc
=> '0',
197 castcontext
=> 'i', castmethod
=> 'b' },
198 { castsource
=> 'regcollation', casttarget
=> 'oid', castfunc
=> '0',
199 castcontext
=> 'i', castmethod
=> 'b' },
200 { castsource
=> 'int8', casttarget
=> 'regcollation', castfunc
=> 'oid',
201 castcontext
=> 'i', castmethod
=> 'f' },
202 { castsource
=> 'int2', casttarget
=> 'regcollation', castfunc
=> 'int4(int2)',
203 castcontext
=> 'i', castmethod
=> 'f' },
204 { castsource
=> 'int4', casttarget
=> 'regcollation', castfunc
=> '0',
205 castcontext
=> 'i', castmethod
=> 'b' },
206 { castsource
=> 'regcollation', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
207 castcontext
=> 'a', castmethod
=> 'f' },
208 { castsource
=> 'regcollation', casttarget
=> 'int4', castfunc
=> '0',
209 castcontext
=> 'a', castmethod
=> 'b' },
210 { castsource
=> 'oid', casttarget
=> 'regtype', castfunc
=> '0',
211 castcontext
=> 'i', castmethod
=> 'b' },
212 { castsource
=> 'regtype', casttarget
=> 'oid', castfunc
=> '0',
213 castcontext
=> 'i', castmethod
=> 'b' },
214 { castsource
=> 'int8', casttarget
=> 'regtype', castfunc
=> 'oid',
215 castcontext
=> 'i', castmethod
=> 'f' },
216 { castsource
=> 'int2', casttarget
=> 'regtype', castfunc
=> 'int4(int2)',
217 castcontext
=> 'i', castmethod
=> 'f' },
218 { castsource
=> 'int4', casttarget
=> 'regtype', castfunc
=> '0',
219 castcontext
=> 'i', castmethod
=> 'b' },
220 { castsource
=> 'regtype', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
221 castcontext
=> 'a', castmethod
=> 'f' },
222 { castsource
=> 'regtype', casttarget
=> 'int4', castfunc
=> '0',
223 castcontext
=> 'a', castmethod
=> 'b' },
224 { castsource
=> 'oid', casttarget
=> 'regconfig', castfunc
=> '0',
225 castcontext
=> 'i', castmethod
=> 'b' },
226 { castsource
=> 'regconfig', casttarget
=> 'oid', castfunc
=> '0',
227 castcontext
=> 'i', castmethod
=> 'b' },
228 { castsource
=> 'int8', casttarget
=> 'regconfig', castfunc
=> 'oid',
229 castcontext
=> 'i', castmethod
=> 'f' },
230 { castsource
=> 'int2', casttarget
=> 'regconfig', castfunc
=> 'int4(int2)',
231 castcontext
=> 'i', castmethod
=> 'f' },
232 { castsource
=> 'int4', casttarget
=> 'regconfig', castfunc
=> '0',
233 castcontext
=> 'i', castmethod
=> 'b' },
234 { castsource
=> 'regconfig', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
235 castcontext
=> 'a', castmethod
=> 'f' },
236 { castsource
=> 'regconfig', casttarget
=> 'int4', castfunc
=> '0',
237 castcontext
=> 'a', castmethod
=> 'b' },
238 { castsource
=> 'oid', casttarget
=> 'regdictionary', castfunc
=> '0',
239 castcontext
=> 'i', castmethod
=> 'b' },
240 { castsource
=> 'regdictionary', casttarget
=> 'oid', castfunc
=> '0',
241 castcontext
=> 'i', castmethod
=> 'b' },
242 { castsource
=> 'int8', casttarget
=> 'regdictionary', castfunc
=> 'oid',
243 castcontext
=> 'i', castmethod
=> 'f' },
244 { castsource
=> 'int2', casttarget
=> 'regdictionary', castfunc
=> 'int4(int2)',
245 castcontext
=> 'i', castmethod
=> 'f' },
246 { castsource
=> 'int4', casttarget
=> 'regdictionary', castfunc
=> '0',
247 castcontext
=> 'i', castmethod
=> 'b' },
248 { castsource
=> 'regdictionary', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
249 castcontext
=> 'a', castmethod
=> 'f' },
250 { castsource
=> 'regdictionary', casttarget
=> 'int4', castfunc
=> '0',
251 castcontext
=> 'a', castmethod
=> 'b' },
252 { castsource
=> 'text', casttarget
=> 'regclass', castfunc
=> 'regclass',
253 castcontext
=> 'i', castmethod
=> 'f' },
254 { castsource
=> 'varchar', casttarget
=> 'regclass', castfunc
=> 'regclass',
255 castcontext
=> 'i', castmethod
=> 'f' },
256 { castsource
=> 'oid', casttarget
=> 'regrole', castfunc
=> '0',
257 castcontext
=> 'i', castmethod
=> 'b' },
258 { castsource
=> 'regrole', casttarget
=> 'oid', castfunc
=> '0',
259 castcontext
=> 'i', castmethod
=> 'b' },
260 { castsource
=> 'int8', casttarget
=> 'regrole', castfunc
=> 'oid',
261 castcontext
=> 'i', castmethod
=> 'f' },
262 { castsource
=> 'int2', casttarget
=> 'regrole', castfunc
=> 'int4(int2)',
263 castcontext
=> 'i', castmethod
=> 'f' },
264 { castsource
=> 'int4', casttarget
=> 'regrole', castfunc
=> '0',
265 castcontext
=> 'i', castmethod
=> 'b' },
266 { castsource
=> 'regrole', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
267 castcontext
=> 'a', castmethod
=> 'f' },
268 { castsource
=> 'regrole', casttarget
=> 'int4', castfunc
=> '0',
269 castcontext
=> 'a', castmethod
=> 'b' },
270 { castsource
=> 'oid', casttarget
=> 'regnamespace', castfunc
=> '0',
271 castcontext
=> 'i', castmethod
=> 'b' },
272 { castsource
=> 'regnamespace', casttarget
=> 'oid', castfunc
=> '0',
273 castcontext
=> 'i', castmethod
=> 'b' },
274 { castsource
=> 'int8', casttarget
=> 'regnamespace', castfunc
=> 'oid',
275 castcontext
=> 'i', castmethod
=> 'f' },
276 { castsource
=> 'int2', casttarget
=> 'regnamespace', castfunc
=> 'int4(int2)',
277 castcontext
=> 'i', castmethod
=> 'f' },
278 { castsource
=> 'int4', casttarget
=> 'regnamespace', castfunc
=> '0',
279 castcontext
=> 'i', castmethod
=> 'b' },
280 { castsource
=> 'regnamespace', casttarget
=> 'int8', castfunc
=> 'int8(oid)',
281 castcontext
=> 'a', castmethod
=> 'f' },
282 { castsource
=> 'regnamespace', casttarget
=> 'int4', castfunc
=> '0',
283 castcontext
=> 'a', castmethod
=> 'b' },
286 { castsource
=> 'text', casttarget
=> 'bpchar', castfunc
=> '0',
287 castcontext
=> 'i', castmethod
=> 'b' },
288 { castsource
=> 'text', casttarget
=> 'varchar', castfunc
=> '0',
289 castcontext
=> 'i', castmethod
=> 'b' },
290 { castsource
=> 'bpchar', casttarget
=> 'text', castfunc
=> 'text(bpchar)',
291 castcontext
=> 'i', castmethod
=> 'f' },
292 { castsource
=> 'bpchar', casttarget
=> 'varchar', castfunc
=> 'text(bpchar)',
293 castcontext
=> 'i', castmethod
=> 'f' },
294 { castsource
=> 'varchar', casttarget
=> 'text', castfunc
=> '0',
295 castcontext
=> 'i', castmethod
=> 'b' },
296 { castsource
=> 'varchar', casttarget
=> 'bpchar', castfunc
=> '0',
297 castcontext
=> 'i', castmethod
=> 'b' },
298 { castsource
=> 'char', casttarget
=> 'text', castfunc
=> 'text(char)',
299 castcontext
=> 'i', castmethod
=> 'f' },
300 { castsource
=> 'char', casttarget
=> 'bpchar', castfunc
=> 'bpchar(char)',
301 castcontext
=> 'a', castmethod
=> 'f' },
302 { castsource
=> 'char', casttarget
=> 'varchar', castfunc
=> 'text(char)',
303 castcontext
=> 'a', castmethod
=> 'f' },
304 { castsource
=> 'name', casttarget
=> 'text', castfunc
=> 'text(name)',
305 castcontext
=> 'i', castmethod
=> 'f' },
306 { castsource
=> 'name', casttarget
=> 'bpchar', castfunc
=> 'bpchar(name)',
307 castcontext
=> 'a', castmethod
=> 'f' },
308 { castsource
=> 'name', casttarget
=> 'varchar', castfunc
=> 'varchar(name)',
309 castcontext
=> 'a', castmethod
=> 'f' },
310 { castsource
=> 'text', casttarget
=> 'char', castfunc
=> 'char(text)',
311 castcontext
=> 'a', castmethod
=> 'f' },
312 { castsource
=> 'bpchar', casttarget
=> 'char', castfunc
=> 'char(text)',
313 castcontext
=> 'a', castmethod
=> 'f' },
314 { castsource
=> 'varchar', casttarget
=> 'char', castfunc
=> 'char(text)',
315 castcontext
=> 'a', castmethod
=> 'f' },
316 { castsource
=> 'text', casttarget
=> 'name', castfunc
=> 'name(text)',
317 castcontext
=> 'i', castmethod
=> 'f' },
318 { castsource
=> 'bpchar', casttarget
=> 'name', castfunc
=> 'name(bpchar)',
319 castcontext
=> 'i', castmethod
=> 'f' },
320 { castsource
=> 'varchar', casttarget
=> 'name', castfunc
=> 'name(varchar)',
321 castcontext
=> 'i', castmethod
=> 'f' },
323 # Allow explicit coercions between int4 and "char"
324 { castsource
=> 'char', casttarget
=> 'int4', castfunc
=> 'int4(char)',
325 castcontext
=> 'e', castmethod
=> 'f' },
326 { castsource
=> 'int4', casttarget
=> 'char', castfunc
=> 'char(int4)',
327 castcontext
=> 'e', castmethod
=> 'f' },
329 # pg_node_tree can be coerced to, but not from, text
330 { castsource
=> 'pg_node_tree', casttarget
=> 'text', castfunc
=> '0',
331 castcontext
=> 'i', castmethod
=> 'b' },
333 # pg_ndistinct can be coerced to, but not from, bytea and text
334 { castsource
=> 'pg_ndistinct', casttarget
=> 'bytea', castfunc
=> '0',
335 castcontext
=> 'i', castmethod
=> 'b' },
336 { castsource
=> 'pg_ndistinct', casttarget
=> 'text', castfunc
=> '0',
337 castcontext
=> 'i', castmethod
=> 'i' },
339 # pg_dependencies can be coerced to, but not from, bytea and text
340 { castsource
=> 'pg_dependencies', casttarget
=> 'bytea', castfunc
=> '0',
341 castcontext
=> 'i', castmethod
=> 'b' },
342 { castsource
=> 'pg_dependencies', casttarget
=> 'text', castfunc
=> '0',
343 castcontext
=> 'i', castmethod
=> 'i' },
345 # pg_mcv_list can be coerced to, but not from, bytea and text
346 { castsource
=> 'pg_mcv_list', casttarget
=> 'bytea', castfunc
=> '0',
347 castcontext
=> 'i', castmethod
=> 'b' },
348 { castsource
=> 'pg_mcv_list', casttarget
=> 'text', castfunc
=> '0',
349 castcontext
=> 'i', castmethod
=> 'i' },
352 { castsource
=> 'date', casttarget
=> 'timestamp',
353 castfunc
=> 'timestamp(date)', castcontext
=> 'i', castmethod
=> 'f' },
354 { castsource
=> 'date', casttarget
=> 'timestamptz',
355 castfunc
=> 'timestamptz(date)', castcontext
=> 'i', castmethod
=> 'f' },
356 { castsource
=> 'time', casttarget
=> 'interval', castfunc
=> 'interval(time)',
357 castcontext
=> 'i', castmethod
=> 'f' },
358 { castsource
=> 'time', casttarget
=> 'timetz', castfunc
=> 'timetz(time)',
359 castcontext
=> 'i', castmethod
=> 'f' },
360 { castsource
=> 'timestamp', casttarget
=> 'date',
361 castfunc
=> 'date(timestamp)', castcontext
=> 'a', castmethod
=> 'f' },
362 { castsource
=> 'timestamp', casttarget
=> 'time',
363 castfunc
=> 'time(timestamp)', castcontext
=> 'a', castmethod
=> 'f' },
364 { castsource
=> 'timestamp', casttarget
=> 'timestamptz',
365 castfunc
=> 'timestamptz(timestamp)', castcontext
=> 'i', castmethod
=> 'f' },
366 { castsource
=> 'timestamptz', casttarget
=> 'date',
367 castfunc
=> 'date(timestamptz)', castcontext
=> 'a', castmethod
=> 'f' },
368 { castsource
=> 'timestamptz', casttarget
=> 'time',
369 castfunc
=> 'time(timestamptz)', castcontext
=> 'a', castmethod
=> 'f' },
370 { castsource
=> 'timestamptz', casttarget
=> 'timestamp',
371 castfunc
=> 'timestamp(timestamptz)', castcontext
=> 'a', castmethod
=> 'f' },
372 { castsource
=> 'timestamptz', casttarget
=> 'timetz',
373 castfunc
=> 'timetz(timestamptz)', castcontext
=> 'a', castmethod
=> 'f' },
374 { castsource
=> 'interval', casttarget
=> 'time', castfunc
=> 'time(interval)',
375 castcontext
=> 'a', castmethod
=> 'f' },
376 { castsource
=> 'timetz', casttarget
=> 'time', castfunc
=> 'time(timetz)',
377 castcontext
=> 'a', castmethod
=> 'f' },
380 { castsource
=> 'point', casttarget
=> 'box', castfunc
=> 'box(point)',
381 castcontext
=> 'a', castmethod
=> 'f' },
382 { castsource
=> 'lseg', casttarget
=> 'point', castfunc
=> 'point(lseg)',
383 castcontext
=> 'e', castmethod
=> 'f' },
384 { castsource
=> 'path', casttarget
=> 'polygon', castfunc
=> 'polygon(path)',
385 castcontext
=> 'a', castmethod
=> 'f' },
386 { castsource
=> 'box', casttarget
=> 'point', castfunc
=> 'point(box)',
387 castcontext
=> 'e', castmethod
=> 'f' },
388 { castsource
=> 'box', casttarget
=> 'lseg', castfunc
=> 'lseg(box)',
389 castcontext
=> 'e', castmethod
=> 'f' },
390 { castsource
=> 'box', casttarget
=> 'polygon', castfunc
=> 'polygon(box)',
391 castcontext
=> 'a', castmethod
=> 'f' },
392 { castsource
=> 'box', casttarget
=> 'circle', castfunc
=> 'circle(box)',
393 castcontext
=> 'e', castmethod
=> 'f' },
394 { castsource
=> 'polygon', casttarget
=> 'point', castfunc
=> 'point(polygon)',
395 castcontext
=> 'e', castmethod
=> 'f' },
396 { castsource
=> 'polygon', casttarget
=> 'path', castfunc
=> 'path',
397 castcontext
=> 'a', castmethod
=> 'f' },
398 { castsource
=> 'polygon', casttarget
=> 'box', castfunc
=> 'box(polygon)',
399 castcontext
=> 'e', castmethod
=> 'f' },
400 { castsource
=> 'polygon', casttarget
=> 'circle',
401 castfunc
=> 'circle(polygon)', castcontext
=> 'e', castmethod
=> 'f' },
402 { castsource
=> 'circle', casttarget
=> 'point', castfunc
=> 'point(circle)',
403 castcontext
=> 'e', castmethod
=> 'f' },
404 { castsource
=> 'circle', casttarget
=> 'box', castfunc
=> 'box(circle)',
405 castcontext
=> 'e', castmethod
=> 'f' },
406 { castsource
=> 'circle', casttarget
=> 'polygon',
407 castfunc
=> 'polygon(circle)', castcontext
=> 'e', castmethod
=> 'f' },
409 # MAC address category
410 { castsource
=> 'macaddr', casttarget
=> 'macaddr8', castfunc
=> 'macaddr8',
411 castcontext
=> 'i', castmethod
=> 'f' },
412 { castsource
=> 'macaddr8', casttarget
=> 'macaddr', castfunc
=> 'macaddr',
413 castcontext
=> 'i', castmethod
=> 'f' },
416 { castsource
=> 'cidr', casttarget
=> 'inet', castfunc
=> '0',
417 castcontext
=> 'i', castmethod
=> 'b' },
418 { castsource
=> 'inet', casttarget
=> 'cidr', castfunc
=> 'cidr',
419 castcontext
=> 'a', castmethod
=> 'f' },
422 { castsource
=> 'bit', casttarget
=> 'varbit', castfunc
=> '0',
423 castcontext
=> 'i', castmethod
=> 'b' },
424 { castsource
=> 'varbit', casttarget
=> 'bit', castfunc
=> '0',
425 castcontext
=> 'i', castmethod
=> 'b' },
427 # Cross-category casts between bit and int4, int8
428 { castsource
=> 'int8', casttarget
=> 'bit', castfunc
=> 'bit(int8,int4)',
429 castcontext
=> 'e', castmethod
=> 'f' },
430 { castsource
=> 'int4', casttarget
=> 'bit', castfunc
=> 'bit(int4,int4)',
431 castcontext
=> 'e', castmethod
=> 'f' },
432 { castsource
=> 'bit', casttarget
=> 'int8', castfunc
=> 'int8(bit)',
433 castcontext
=> 'e', castmethod
=> 'f' },
434 { castsource
=> 'bit', casttarget
=> 'int4', castfunc
=> 'int4(bit)',
435 castcontext
=> 'e', castmethod
=> 'f' },
437 # Cross-category casts to and from TEXT
438 # We need entries here only for a few specialized cases where the behavior
439 # of the cast function differs from the datatype's I/O functions. Otherwise,
440 # parse_coerce.c will generate CoerceViaIO operations without any prompting.
441 # Note that the castcontext values specified here should be no stronger than
442 # parse_coerce.c's automatic casts ('a' to text, 'e' from text) else odd
443 # behavior will ensue when the automatic cast is applied instead of the
445 { castsource
=> 'cidr', casttarget
=> 'text', castfunc
=> 'text(inet)',
446 castcontext
=> 'a', castmethod
=> 'f' },
447 { castsource
=> 'inet', casttarget
=> 'text', castfunc
=> 'text(inet)',
448 castcontext
=> 'a', castmethod
=> 'f' },
449 { castsource
=> 'bool', casttarget
=> 'text', castfunc
=> 'text(bool)',
450 castcontext
=> 'a', castmethod
=> 'f' },
451 { castsource
=> 'xml', casttarget
=> 'text', castfunc
=> '0',
452 castcontext
=> 'a', castmethod
=> 'b' },
453 { castsource
=> 'text', casttarget
=> 'xml', castfunc
=> 'xml',
454 castcontext
=> 'e', castmethod
=> 'f' },
456 # Cross-category casts to and from VARCHAR
457 # We support all the same casts as for TEXT.
458 { castsource
=> 'cidr', casttarget
=> 'varchar', castfunc
=> 'text(inet)',
459 castcontext
=> 'a', castmethod
=> 'f' },
460 { castsource
=> 'inet', casttarget
=> 'varchar', castfunc
=> 'text(inet)',
461 castcontext
=> 'a', castmethod
=> 'f' },
462 { castsource
=> 'bool', casttarget
=> 'varchar', castfunc
=> 'text(bool)',
463 castcontext
=> 'a', castmethod
=> 'f' },
464 { castsource
=> 'xml', casttarget
=> 'varchar', castfunc
=> '0',
465 castcontext
=> 'a', castmethod
=> 'b' },
466 { castsource
=> 'varchar', casttarget
=> 'xml', castfunc
=> 'xml',
467 castcontext
=> 'e', castmethod
=> 'f' },
469 # Cross-category casts to and from BPCHAR
470 # We support all the same casts as for TEXT.
471 { castsource
=> 'cidr', casttarget
=> 'bpchar', castfunc
=> 'text(inet)',
472 castcontext
=> 'a', castmethod
=> 'f' },
473 { castsource
=> 'inet', casttarget
=> 'bpchar', castfunc
=> 'text(inet)',
474 castcontext
=> 'a', castmethod
=> 'f' },
475 { castsource
=> 'bool', casttarget
=> 'bpchar', castfunc
=> 'text(bool)',
476 castcontext
=> 'a', castmethod
=> 'f' },
477 { castsource
=> 'xml', casttarget
=> 'bpchar', castfunc
=> '0',
478 castcontext
=> 'a', castmethod
=> 'b' },
479 { castsource
=> 'bpchar', casttarget
=> 'xml', castfunc
=> 'xml',
480 castcontext
=> 'e', castmethod
=> 'f' },
482 # Length-coercion functions
483 { castsource
=> 'bpchar', casttarget
=> 'bpchar',
484 castfunc
=> 'bpchar(bpchar,int4,bool)', castcontext
=> 'i',
486 { castsource
=> 'varchar', casttarget
=> 'varchar',
487 castfunc
=> 'varchar(varchar,int4,bool)', castcontext
=> 'i',
489 { castsource
=> 'time', casttarget
=> 'time', castfunc
=> 'time(time,int4)',
490 castcontext
=> 'i', castmethod
=> 'f' },
491 { castsource
=> 'timestamp', casttarget
=> 'timestamp',
492 castfunc
=> 'timestamp(timestamp,int4)', castcontext
=> 'i',
494 { castsource
=> 'timestamptz', casttarget
=> 'timestamptz',
495 castfunc
=> 'timestamptz(timestamptz,int4)', castcontext
=> 'i',
497 { castsource
=> 'interval', casttarget
=> 'interval',
498 castfunc
=> 'interval(interval,int4)', castcontext
=> 'i',
500 { castsource
=> 'timetz', casttarget
=> 'timetz',
501 castfunc
=> 'timetz(timetz,int4)', castcontext
=> 'i', castmethod
=> 'f' },
502 { castsource
=> 'bit', casttarget
=> 'bit', castfunc
=> 'bit(bit,int4,bool)',
503 castcontext
=> 'i', castmethod
=> 'f' },
504 { castsource
=> 'varbit', casttarget
=> 'varbit', castfunc
=> 'varbit',
505 castcontext
=> 'i', castmethod
=> 'f' },
506 { castsource
=> 'numeric', casttarget
=> 'numeric',
507 castfunc
=> 'numeric(numeric,int4)', castcontext
=> 'i', castmethod
=> 'f' },
510 { castsource
=> 'json', casttarget
=> 'jsonb', castfunc
=> '0',
511 castcontext
=> 'a', castmethod
=> 'i' },
512 { castsource
=> 'jsonb', casttarget
=> 'json', castfunc
=> '0',
513 castcontext
=> 'a', castmethod
=> 'i' },
515 # jsonb to numeric and bool types
516 { castsource
=> 'jsonb', casttarget
=> 'bool', castfunc
=> 'bool(jsonb)',
517 castcontext
=> 'e', castmethod
=> 'f' },
518 { castsource
=> 'jsonb', casttarget
=> 'numeric', castfunc
=> 'numeric(jsonb)',
519 castcontext
=> 'e', castmethod
=> 'f' },
520 { castsource
=> 'jsonb', casttarget
=> 'int2', castfunc
=> 'int2(jsonb)',
521 castcontext
=> 'e', castmethod
=> 'f' },
522 { castsource
=> 'jsonb', casttarget
=> 'int4', castfunc
=> 'int4(jsonb)',
523 castcontext
=> 'e', castmethod
=> 'f' },
524 { castsource
=> 'jsonb', casttarget
=> 'int8', castfunc
=> 'int8(jsonb)',
525 castcontext
=> 'e', castmethod
=> 'f' },
526 { castsource
=> 'jsonb', casttarget
=> 'float4', castfunc
=> 'float4(jsonb)',
527 castcontext
=> 'e', castmethod
=> 'f' },
528 { castsource
=> 'jsonb', casttarget
=> 'float8', castfunc
=> 'float8(jsonb)',
529 castcontext
=> 'e', castmethod
=> 'f' },
531 # range to multirange
532 { castsource
=> 'int4range', casttarget
=> 'int4multirange',
533 castfunc
=> 'int4multirange(int4range)', castcontext
=> 'e',
535 { castsource
=> 'int8range', casttarget
=> 'int8multirange',
536 castfunc
=> 'int8multirange(int8range)', castcontext
=> 'e',
538 { castsource
=> 'numrange', casttarget
=> 'nummultirange',
539 castfunc
=> 'nummultirange(numrange)', castcontext
=> 'e',
541 { castsource
=> 'daterange', casttarget
=> 'datemultirange',
542 castfunc
=> 'datemultirange(daterange)', castcontext
=> 'e',
544 { castsource
=> 'tsrange', casttarget
=> 'tsmultirange',
545 castfunc
=> 'tsmultirange(tsrange)', castcontext
=> 'e', castmethod
=> 'f' },
546 { castsource
=> 'tstzrange', casttarget
=> 'tstzmultirange',
547 castfunc
=> 'tstzmultirange(tstzrange)', castcontext
=> 'e',