Fix some prepared statement bug
This commit is contained in:
parent
088e14bdc0
commit
e556c2117c
@ -329,9 +329,14 @@ int ObExprCast::calc_result_type2(ObExprResType &type,
|
||||
LOG_WARN("adjust udt cast sub type failed", K(ret));
|
||||
} else if (OB_UNLIKELY(!cast_supported(type1.get_type(), type1.get_collation_type(),
|
||||
dst_type.get_type(), dst_type.get_collation_type()))) {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_WARN("transition does not support", "src", ob_obj_type_str(type1.get_type()),
|
||||
"dst", ob_obj_type_str(dst_type.get_type()));
|
||||
if (session->is_ps_prepare_stage()) {
|
||||
type.set_null();
|
||||
LOG_TRACE("ps prepare phase ignores type deduce error");
|
||||
} else {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_WARN("transition does not support", "src", ob_obj_type_str(type1.get_type()),
|
||||
"dst", ob_obj_type_str(dst_type.get_type()));
|
||||
}
|
||||
} else if (FALSE_IT(is_explicit_cast = CM_IS_EXPLICIT_CAST(cast_raw_expr->get_extra()))) {
|
||||
// check cast supported in cast_map but not support here.
|
||||
} else if (OB_FAIL(ObSQLUtils::get_cs_level_from_cast_mode(cast_raw_expr->get_extra(),
|
||||
@ -341,8 +346,13 @@ int ObExprCast::calc_result_type2(ObExprResType &type,
|
||||
} else if (!check_cast_allowed(type1.get_type(), type1.get_collation_type(),
|
||||
dst_type.get_type(), dst_type.get_collation_type(),
|
||||
is_explicit_cast)) {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_WARN("explicit cast to lob type not allowed", K(ret), K(dst_type));
|
||||
if (session->is_ps_prepare_stage()) {
|
||||
type.set_null();
|
||||
LOG_TRACE("ps prepare phase ignores type deduce error");
|
||||
} else {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_WARN("explicit cast to lob type not allowed", K(ret), K(dst_type));
|
||||
}
|
||||
} else {
|
||||
// always cast to user requested type
|
||||
if (is_explicit_cast && !lib::is_oracle_mode() &&
|
||||
|
@ -78,6 +78,8 @@ int ObExprLeft::calc_result_type2(ObExprResType &type,
|
||||
} else if (exec_ctx->is_ps_prepare_stage()) {
|
||||
// the ps prepare stage does not do type deduction, and directly gives a default type.
|
||||
type.set_char();
|
||||
type.set_default_collation_type();
|
||||
type.set_collation_level(CS_LEVEL_IMPLICIT);
|
||||
type.set_length(0);
|
||||
} else {
|
||||
type2.set_calc_type(ObIntType);
|
||||
|
@ -389,7 +389,12 @@ int ObRawExpr::deduce_type(const ObSQLSessionInfo *session_info)
|
||||
ObRawExprDeduceType expr_deducer(session_info);
|
||||
expr_deducer.set_expr_factory(expr_factory_);
|
||||
if (OB_FAIL(expr_deducer.deduce(*this))) {
|
||||
LOG_WARN("fail to deduce", K(ret));
|
||||
if (session_info->is_ps_prepare_stage()) {
|
||||
ret = OB_SUCCESS;
|
||||
LOG_TRACE("ps prepare phase ignores type deduce error");
|
||||
} else {
|
||||
LOG_WARN("fail to deduce", K(ret));
|
||||
}
|
||||
}
|
||||
//LOG_DEBUG("deduce_type", "usec", ObSQLUtils::get_usec());
|
||||
return ret;
|
||||
|
@ -449,20 +449,7 @@ int ObRawExprDeduceType::calc_result_type(ObNonTerminalRawExpr &expr,
|
||||
}
|
||||
if (OB_FAIL(ret) && my_session_->is_ps_prepare_stage()) {
|
||||
// the ps prepare stage does not do type deduction, and directly gives a default type.
|
||||
result_type.set_varchar();
|
||||
result_type.set_default_collation_type();
|
||||
result_type.set_collation_level(CS_LEVEL_IMPLICIT);
|
||||
result_type.set_calc_type_default_varchar();
|
||||
result_type.set_calc_collation_level(CS_LEVEL_IMPLICIT);
|
||||
for (int64_t i = 0; i < types.count(); i++) {
|
||||
types.at(i).set_varchar();
|
||||
types.at(i).set_default_collation_type();
|
||||
types.at(i).set_collation_level(CS_LEVEL_IMPLICIT);
|
||||
types.at(i).set_calc_type_default_varchar();
|
||||
types.at(i).set_calc_collation_level(CS_LEVEL_IMPLICIT);
|
||||
}
|
||||
expr.set_result_type(result_type);
|
||||
expr.set_input_types(types);
|
||||
result_type.set_null();
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
// check parameters can cast to expected type
|
||||
@ -492,7 +479,8 @@ int ObRawExprDeduceType::calc_result_type(ObNonTerminalRawExpr &expr,
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_WARN("cast parameter to expected type not supported", K(ret), K(i), K(from), K(to));
|
||||
} else if (is_oracle_mode && (ob_is_lob_locator(from) || ob_is_text_tc(from))) {
|
||||
if (OB_FAIL(check_lob_param_allowed(from, from_cs_type, to,
|
||||
if (!my_session_->is_ps_prepare_stage()
|
||||
&& OB_FAIL(check_lob_param_allowed(from, from_cs_type, to,
|
||||
to_cs_type, expr.get_expr_type()))) {
|
||||
LOG_WARN("lob parameter not allowed", K(ret));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user