1 /*-------------------------------------------------------------------------
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: parse_coerce.h,v 1.9 1999/03/10 05:05:58 tgl Exp $
11 *-------------------------------------------------------------------------
13 #ifndef PARSE_COERCE_H
14 #define PARSE_COERCE_H
33 * Check for types which are in the core distribution.
34 * The built-in types can have more explicit support for type coersion, etc,
35 * since we know apriori how they should behave.
38 #define IS_BUILTIN_TYPE(t) \
41 || ((t) == BPCHAROID) \
42 || ((t) == VARCHAROID) \
46 || ((t) == FLOAT8OID) \
47 || ((t) == DATETIMEOID) \
48 || ((t) == TIMESTAMPOID) \
49 || ((t) == ABSTIMEOID) \
50 || ((t) == RELTIMEOID) \
54 || ((t) == POINTOID) \
59 || ((t) == POLYGONOID) \
60 || ((t) == CIRCLEOID) \
65 /* IS_BINARY_COMPATIBLE()
66 * Check for types with the same underlying binary representation.
67 * This allows us to cheat and directly exchange values without
68 * going through the trouble of calling a conversion function.
69 * Remove equivalencing of FLOAT8 and DATETIME. They really are not
70 * close enough in behavior, with the DATETIME reserved values
71 * and special formatting. - thomas 1999-01-24
73 #define IS_BINARY_COMPATIBLE(a,b) \
74 (((a) == BPCHAROID && (b) == TEXTOID) \
75 || ((a) == BPCHAROID && (b) == VARCHAROID) \
76 || ((a) == VARCHAROID && (b) == TEXTOID) \
77 || ((a) == VARCHAROID && (b) == BPCHAROID) \
78 || ((a) == TEXTOID && (b) == BPCHAROID) \
79 || ((a) == TEXTOID && (b) == VARCHAROID) \
80 || ((a) == OIDOID && (b) == INT4OID) \
81 || ((a) == OIDOID && (b) == REGPROCOID) \
82 || ((a) == INT4OID && (b) == OIDOID) \
83 || ((a) == INT4OID && (b) == REGPROCOID) \
84 || ((a) == REGPROCOID && (b) == OIDOID) \
85 || ((a) == REGPROCOID && (b) == INT4OID) \
86 || ((a) == ABSTIMEOID && (b) == TIMESTAMPOID) \
87 || ((a) == ABSTIMEOID && (b) == INT4OID) \
88 || ((a) == TIMESTAMPOID && (b) == ABSTIMEOID) \
89 || ((a) == TIMESTAMPOID && (b) == INT4OID) \
90 || ((a) == INT4OID && (b) == ABSTIMEOID) \
91 || ((a) == INT4OID && (b) == TIMESTAMPOID) \
92 || ((a) == RELTIMEOID && (b) == INT4OID) \
93 || ((a) == INT4OID && (b) == RELTIMEOID) \
94 || ((a) == INETOID && (b) == CIDROID) \
95 || ((a) == CIDROID && (b) == INETOID))
98 * These types are the most general in each of the type categories.
100 #define IS_HIGHER_TYPE(t) \
102 || ((t) == FLOAT8OID) \
103 || ((t) == TIMESPANOID) \
104 || ((t) == DATETIMEOID) \
105 || ((t) == POLYGONOID) \
106 || ((t) == INETOID) )
109 * These types are the most general in each of the type categories.
110 * Since timespan and datetime overload so many functions, let's
111 * give datetime the preference.
112 * Since text is a generic string type let's leave it out too.
114 #define IS_HIGHEST_TYPE(t) \
115 (((t) == FLOAT8OID) \
116 || ((t) == DATETIMEOID) \
117 || ((t) == TIMESPANOID))
120 extern bool IsPreferredType(CATEGORY category, Oid type);
121 extern CATEGORY TypeCategory(Oid type);
123 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids);
124 extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId);
126 #endif /* PARSE_COERCE_H */