PostgreSQL Source Code git master
|
#include "postgres.h"
#include "catalog/pg_cast.h"
#include "catalog/pg_class.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_coerce.h"
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
Functions | |
static Node * | coerce_type_typmod (Node *node, Oid targetTypeId, int32 targetTypMod, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion) |
static void | hide_coercion_node (Node *node) |
static Node * | build_coercion_expression (Node *node, CoercionPathType pathtype, Oid funcId, Oid targetTypeId, int32 targetTypMod, CoercionContext ccontext, CoercionForm cformat, int location) |
static Node * | coerce_record_to_complex (ParseState *pstate, Node *node, Oid targetTypeId, CoercionContext ccontext, CoercionForm cformat, int location) |
static bool | is_complex_array (Oid typid) |
static bool | typeIsOfTypedTable (Oid reltypeId, Oid reloftypeId) |
Node * | coerce_to_target_type (ParseState *pstate, Node *expr, Oid exprtype, Oid targettype, int32 targettypmod, CoercionContext ccontext, CoercionForm cformat, int location) |
Node * | coerce_type (ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId, int32 targetTypeMod, CoercionContext ccontext, CoercionForm cformat, int location) |
bool | can_coerce_type (int nargs, const Oid *input_typeids, const Oid *target_typeids, CoercionContext ccontext) |
Node * | coerce_to_domain (Node *arg, Oid baseTypeId, int32 baseTypeMod, Oid typeId, CoercionContext ccontext, CoercionForm cformat, int location, bool hideInputCoercion) |
Node * | coerce_to_boolean (ParseState *pstate, Node *node, const char *constructName) |
Node * | coerce_to_specific_type_typmod (ParseState *pstate, Node *node, Oid targetTypeId, int32 targetTypmod, const char *constructName) |
Node * | coerce_to_specific_type (ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName) |
Node * | coerce_null_to_domain (Oid typid, int32 typmod, Oid collation, int typlen, bool typbyval) |
int | parser_coercion_errposition (ParseState *pstate, int coerce_location, Node *input_expr) |
Oid | select_common_type (ParseState *pstate, List *exprs, const char *context, Node **which_expr) |
static Oid | select_common_type_from_oids (int nargs, const Oid *typeids, bool noerror) |
Node * | coerce_to_common_type (ParseState *pstate, Node *node, Oid targetTypeId, const char *context) |
bool | verify_common_type (Oid common_type, List *exprs) |
static bool | verify_common_type_from_oids (Oid common_type, int nargs, const Oid *typeids) |
int32 | select_common_typmod (ParseState *pstate, List *exprs, Oid common_type) |
bool | check_generic_type_consistency (const Oid *actual_arg_types, const Oid *declared_arg_types, int nargs) |
Oid | enforce_generic_type_consistency (const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly) |
char * | check_valid_polymorphic_signature (Oid ret_type, const Oid *declared_arg_types, int nargs) |
char * | check_valid_internal_signature (Oid ret_type, const Oid *declared_arg_types, int nargs) |
TYPCATEGORY | TypeCategory (Oid type) |
bool | IsPreferredType (TYPCATEGORY category, Oid type) |
bool | IsBinaryCoercible (Oid srctype, Oid targettype) |
bool | IsBinaryCoercibleWithCast (Oid srctype, Oid targettype, Oid *castoid) |
CoercionPathType | find_coercion_pathway (Oid targetTypeId, Oid sourceTypeId, CoercionContext ccontext, Oid *funcid) |
CoercionPathType | find_typmod_coercion_function (Oid typeId, Oid *funcid) |
|
static |
Definition at line 837 of file parse_coerce.c.
References CoerceViaIO::arg, ArrayCoerceExpr::arg, generate_unaccent_rules::args, Assert, BoolGetDatum(), coerce_to_target_type(), COERCION_EXPLICIT, COERCION_PATH_ARRAYCOERCE, COERCION_PATH_COERCEVIAIO, COERCION_PATH_FUNC, ArrayCoerceExpr::elemexpr, elog, ERROR, exprType(), exprTypmod(), get_element_type(), getBaseTypeAndTypmod(), GETSTRUCT(), HeapTupleIsValid, Int32GetDatum(), InvalidOid, lappend(), list_make1, FuncExpr::location, CoerceViaIO::location, ArrayCoerceExpr::location, makeConst(), makeFuncExpr(), makeNode, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), CoerceViaIO::resulttype, ArrayCoerceExpr::resulttype, SearchSysCache1(), and CaseTestExpr::typeId.
Referenced by coerce_type(), and coerce_type_typmod().
bool can_coerce_type | ( | int | nargs, |
const Oid * | input_typeids, | ||
const Oid * | target_typeids, | ||
CoercionContext | ccontext | ||
) |
Definition at line 557 of file parse_coerce.c.
References check_generic_type_consistency(), COERCION_PATH_NONE, find_coercion_pathway(), i, is_complex_array(), ISCOMPLEX, typeInheritsFrom(), and typeIsOfTypedTable().
Referenced by ATAddForeignKeyConstraint(), coerce_to_common_type(), coerce_to_target_type(), func_match_argtypes(), func_select_candidate(), jsonb_subscript_transform(), select_common_type(), select_common_type_from_oids(), transformFrameOffset(), verify_common_type(), and verify_common_type_from_oids().
bool check_generic_type_consistency | ( | const Oid * | actual_arg_types, |
const Oid * | declared_arg_types, | ||
int | nargs | ||
) |
Definition at line 1737 of file parse_coerce.c.
References Assert, FUNC_MAX_ARGS, get_element_type(), get_multirange_range(), get_range_subtype(), getBaseType(), InvalidOid, j, OidIsValid, select_common_type_from_oids(), type_is_array_domain, type_is_enum(), and verify_common_type_from_oids().
Referenced by can_coerce_type().
Definition at line 2952 of file parse_coerce.c.
References _, i, and pstrdup().
Referenced by AggregateCreate(), and ProcedureCreate().
char * check_valid_polymorphic_signature | ( | Oid | ret_type, |
const Oid * | declared_arg_types, | ||
int | nargs | ||
) |
Definition at line 2875 of file parse_coerce.c.
References _, format_type_be(), i, and psprintf().
Referenced by AggregateCreate(), and ProcedureCreate().
Definition at line 1271 of file parse_coerce.c.
References COERCE_IMPLICIT_CAST, coerce_to_domain(), COERCION_IMPLICIT, getBaseTypeAndTypmod(), and makeConst().
Referenced by expand_insert_targetlist(), ReplaceVarsFromTargetList_callback(), rewriteTargetListIU(), and rewriteValuesRTE().
|
static |
Definition at line 1010 of file parse_coerce.c.
References arg, generate_unaccent_rules::args, RowExpr::args, COERCE_IMPLICIT_CAST, coerce_to_domain(), coerce_to_target_type(), ereport, errcode(), errdetail(), errmsg(), ERROR, expandNSItemVars(), exprType(), format_type_be(), getBaseTypeAndTypmod(), GetNSItemByRangeTablePosn(), i, InvalidAttrNumber, InvalidOid, IsA, lappend(), lfirst, list_head(), lnext(), RowExpr::location, lookup_rowtype_tupdesc(), makeNode, makeNullConst(), TupleDescData::natts, NIL, parser_coercion_errposition(), ReleaseTupleDesc, and TupleDescAttr().
Referenced by coerce_type().
Node * coerce_to_boolean | ( | ParseState * | pstate, |
Node * | node, | ||
const char * | constructName | ||
) |
Definition at line 1159 of file parse_coerce.c.
References COERCE_IMPLICIT_CAST, coerce_to_target_type(), COERCION_ASSIGNMENT, ereport, errcode(), errmsg(), ERROR, expression_returns_set(), exprLocation(), exprType(), format_type_be(), and parser_errposition().
Referenced by cookConstraint(), DoCopy(), domainAddCheckConstraint(), transformAExprIn(), transformBooleanTest(), transformBoolExpr(), transformCaseExpr(), transformJoinUsingClause(), transformWhereClause(), and transformXmlExpr().
Node * coerce_to_common_type | ( | ParseState * | pstate, |
Node * | node, | ||
Oid | targetTypeId, | ||
const char * | context | ||
) |
Definition at line 1572 of file parse_coerce.c.
References can_coerce_type(), COERCE_IMPLICIT_CAST, coerce_type(), COERCION_IMPLICIT, ereport, errcode(), errmsg(), ERROR, exprLocation(), exprType(), format_type_be(), and parser_errposition().
Referenced by analyzeCTE(), generate_setop_tlist(), transformAExprIn(), transformArrayExpr(), transformCaseExpr(), transformCoalesceExpr(), transformMinMaxExpr(), transformSetOperationTree(), and transformValuesClause().
Node * coerce_to_domain | ( | Node * | arg, |
Oid | baseTypeId, | ||
int32 | baseTypeMod, | ||
Oid | typeId, | ||
CoercionContext | ccontext, | ||
CoercionForm | cformat, | ||
int | location, | ||
bool | hideInputCoercion | ||
) |
Definition at line 675 of file parse_coerce.c.
References arg, CoerceToDomain::arg, Assert, COERCE_IMPLICIT_CAST, coerce_type_typmod(), hide_coercion_node(), CoerceToDomain::location, makeNode, OidIsValid, and CoerceToDomain::resulttype.
Referenced by coerce_null_to_domain(), coerce_record_to_complex(), coerce_type(), and transformAssignmentIndirection().
Node * coerce_to_specific_type | ( | ParseState * | pstate, |
Node * | node, | ||
Oid | targetTypeId, | ||
const char * | constructName | ||
) |
Definition at line 1255 of file parse_coerce.c.
References coerce_to_specific_type_typmod().
Referenced by coerceJsonFuncExpr(), interpret_function_parameter_list(), transformFrameOffset(), transformJsonScalarExpr(), transformJsonValueExpr(), transformLimitClause(), transformRangeTableFunc(), transformRangeTableSample(), transformXmlExpr(), and transformXmlSerialize().
Node * coerce_to_specific_type_typmod | ( | ParseState * | pstate, |
Node * | node, | ||
Oid | targetTypeId, | ||
int32 | targetTypmod, | ||
const char * | constructName | ||
) |
Definition at line 1206 of file parse_coerce.c.
References COERCE_IMPLICIT_CAST, coerce_to_target_type(), COERCION_ASSIGNMENT, ereport, errcode(), errmsg(), ERROR, expression_returns_set(), exprLocation(), exprType(), format_type_be(), and parser_errposition().
Referenced by coerce_to_specific_type(), and transformRangeTableFunc().
Node * coerce_to_target_type | ( | ParseState * | pstate, |
Node * | expr, | ||
Oid | exprtype, | ||
Oid | targettype, | ||
int32 | targettypmod, | ||
CoercionContext | ccontext, | ||
CoercionForm | cformat, | ||
int | location | ||
) |
Definition at line 78 of file parse_coerce.c.
References arg, CollateExpr::arg, can_coerce_type(), coerce_type(), coerce_type_typmod(), CollateExpr::collOid, IsA, CollateExpr::location, makeNode, and type_is_collatable().
Referenced by array_subscript_transform(), ATExecAddColumn(), ATExecAlterColumnType(), ATPrepAlterColumnType(), build_coercion_expression(), build_column_default(), coerce_fn_result_column(), coerce_record_to_complex(), coerce_to_boolean(), coerce_to_specific_type_typmod(), coerceJsonFuncExpr(), cookDefault(), EvaluateParams(), get_cast_hashentry(), hstore_subscript_transform(), transformArrayExpr(), transformAssignedExpr(), transformAssignmentIndirection(), transformAssignmentSubscripts(), transformJsonBehavior(), transformJsonFuncExpr(), transformJsonParseArg(), transformJsonValueExpr(), transformPartitionBoundValue(), transformPLAssignStmt(), transformTypeCast(), and transformXmlSerialize().
Node * coerce_type | ( | ParseState * | pstate, |
Node * | node, | ||
Oid | inputTypeId, | ||
Oid | targetTypeId, | ||
int32 | targetTypeMod, | ||
CoercionContext | ccontext, | ||
CoercionForm | cformat, | ||
int | location | ||
) |
Definition at line 157 of file parse_coerce.c.
References ConvertRowtypeExpr::arg, CollateExpr::arg, build_coercion_expression(), cancel_parser_errposition_callback(), COERCE_IMPLICIT_CAST, coerce_record_to_complex(), coerce_to_domain(), coerce_type(), COERCION_PATH_NONE, COERCION_PATH_RELABELTYPE, CollateExpr::collOid, Const::consttype, DatumGetCString(), datumIsEqual(), elog, ERROR, find_coercion_pathway(), format_type_be(), getBaseType(), getBaseTypeAndTypmod(), InvalidOid, is_complex_array(), IsA, ISCOMPLEX, RelabelType::location, ConvertRowtypeExpr::location, CollateExpr::location, makeNode, makeRelabelType(), ParseState::p_coerce_param_hook, PG_DETOAST_DATUM, PointerGetDatum(), ReleaseSysCache(), ConvertRowtypeExpr::resulttype, setup_parser_errposition_callback(), stringTypeDatum(), type_is_collatable(), typeByVal(), typeidType(), typeInheritsFrom(), typeIsOfTypedTable(), typeLen(), typeTypeCollation(), typeTypeName(), and WARNING.
Referenced by addTargetToGroupList(), addTargetToSortList(), buildMergedJoinVar(), coerce_to_common_type(), coerce_to_target_type(), coerce_type(), jsonb_subscript_transform(), make_fn_arguments(), ParseFuncOrColumn(), resolveTargetListUnknowns(), transformArrayExpr(), and unify_hypothetical_args().
|
static |
Definition at line 751 of file parse_coerce.c.
References applyRelabelType(), build_coercion_expression(), COERCION_PATH_NONE, exprCollation(), exprTypmod(), find_typmod_coercion_function(), and hide_coercion_node().
Referenced by coerce_to_domain(), and coerce_to_target_type().
Oid enforce_generic_type_consistency | ( | const Oid * | actual_arg_types, |
Oid * | declared_arg_types, | ||
int | nargs, | ||
Oid | rettype, | ||
bool | allow_poly | ||
) |
Definition at line 2131 of file parse_coerce.c.
References Assert, ereport, errcode(), errdetail(), errmsg(), errmsg_internal(), ERROR, format_type_be(), FUNC_MAX_ARGS, get_array_type(), get_element_type(), get_multirange_range(), get_range_multirange(), get_range_subtype(), getBaseType(), InvalidOid, j, OidIsValid, select_common_type_from_oids(), type_is_array_domain, type_is_enum(), and verify_common_type_from_oids().
Referenced by lookup_agg_function(), make_op(), make_scalar_array_op(), ParseFuncOrColumn(), recheck_cast_function_args(), and resolve_aggregate_transtype().
CoercionPathType find_coercion_pathway | ( | Oid | targetTypeId, |
Oid | sourceTypeId, | ||
CoercionContext | ccontext, | ||
Oid * | funcid | ||
) |
Definition at line 3153 of file parse_coerce.c.
References COERCION_ASSIGNMENT, COERCION_EXPLICIT, COERCION_IMPLICIT, COERCION_PATH_ARRAYCOERCE, COERCION_PATH_COERCEVIAIO, COERCION_PATH_FUNC, COERCION_PATH_NONE, COERCION_PATH_RELABELTYPE, COERCION_PLPGSQL, elog, ERROR, find_coercion_pathway(), get_element_type(), getBaseType(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache2(), and TypeCategory().
Referenced by can_coerce_type(), coerce_type(), find_coercion_pathway(), findFkeyCast(), func_get_detail(), json_categorize_type(), and ri_HashCompareOp().
CoercionPathType find_typmod_coercion_function | ( | Oid | typeId, |
Oid * | funcid | ||
) |
Definition at line 3316 of file parse_coerce.c.
References COERCION_PATH_ARRAYCOERCE, COERCION_PATH_FUNC, COERCION_PATH_NONE, GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache2(), and typeidType().
Referenced by coerce_type_typmod().
|
static |
Definition at line 809 of file parse_coerce.c.
References COERCE_IMPLICIT_CAST, elog, ERROR, IsA, and nodeTag.
Referenced by coerce_to_domain(), and coerce_type_typmod().
|
static |
Definition at line 3366 of file parse_coerce.c.
References get_element_type(), ISCOMPLEX, and OidIsValid.
Referenced by can_coerce_type(), coerce_type(), and IsBinaryCoercibleWithCast().
Definition at line 3030 of file parse_coerce.c.
References IsBinaryCoercibleWithCast().
Referenced by AggregateCreate(), binary_coercible(), check_amproc_signature(), compatible_oper(), ExecInitAgg(), findRangeSubOpclass(), GetDefaultOpClass(), initialize_peragg(), lookup_agg_function(), ResolveOpClass(), ri_HashCompareOp(), satisfies_hash_partition(), spgGetCache(), ts_stat_sql(), tsvector_update_trigger(), and tupledesc_match().
Definition at line 3045 of file parse_coerce.c.
References getBaseType(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, is_complex_array(), ISCOMPLEX, ObjectIdGetDatum(), OidIsValid, ReleaseSysCache(), SearchSysCache2(), type_is_array, type_is_enum(), type_is_multirange(), and type_is_range().
Referenced by CreateCast(), and IsBinaryCoercible().
bool IsPreferredType | ( | TYPCATEGORY | category, |
Oid | type | ||
) |
Definition at line 2995 of file parse_coerce.c.
References get_type_category_preferred(), and type.
Referenced by func_select_candidate(), and GetDefaultOpClass().
int parser_coercion_errposition | ( | ParseState * | pstate, |
int | coerce_location, | ||
Node * | input_expr | ||
) |
Definition at line 1312 of file parse_coerce.c.
References exprLocation(), and parser_errposition().
Referenced by coerce_record_to_complex(), coerceJsonFuncExpr(), and transformTypeCast().
Oid select_common_type | ( | ParseState * | pstate, |
List * | exprs, | ||
const char * | context, | ||
Node ** | which_expr | ||
) |
Definition at line 1342 of file parse_coerce.c.
References Assert, can_coerce_type(), COERCION_IMPLICIT, ereport, errcode(), errmsg(), ERROR, exprLocation(), exprType(), for_each_cell, format_type_be(), get_type_category_preferred(), getBaseType(), InvalidOid, lfirst, linitial, list_second_cell(), NIL, and parser_errposition().
Referenced by analyzeCTE(), buildMergedJoinVar(), transformAExprIn(), transformArrayExpr(), transformCaseExpr(), transformCoalesceExpr(), transformMinMaxExpr(), transformSetOperationTree(), transformValuesClause(), and unify_hypothetical_args().
Definition at line 1478 of file parse_coerce.c.
References Assert, can_coerce_type(), COERCION_IMPLICIT, ereport, errcode(), errmsg(), ERROR, format_type_be(), get_type_category_preferred(), getBaseType(), i, and InvalidOid.
Referenced by check_generic_type_consistency(), and enforce_generic_type_consistency().
int32 select_common_typmod | ( | ParseState * | pstate, |
List * | exprs, | ||
Oid | common_type | ||
) |
Definition at line 1644 of file parse_coerce.c.
References exprType(), exprTypmod(), and lfirst.
Referenced by analyzeCTE(), buildMergedJoinVar(), transformSetOperationTree(), transformValuesClause(), and unify_hypothetical_args().
TYPCATEGORY TypeCategory | ( | Oid | type | ) |
Definition at line 2976 of file parse_coerce.c.
References Assert, get_type_category_preferred(), and type.
Referenced by find_coercion_pathway(), func_get_detail(), func_select_candidate(), GetDefaultOpClass(), and transformJsonBehavior().
Definition at line 3380 of file parse_coerce.c.
References elog, ERROR, GETSTRUCT(), HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache1(), and typeOrDomainTypeRelid().
Referenced by can_coerce_type(), and coerce_type().
Definition at line 1606 of file parse_coerce.c.
References can_coerce_type(), COERCION_IMPLICIT, exprType(), and lfirst.
Referenced by transformAExprIn().
Definition at line 1626 of file parse_coerce.c.
References can_coerce_type(), COERCION_IMPLICIT, and i.
Referenced by check_generic_type_consistency(), and enforce_generic_type_consistency().