From 8f7ed1a53f58f88da4600b8f8327f8c600bac324 Mon Sep 17 00:00:00 2001 From: skylhd Date: Fri, 15 Sep 2023 10:40:41 +0000 Subject: [PATCH] [BUGFIX] fix repeat/space expr compat --- src/sql/engine/expr/ob_expr_repeat.cpp | 6 +++++- src/sql/engine/expr/ob_expr_space.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sql/engine/expr/ob_expr_repeat.cpp b/src/sql/engine/expr/ob_expr_repeat.cpp index 6e11c3170..970ac1ecc 100644 --- a/src/sql/engine/expr/ob_expr_repeat.cpp +++ b/src/sql/engine/expr/ob_expr_repeat.cpp @@ -46,7 +46,11 @@ int ObExprRepeat::calc_result_type2(ObExprResType &type, ObExprTypeCtx &type_ctx) const { int ret = OB_SUCCESS; - if (!ob_is_text_tc(text.get_type()) && !text.is_null()) { + if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_2_0_0) { + if (!text.is_string_type()) { + text.set_calc_type(common::ObVarcharType); + } + } else if (!ob_is_text_tc(text.get_type()) && !text.is_null()) { text.set_calc_type(common::ObVarcharType); } if (!count.is_null()) { diff --git a/src/sql/engine/expr/ob_expr_space.cpp b/src/sql/engine/expr/ob_expr_space.cpp index 3c0de8351..bc6849fae 100644 --- a/src/sql/engine/expr/ob_expr_space.cpp +++ b/src/sql/engine/expr/ob_expr_space.cpp @@ -37,7 +37,7 @@ inline int ObExprSpace::calc_result_type1( // space is mysql only expr CK(lib::is_mysql_mode()); ObObjType res_type = ObMaxType; - if (type1.is_null()) { + if (type1.is_null() || (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_2_0_0)) { res_type = ObVarcharType; } else if (type1.is_literal()) { const ObObj &obj = type1.get_param(); @@ -63,7 +63,11 @@ inline int ObExprSpace::calc_result_type1( type.set_collation_level(type1.get_collation_level()); type.set_collation_type(get_default_collation_type(type.get_type(), *type_ctx.get_session())); if (ObVarcharType == type.get_type()) { - type.set_length(MAX_CHAR_LENGTH_FOR_VARCAHR_RESULT); + if (GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_2_0_0) { + type.set_length(OB_MAX_VARCHAR_LENGTH); + } else { + type.set_length(MAX_CHAR_LENGTH_FOR_VARCAHR_RESULT); + } } else if (ob_is_text_tc(type.get_type())) { const int32_t mbmaxlen = 4; const int32_t default_text_length =