PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
parse_coerce.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parse_coerce.h
4  * Routines for type coercion.
5  *
6  *
7  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/include/parser/parse_coerce.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef PARSE_COERCE_H
15 #define PARSE_COERCE_H
16 
17 #include "parser/parse_node.h"
18 
19 
20 /* Type categories (see TYPCATEGORY_xxx symbols in catalog/pg_type.h) */
21 typedef char TYPCATEGORY;
22 
23 /* Result codes for find_coercion_pathway */
24 typedef enum CoercionPathType
25 {
26  COERCION_PATH_NONE, /* failed to find any coercion pathway */
27  COERCION_PATH_FUNC, /* apply the specified coercion function */
28  COERCION_PATH_RELABELTYPE, /* binary-compatible cast, no function */
29  COERCION_PATH_ARRAYCOERCE, /* need an ArrayCoerceExpr node */
30  COERCION_PATH_COERCEVIAIO /* need a CoerceViaIO node */
32 
33 
34 extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
35 extern bool IsPreferredType(TYPCATEGORY category, Oid type);
36 extern TYPCATEGORY TypeCategory(Oid type);
37 
38 extern Node *coerce_to_target_type(ParseState *pstate,
39  Node *expr, Oid exprtype,
40  Oid targettype, int32 targettypmod,
41  CoercionContext ccontext,
42  CoercionForm cformat,
43  int location);
44 extern bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
45  CoercionContext ccontext);
46 extern Node *coerce_type(ParseState *pstate, Node *node,
47  Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod,
48  CoercionContext ccontext, CoercionForm cformat, int location);
49 extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod,
50  Oid typeId,
51  CoercionForm cformat, int location,
52  bool hideInputCoercion,
53  bool lengthCoercionDone);
54 
55 extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
56  const char *constructName);
57 extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
58  Oid targetTypeId,
59  const char *constructName);
60 
61 extern Node *coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
62  Oid targetTypeId, int32 targetTypmod,
63  const char *constructName);
64 
65 extern int parser_coercion_errposition(ParseState *pstate,
66  int coerce_location,
67  Node *input_expr);
68 
69 extern Oid select_common_type(ParseState *pstate, List *exprs,
70  const char *context, Node **which_expr);
71 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
72  Oid targetTypeId,
73  const char *context);
74 
75 extern bool check_generic_type_consistency(Oid *actual_arg_types,
76  Oid *declared_arg_types,
77  int nargs);
78 extern Oid enforce_generic_type_consistency(Oid *actual_arg_types,
79  Oid *declared_arg_types,
80  int nargs,
81  Oid rettype,
82  bool allow_poly);
83 extern Oid resolve_generic_type(Oid declared_type,
84  Oid context_actual_type,
85  Oid context_declared_type);
86 
87 extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
88  Oid sourceTypeId,
89  CoercionContext ccontext,
90  Oid *funcid);
92  Oid *funcid);
93 
94 #endif /* PARSE_COERCE_H */
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
Definition: parse_coerce.c:156
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
Oid resolve_generic_type(Oid declared_type, Oid context_actual_type, Oid context_declared_type)
Node * coerce_to_specific_type_typmod(ParseState *pstate, Node *node, Oid targetTypeId, int32 targetTypmod, const char *constructName)
Definition: nodes.h:509
unsigned int Oid
Definition: postgres_ext.h:31
CoercionContext
Definition: primnodes.h:419
CoercionPathType
Definition: parse_coerce.h:24
signed int int32
Definition: c.h:256
bool IsPreferredType(TYPCATEGORY category, Oid type)
char TYPCATEGORY
Definition: parse_coerce.h:21
Oid enforce_generic_type_consistency(Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
Node * coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionForm cformat, int location, bool hideInputCoercion, bool lengthCoercionDone)
Definition: parse_coerce.c:648
Node * coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context)
CoercionPathType find_typmod_coercion_function(Oid typeId, Oid *funcid)
Node * coerce_to_specific_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName)
bool check_generic_type_consistency(Oid *actual_arg_types, Oid *declared_arg_types, int nargs)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
Definition: parse_coerce.c:77
bool can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, CoercionContext ccontext)
Definition: parse_coerce.c:527
void * arg
int parser_coercion_errposition(ParseState *pstate, int coerce_location, Node *input_expr)
TYPCATEGORY TypeCategory(Oid type)
CoercionForm
Definition: primnodes.h:435
Definition: pg_list.h:45
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
bool IsBinaryCoercible(Oid srctype, Oid targettype)