fix: decimal int not handled properly for values stmt
This commit is contained in:
parent
4148bbff34
commit
e17fa92572
@ -245,10 +245,22 @@ int ObValuesTableAccessOp::calc_datum_from_param(const ObObj &src_obj, ObExpr *d
|
|||||||
ObDatum &dst_datum = dst_expr->locate_datum_for_write(eval_ctx_);
|
ObDatum &dst_datum = dst_expr->locate_datum_for_write(eval_ctx_);
|
||||||
const ObObjType &src_type = src_obj.get_type();
|
const ObObjType &src_type = src_obj.get_type();
|
||||||
const ObObjType &dst_type = dst_expr->obj_meta_.get_type();
|
const ObObjType &dst_type = dst_expr->obj_meta_.get_type();
|
||||||
if (ob_is_decimal_int_tc(src_type) && ob_is_number_tc(dst_type)) {
|
const ObObjParam src_obj_param = static_cast<const ObObjParam>(src_obj);
|
||||||
|
bool need_adjust_decimal_int = ob_is_decimal_int_tc(src_type)
|
||||||
|
&& ob_is_decimal_int_tc(dst_expr->datum_meta_.type_)
|
||||||
|
&& ObDatumCast::need_scale_decimalint(src_obj_param.get_scale(),
|
||||||
|
src_obj_param.get_precision(),
|
||||||
|
dst_expr->datum_meta_.scale_,
|
||||||
|
dst_expr->datum_meta_.precision_);
|
||||||
|
if (ob_is_decimal_int_tc(src_type) && (ob_is_number_tc(dst_type) || need_adjust_decimal_int)) {
|
||||||
ObObj dst_obj;
|
ObObj dst_obj;
|
||||||
const ObDataTypeCastParams dtc_params = ObBasicSessionInfo::create_dtc_params(GET_MY_SESSION(ctx_));
|
const ObDataTypeCastParams dtc_params = ObBasicSessionInfo::create_dtc_params(GET_MY_SESSION(ctx_));
|
||||||
ObCastCtx cast_ctx(&eval_ctx_.exec_ctx_.get_allocator(), &dtc_params, cm_, dst_expr->obj_meta_.get_collation_type());
|
ObAccuracy dst_accuracy = ObAccuracy::DDL_DEFAULT_ACCURACY2[is_oracle_mode()][dst_type];
|
||||||
|
if (ob_is_decimal_int_tc(dst_type)) {
|
||||||
|
dst_accuracy.set_scale(dst_expr->datum_meta_.scale_);
|
||||||
|
dst_accuracy.set_precision(dst_expr->datum_meta_.precision_);
|
||||||
|
}
|
||||||
|
ObCastCtx cast_ctx(&eval_ctx_.exec_ctx_.get_allocator(), &dtc_params, cm_, dst_expr->obj_meta_.get_collation_type(), &dst_accuracy);
|
||||||
cast_ctx.exec_ctx_ = &eval_ctx_.exec_ctx_;
|
cast_ctx.exec_ctx_ = &eval_ctx_.exec_ctx_;
|
||||||
if (OB_FAIL(ObObjCaster::to_type(dst_type, dst_expr->obj_meta_.get_collation_type(), cast_ctx,
|
if (OB_FAIL(ObObjCaster::to_type(dst_type, dst_expr->obj_meta_.get_collation_type(), cast_ctx,
|
||||||
src_obj, dst_obj))) {
|
src_obj, dst_obj))) {
|
||||||
|
@ -95,6 +95,7 @@ int ObPlanCacheObject::set_params_info(const ParamStore ¶ms)
|
|||||||
} else {
|
} else {
|
||||||
param_info.ext_real_type_ = data_type.get_obj_type();
|
param_info.ext_real_type_ = data_type.get_obj_type();
|
||||||
param_info.scale_ = data_type.get_scale();
|
param_info.scale_ = data_type.get_scale();
|
||||||
|
param_info.precision_ = data_type.get_precision();
|
||||||
}
|
}
|
||||||
LOG_DEBUG("ext params info", K(data_type), K(param_info), K(params.at(i)));
|
LOG_DEBUG("ext params info", K(data_type), K(param_info), K(params.at(i)));
|
||||||
} else if (params.at(i).get_param_meta().is_ext() || params.at(i).is_user_defined_sql_type() || params.at(i).is_collection_sql_type()) {
|
} else if (params.at(i).get_param_meta().is_ext() || params.at(i).is_user_defined_sql_type() || params.at(i).is_collection_sql_type()) {
|
||||||
|
@ -272,6 +272,10 @@ int ObPlanSet::match_param_info(const ObParamInfo ¶m_info,
|
|||||||
// do nothing
|
// do nothing
|
||||||
} else if (OB_FAIL(ObSQLUtils::get_ext_obj_data_type(param, data_type))) {
|
} else if (OB_FAIL(ObSQLUtils::get_ext_obj_data_type(param, data_type))) {
|
||||||
LOG_WARN("fail to get obj data_type", K(ret), K(param));
|
LOG_WARN("fail to get obj data_type", K(ret), K(param));
|
||||||
|
} else if (data_type.get_obj_type() == ObDecimalIntType) {
|
||||||
|
is_same = param_info.ext_real_type_ == ObDecimalIntType
|
||||||
|
&& data_type.get_scale() == param_info.scale_
|
||||||
|
&& match_decint_precision(param_info, data_type.get_precision());
|
||||||
} else if (data_type.get_scale() == param_info.scale_ &&
|
} else if (data_type.get_scale() == param_info.scale_ &&
|
||||||
data_type.get_obj_type() == param_info.ext_real_type_) {
|
data_type.get_obj_type() == param_info.ext_real_type_) {
|
||||||
is_same = true;
|
is_same = true;
|
||||||
@ -2469,6 +2473,9 @@ bool ObPlanSet::match_decint_precision(const ObParamInfo ¶m_info, ObPrecisio
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (ob_is_decimal_int(param_info.type_)) {
|
if (ob_is_decimal_int(param_info.type_)) {
|
||||||
ret = (param_info.precision_ == other_prec);
|
ret = (param_info.precision_ == other_prec);
|
||||||
|
} else if (ob_is_extend(param_info.type_) && ob_is_decimal_int(param_info.ext_real_type_)) {
|
||||||
|
ret = wide::ObDecimalIntConstValue::get_int_bytes_by_precision(param_info.precision_)
|
||||||
|
== wide::ObDecimalIntConstValue::get_int_bytes_by_precision(other_prec);
|
||||||
} else {
|
} else {
|
||||||
// not decimal_int, return true
|
// not decimal_int, return true
|
||||||
ret = true;
|
ret = true;
|
||||||
|
@ -171,9 +171,15 @@ int ObInListResolver::check_inlist_rewrite_enable(const ParseNode &in_list,
|
|||||||
if (OB_ISNULL(session_info)) {
|
if (OB_ISNULL(session_info)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("get unexpected null", K(ret), KP(session_info));
|
LOG_WARN("get unexpected null", K(ret), KP(session_info));
|
||||||
} else if (T_WHERE_SCOPE != scope || !is_root_condition || T_OP_IN != op_type ||
|
} else if (T_WHERE_SCOPE != scope
|
||||||
T_EXPR_LIST != in_list.type_ || is_need_print || session_info->is_varparams_sql_prepare() ||
|
|| !is_root_condition
|
||||||
(NULL != stmt && stmt->is_select_stmt() && static_cast<const ObSelectStmt *>(stmt)->is_hierarchical_query())) {
|
|| (T_OP_IN != op_type && T_OP_NOT_IN != op_type)
|
||||||
|
|| T_EXPR_LIST != in_list.type_
|
||||||
|
|| is_need_print
|
||||||
|
|| session_info->is_varparams_sql_prepare()
|
||||||
|
|| (NULL != stmt
|
||||||
|
&& stmt->is_select_stmt()
|
||||||
|
&& static_cast<const ObSelectStmt *>(stmt)->is_hierarchical_query())) {
|
||||||
LOG_TRACE("no need rewrite inlist", K(is_root_condition), K(scope), K(in_list.type_),
|
LOG_TRACE("no need rewrite inlist", K(is_root_condition), K(scope), K(in_list.type_),
|
||||||
K(op_type), K(is_need_print), K(session_info->is_varparams_sql_prepare()));
|
K(op_type), K(is_need_print), K(session_info->is_varparams_sql_prepare()));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user