1 /*-------------------------------------------------------------------------
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: parse_coerce.h,v 1.6 1998/10/08 18:30:36 momjian Exp $
11 *-------------------------------------------------------------------------
13 #ifndef PARSE_COERCE_H
14 #define PARSE_COERCE_H
32 * Check for types which are in the core distribution.
33 * The built-in types can have more explicit support for type coersion, etc,
34 * since we know apriori how they should behave.
37 #define IS_BUILTIN_TYPE(t) \
40 || ((t) == BPCHAROID) \
41 || ((t) == VARCHAROID) \
45 || ((t) == FLOAT8OID) \
46 || ((t) == DATETIMEOID) \
47 || ((t) == TIMESTAMPOID) \
48 || ((t) == ABSTIMEOID) \
49 || ((t) == RELTIMEOID) \
53 || ((t) == POINTOID) \
58 || ((t) == POLYGONOID) \
59 || ((t) == CIRCLEOID))
62 /* IS_BINARY_COMPATIBLE()
63 * Check for types with the same underlying binary representation.
64 * This allows us to cheat and directly exchange values without
65 * going through the trouble of calling a conversion function.
67 #define IS_BINARY_COMPATIBLE(a,b) \
68 (((a) == BPCHAROID && (b) == TEXTOID) \
69 || ((a) == BPCHAROID && (b) == VARCHAROID) \
70 || ((a) == VARCHAROID && (b) == TEXTOID) \
71 || ((a) == VARCHAROID && (b) == BPCHAROID) \
72 || ((a) == TEXTOID && (b) == BPCHAROID) \
73 || ((a) == TEXTOID && (b) == VARCHAROID) \
74 || ((a) == OIDOID && (b) == INT4OID) \
75 || ((a) == INT4OID && (b) == TIMESTAMPOID) \
76 || ((a) == DATETIMEOID && (b) == FLOAT8OID) \
77 || ((a) == FLOAT8OID && (b) == DATETIMEOID) \
78 || ((a) == ABSTIMEOID && (b) == TIMESTAMPOID) \
79 || ((a) == ABSTIMEOID && (b) == INT4OID) \
80 || ((a) == TIMESTAMPOID && (b) == ABSTIMEOID) \
81 || ((a) == TIMESTAMPOID && (b) == INT4OID) \
82 || ((a) == INT4OID && (b) == OIDOID) \
83 || ((a) == INT4OID && (b) == ABSTIMEOID) \
84 || ((a) == INT4OID && (b) == TIMESTAMPOID) \
85 || ((a) == RELTIMEOID && (b) == INT4OID) \
86 || ((a) == INT4OID && (b) == RELTIMEOID))
89 * These types are the most general in each of the type categories.
91 #define IS_HIGHER_TYPE(t) \
93 || ((t) == FLOAT8OID) \
94 || ((t) == TIMESPANOID) \
95 || ((t) == DATETIMEOID) \
96 || ((t) == POLYGONOID))
99 * These types are the most general in each of the type categories.
100 * Since timespan and datetime overload so many functions, let's
101 * give datetime the preference.
102 * Since text is a generic string type let's leave it out too.
104 #define IS_HIGHEST_TYPE(t) \
105 (((t) == FLOAT8OID) \
106 || ((t) == DATETIMEOID) \
107 || ((t) == TIMESPANOID))
110 extern bool IsPreferredType(CATEGORY category, Oid type);
111 extern CATEGORY TypeCategory(Oid type);
113 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids);
114 extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId);
116 #endif /* PARSE_COERCE_H */