fix add cast check bug

This commit is contained in:
obdev
2023-10-19 02:39:18 +00:00
committed by ob-robot
parent 91c8fb0b92
commit 17bc8d4e1d
2 changed files with 5 additions and 4 deletions

View File

@ -119,7 +119,7 @@ int ObStmtExprVisitor::visit(T *&expr,
(!std::is_same<T, ObRawExpr>::value &&
OB_UNLIKELY(tmp->get_expr_class() != expr->get_expr_class()))) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(WARN, "expr class is changed", KPC(tmp), KPC(expr));
SQL_RESV_LOG(WARN, "expr class is changed", K(tmp->get_expr_class()), K(expr->get_expr_class()));
}
}
return ret;
@ -142,7 +142,7 @@ int ObStmtExprVisitor::visit(common::ObIArray<T *> &exprs,
(!std::is_same<T, ObRawExpr>::value &&
OB_UNLIKELY(tmp->get_expr_class() != exprs.at(i)->get_expr_class()))) {
ret = OB_ERR_UNEXPECTED;
SQL_RESV_LOG(WARN, "expr class is changed", KPC(tmp), KPC(exprs.at(i)));
SQL_RESV_LOG(WARN, "expr class is changed", K(tmp->get_expr_class()), K(exprs.at(i)->get_expr_class()));
}
}
}

View File

@ -4348,11 +4348,12 @@ int ObTransformUtils::add_cast_for_replace_if_need(ObRawExprFactory &expr_factor
const ObExprResType &dst_type = to_expr->get_result_type();
bool need_length_cast = (ob_is_string_or_lob_type(dst_type.get_type()) || ob_is_rowid_tc(dst_type.get_type()))
? (src_type.get_length() != dst_type.get_length()) : false;
bool need_zerofill_cast = from_expr->get_result_type().has_result_flag(ZEROFILL_FLAG) &&
!to_expr->get_result_type().has_result_flag(ZEROFILL_FLAG);
bool need_cast = (src_type.get_type() != dst_type.get_type()) ||
(src_type.get_precision() != dst_type.get_precision()) ||
(src_type.get_scale() != dst_type.get_scale()) ||
from_expr->get_result_type().has_result_flag(ZEROFILL_FLAG) ||
need_length_cast;
need_zerofill_cast || need_length_cast;
if (ob_is_string_or_lob_type(src_type.get_type())) {
need_cast |= (src_type.get_collation_type() != dst_type.get_collation_type()) ||
(src_type.get_collation_level() != dst_type.get_collation_level());