]> granicus.if.org Git - postgresql/blob - src/include/parser/parse_coerce.h
Code review for DOMAIN patch.
[postgresql] / src / include / parser / parse_coerce.h
1 /*-------------------------------------------------------------------------
2  *
3  * parse_coerce.h
4  *
5  *      Routines for type coercion.
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: parse_coerce.h,v 1.41 2002/03/20 19:45:07 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PARSE_COERCE_H
15 #define PARSE_COERCE_H
16
17 #include "catalog/pg_type.h"
18 #include "parser/parse_node.h"
19
20 typedef enum CATEGORY
21 {
22         INVALID_TYPE,
23         UNKNOWN_TYPE,
24         BOOLEAN_TYPE,
25         STRING_TYPE,
26         BITSTRING_TYPE,
27         NUMERIC_TYPE,
28         DATETIME_TYPE,
29         TIMESPAN_TYPE,
30         GEOMETRIC_TYPE,
31         NETWORK_TYPE,
32         USER_TYPE,
33         MIXED_TYPE
34 } CATEGORY;
35
36
37 extern bool IsBinaryCompatible(Oid type1, Oid type2);
38 extern bool IsPreferredType(CATEGORY category, Oid type);
39 extern CATEGORY TypeCategory(Oid type);
40
41 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids);
42 extern Node *coerce_type(ParseState *pstate, Node *node, Oid inputTypeId,
43                         Oid targetTypeId, int32 atttypmod);
44 extern Node *coerce_type_typmod(ParseState *pstate, Node *node,
45                                    Oid targetTypeId, int32 atttypmod);
46
47 extern bool coerce_to_boolean(ParseState *pstate, Node **pnode);
48
49 extern Oid      select_common_type(List *typeids, const char *context);
50 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
51                                           Oid targetTypeId,
52                                           const char *context);
53
54 #endif   /* PARSE_COERCE_H */