From fc3e6e947b0d8de48df394276e650a63a07bcc6e Mon Sep 17 00:00:00 2001 From: obdev Date: Fri, 22 Jul 2022 10:44:45 +0800 Subject: [PATCH] [CP] Repair type conversion range check of year to tinyint or utinyint --- src/sql/engine/expr/ob_datum_cast.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sql/engine/expr/ob_datum_cast.cpp b/src/sql/engine/expr/ob_datum_cast.cpp index d1401bc6a1..1d2745545f 100644 --- a/src/sql/engine/expr/ob_datum_cast.cpp +++ b/src/sql/engine/expr/ob_datum_cast.cpp @@ -3478,7 +3478,8 @@ CAST_FUNC_NAME(year, int) { uint8_t in_val = child_res->get_uint8(); int64_t out_val = 0; - if (OB_FAIL(common_year_int(expr, ObIntType, in_val, out_val))) { + ObObjType out_type = expr.datum_meta_.type_; + if (OB_FAIL(common_year_int(expr, out_type, in_val, out_val))) { LOG_WARN("common_year_int failed", K(ret)); } else { res_datum.set_int(out_val); @@ -3498,7 +3499,7 @@ CAST_FUNC_NAME(year, uint) LOG_WARN("year_to_int failed", K(ret)); } else { out_val = static_cast(val_int); - if (out_type < ObSmallIntType && CAST_FAIL(uint_range_check(out_type, val_int, out_val))) { + if (out_type < ObUSmallIntType && CAST_FAIL(uint_range_check(out_type, val_int, out_val))) { LOG_WARN("uint_range_check failed", K(ret)); } else { res_datum.set_uint(out_val);