From f2f2aed95cce285df8729aa8d7b904494ac2b89a Mon Sep 17 00:00:00 2001 From: br0 Date: Thu, 11 Nov 2021 19:49:10 +0800 Subject: [PATCH] Fix cast mode bug when cast string to int explicitly --- src/sql/engine/expr/ob_expr_cast.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sql/engine/expr/ob_expr_cast.cpp b/src/sql/engine/expr/ob_expr_cast.cpp index 424f4bd040..d70069dbd7 100644 --- a/src/sql/engine/expr/ob_expr_cast.cpp +++ b/src/sql/engine/expr/ob_expr_cast.cpp @@ -505,6 +505,10 @@ int ObExprCast::calc_result2(ObObj& result, const ObObj& obj1, const ObObj& obj2 } LOG_DEBUG("get accuracy from result_type", K(src_type), K(dest_type), K(accuracy), K(result_type_)); ObCastMode cast_mode = CM_EXPLICIT_CAST; + if (share::is_mysql_mode() && ob_is_string_type(src_type) && + ((ob_is_int_tc(dest_type)) || ob_is_uint_tc(dest_type))) { + cast_mode |= CM_STRING_INTEGER_TRUNC; + } if (ObDateTimeTC == dest_tc || ObDateTC == dest_tc || ObTimeTC == dest_tc) { cast_mode |= CM_NULL_ON_WARN; } else if (ob_is_int_uint(src_tc, dest_tc)) { -- GitLab