Fix expr calc accuracy reuse during type deduce

This commit is contained in:
hezuojiao
2024-02-08 16:26:25 +00:00
committed by ob-robot
parent ba7c8e7351
commit 5ca81e3013
7 changed files with 122 additions and 118 deletions

View File

@ -373,6 +373,10 @@ int ObRawExprDeduceType::push_back_types(const ObRawExpr *param_expr, ObExprResT
const ObPrecision prec = MAX(types.at(idx).get_precision(), max_prec);
types.at(idx).set_precision(prec);
types.at(idx).set_scale(0);
} else if (is_mysql_mode && ob_is_decimal_int_tc(types.at(idx).get_type())) {
// for decimal int type in mysql, reset calc accuracy to itself to avoid accuracy reuse
// during type deduce
types.at(idx).set_calc_accuracy(types.at(idx).get_accuracy());
} else if (!is_mysql_mode && (is_ddl_stmt || is_show_stmt) && types.at(idx).is_decimal_int()
&& param_expr->is_column_ref_expr()) {
// If c1 and c2 are both ObDecimalIntType columns, result type of c1 + c2 is ObDecimalIntType.