]> granicus.if.org Git - postgresql/blob - src/include/parser/parse_coerce.h
Code review for bigint-LIMIT patch. Fix missed planner dependency,
[postgresql] / src / include / parser / parse_coerce.h
1 /*-------------------------------------------------------------------------
2  *
3  * parse_coerce.h
4  *      Routines for type coercion.
5  *
6  *
7  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $PostgreSQL: pgsql/src/include/parser/parse_coerce.h,v 1.65 2006/07/26 19:31:51 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PARSE_COERCE_H
15 #define PARSE_COERCE_H
16
17 #include "parser/parse_node.h"
18
19
20 typedef enum CATEGORY
21 {
22         INVALID_TYPE,
23         UNKNOWN_TYPE,
24         GENERIC_TYPE,
25         BOOLEAN_TYPE,
26         STRING_TYPE,
27         BITSTRING_TYPE,
28         NUMERIC_TYPE,
29         DATETIME_TYPE,
30         TIMESPAN_TYPE,
31         GEOMETRIC_TYPE,
32         NETWORK_TYPE,
33         USER_TYPE
34 } CATEGORY;
35
36
37 extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
38 extern bool IsPreferredType(CATEGORY category, Oid type);
39 extern CATEGORY TypeCategory(Oid type);
40
41 extern Node *coerce_to_target_type(ParseState *pstate,
42                                           Node *expr, Oid exprtype,
43                                           Oid targettype, int32 targettypmod,
44                                           CoercionContext ccontext,
45                                           CoercionForm cformat);
46 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
47                                 CoercionContext ccontext);
48 extern Node *coerce_type(ParseState *pstate, Node *node,
49                         Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod,
50                         CoercionContext ccontext, CoercionForm cformat);
51 extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod,
52                                  Oid typeId,
53                                  CoercionForm cformat, bool hideInputCoercion,
54                                  bool lengthCoercionDone);
55
56 extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
57                                   const char *constructName);
58 extern Node *coerce_to_integer(ParseState *pstate, Node *node,
59                                   const char *constructName);
60 extern Node *coerce_to_bigint(ParseState *pstate, Node *node,
61                                                           const char *constructName);
62
63 extern Oid      select_common_type(List *typeids, const char *context);
64 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
65                                           Oid targetTypeId,
66                                           const char *context);
67
68 extern bool check_generic_type_consistency(Oid *actual_arg_types,
69                                                            Oid *declared_arg_types,
70                                                            int nargs);
71 extern Oid enforce_generic_type_consistency(Oid *actual_arg_types,
72                                                                  Oid *declared_arg_types,
73                                                                  int nargs,
74                                                                  Oid rettype);
75 extern Oid resolve_generic_type(Oid declared_type,
76                                          Oid context_actual_type,
77                                          Oid context_declared_type);
78
79 extern bool find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
80                                           CoercionContext ccontext,
81                                           Oid *funcid);
82 extern Oid      find_typmod_coercion_function(Oid typeId);
83
84 #endif   /* PARSE_COERCE_H */