PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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-2026, 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) */
21typedef char TYPCATEGORY;
22
23/* Result codes for find_coercion_pathway */
24typedef 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
34extern bool IsBinaryCoercible(Oid srctype, Oid targettype);
35extern bool IsBinaryCoercibleWithCast(Oid srctype, Oid targettype,
36 Oid *castoid);
37extern bool IsPreferredType(TYPCATEGORY category, Oid type);
39
41 Node *expr, Oid exprtype,
42 Oid targettype, int32 targettypmod,
45 int location);
46extern bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids,
48extern Node *coerce_type(ParseState *pstate, Node *node,
52 Oid typeId,
55
56extern Node *coerce_to_boolean(ParseState *pstate, Node *node,
57 const char *constructName);
58extern Node *coerce_to_specific_type(ParseState *pstate, Node *node,
60 const char *constructName);
61
64 const char *constructName);
65
66extern Node *coerce_null_to_domain(Oid typid, int32 typmod, Oid collation,
67 int typlen, bool typbyval);
68
72
73extern Oid select_common_type(ParseState *pstate, List *exprs,
74 const char *context, Node **which_expr);
75extern Node *coerce_to_common_type(ParseState *pstate, Node *node,
77 const char *context);
78extern bool verify_common_type(Oid common_type, List *exprs);
79
81
84 int nargs);
87 int nargs,
88 Oid rettype,
89 bool allow_poly);
90
93 int nargs);
96 int nargs);
97
101 Oid *funcid);
103 Oid *funcid);
104
105#endif /* PARSE_COERCE_H */
int32_t int32
Definition c.h:542
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)
Node * coerce_to_common_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *context)
CoercionPathType find_typmod_coercion_function(Oid typeId, Oid *funcid)
char TYPCATEGORY
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)
char * check_valid_internal_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
Node * coerce_to_domain(Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion)
char * check_valid_polymorphic_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
Node * coerce_to_specific_type_typmod(ParseState *pstate, Node *node, Oid targetTypeId, int32 targetTypmod, const char *constructName)
CoercionPathType find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid)
int parser_coercion_errposition(ParseState *pstate, int coerce_location, Node *input_expr)
Node * coerce_null_to_domain(Oid typid, int32 typmod, Oid collation, int typlen, bool typbyval)
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)
Node * coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
bool IsPreferredType(TYPCATEGORY category, Oid type)
Node * coerce_to_boolean(ParseState *pstate, Node *node, const char *constructName)
Oid select_common_type(ParseState *pstate, List *exprs, const char *context, Node **which_expr)
bool can_coerce_type(int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext)
Node * coerce_to_target_type(ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location)
CoercionPathType
@ COERCION_PATH_NONE
@ COERCION_PATH_COERCEVIAIO
@ COERCION_PATH_ARRAYCOERCE
@ COERCION_PATH_FUNC
@ COERCION_PATH_RELABELTYPE
bool IsBinaryCoercibleWithCast(Oid srctype, Oid targettype, Oid *castoid)
void * arg
unsigned int Oid
static int fb(int x)
CoercionForm
Definition primnodes.h:765
CoercionContext
Definition primnodes.h:745
Definition pg_list.h:54
Definition nodes.h:135
const char * type