PostgreSQL Source Code  git master
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-2024, 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 IsBinaryCoercibleWithCast(Oid srctype, Oid targettype,
36  Oid *castoid);
37 extern bool IsPreferredType(TYPCATEGORY category, Oid type);
39 
40 extern Node *coerce_to_target_type(ParseState *pstate,
41  Node *expr, Oid exprtype,
42  Oid targettype, int32 targettypmod,
43  CoercionContext ccontext,
44  CoercionForm cformat,
45  int location);
46 extern bool can_coerce_type(int nargs, const Oid *input_typeids, const 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, int location);
51 extern Node *coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod,
52  Oid typeId,
53  CoercionContext ccontext, CoercionForm cformat, int location,
54  bool hideInputCoercion);
55 
56 extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
57  const char *constructName);
58 extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
59  Oid targetTypeId,
60  const char *constructName);
61 
62 extern Node *coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
63  Oid targetTypeId, int32 targetTypmod,
64  const char *constructName);
65 
66 extern int parser_coercion_errposition(ParseState *pstate,
67  int coerce_location,
68  Node *input_expr);
69 
70 extern Oid select_common_type(ParseState *pstate, List *exprs,
71  const char *context, Node **which_expr);
72 extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
73  Oid targetTypeId,
74  const char *context);
75 extern bool verify_common_type(Oid common_type, List *exprs);
76 
77 extern int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type);
78 
79 extern bool check_generic_type_consistency(const Oid *actual_arg_types,
80  const Oid *declared_arg_types,
81  int nargs);
82 extern Oid enforce_generic_type_consistency(const Oid *actual_arg_types,
83  Oid *declared_arg_types,
84  int nargs,
85  Oid rettype,
86  bool allow_poly);
87 
88 extern char *check_valid_polymorphic_signature(Oid ret_type,
89  const Oid *declared_arg_types,
90  int nargs);
91 extern char *check_valid_internal_signature(Oid ret_type,
92  const Oid *declared_arg_types,
93  int nargs);
94 
95 extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
96  Oid sourceTypeId,
97  CoercionContext ccontext,
98  Oid *funcid);
100  Oid *funcid);
101 
102 #endif /* PARSE_COERCE_H */
signed int int32
Definition: c.h:497
TYPCATEGORY TypeCategory(Oid type)
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
CoercionPathType find_typmod_coercion_function(Oid typeId, Oid *funcid)
Node * coerce_to_specific_type_typmod(ParseState *pstate, Node *node, Oid targetTypeId, int32 targetTypmod, const char *constructName)
Node * coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
Definition: parse_coerce.c:157
Node * coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion)
Definition: parse_coerce.c:676
char TYPCATEGORY
Definition: parse_coerce.h:21
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:78
bool check_generic_type_consistency(const Oid *actual_arg_types, const Oid *declared_arg_types, int nargs)
bool verify_common_type(Oid common_type, List *exprs)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
int parser_coercion_errposition(ParseState *pstate, int coerce_location, Node *input_expr)
int32 select_common_typmod(ParseState *pstate, List *exprs, Oid common_type)
Node * coerce_to_specific_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName)
char * check_valid_internal_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
bool IsPreferredType(TYPCATEGORY category, Oid type)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
char * check_valid_polymorphic_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
Definition: parse_coerce.c:556
CoercionPathType
Definition: parse_coerce.h:25
@ COERCION_PATH_NONE
Definition: parse_coerce.h:26
@ COERCION_PATH_COERCEVIAIO
Definition: parse_coerce.h:30
@ COERCION_PATH_ARRAYCOERCE
Definition: parse_coerce.h:29
@ COERCION_PATH_FUNC
Definition: parse_coerce.h:27
@ COERCION_PATH_RELABELTYPE
Definition: parse_coerce.h:28
bool IsBinaryCoercibleWithCast(Oid srctype, Oid targettype, Oid *castoid)
void * arg
unsigned int Oid
Definition: postgres_ext.h:31
CoercionForm
Definition: primnodes.h:733
CoercionContext
Definition: primnodes.h:713
tree context
Definition: radixtree.h:1835
Definition: pg_list.h:54
Definition: nodes.h:129
const char * type