]> granicus.if.org Git - postgresql/blob - src/include/parser/parse_coerce.h
Do honest transformation and preprocessing of LIMIT/OFFSET clauses,
[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-2002, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: parse_coerce.h,v 1.53 2003/07/03 19:07:54 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
21 typedef enum CATEGORY
22 {
23         INVALID_TYPE,
24         UNKNOWN_TYPE,
25         GENERIC_TYPE,
26         BOOLEAN_TYPE,
27         STRING_TYPE,
28         BITSTRING_TYPE,
29         NUMERIC_TYPE,
30         DATETIME_TYPE,
31         TIMESPAN_TYPE,
32         GEOMETRIC_TYPE,
33         NETWORK_TYPE,
34         USER_TYPE
35 } CATEGORY;
36
37
38 extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
39 extern bool IsPreferredType(CATEGORY category, Oid type);
40 extern CATEGORY TypeCategory(Oid type);
41
42 extern Node *coerce_to_target_type(ParseState *pstate,
43                                                                    Node *expr, Oid exprtype,
44                                                                    Oid targettype, int32 targettypmod,
45                                                                    CoercionContext ccontext,
46                                                                    CoercionForm cformat);
47 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
48                                                         CoercionContext ccontext);
49 extern Node *coerce_type(ParseState *pstate, Node *node,
50                                                  Oid inputTypeId, Oid targetTypeId,
51                                                  CoercionContext ccontext, CoercionForm cformat);
52 extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, Oid typeId,
53                                                           CoercionForm cformat);
54
55 extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
56                                                            const char *constructName);
57 extern Node *coerce_to_integer(ParseState *pstate, Node *node,
58                                                            const char *constructName);
59
60 extern Oid      select_common_type(List *typeids, const char *context);
61 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
62                                                                    Oid targetTypeId,
63                                                                    const char *context);
64
65 extern bool check_generic_type_consistency(Oid *actual_arg_types,
66                                                                                    Oid *declared_arg_types,
67                                                                                    int nargs);
68 extern Oid enforce_generic_type_consistency(Oid *actual_arg_types,
69                                                                                         Oid *declared_arg_types,
70                                                                                         int nargs,
71                                                                                         Oid rettype);
72 extern Oid resolve_generic_type(Oid declared_type,
73                                                                 Oid context_actual_type,
74                                                                 Oid context_declared_type);
75
76 extern bool find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,
77                                                                   CoercionContext ccontext,
78                                                                   Oid *funcid);
79 extern Oid      find_typmod_coercion_function(Oid typeId, int *nargs);
80
81 #endif   /* PARSE_COERCE_H */