diff --git a/src/sql/engine/expr/ob_expr_substr.cpp b/src/sql/engine/expr/ob_expr_substr.cpp index f82704280..3c29f0189 100644 --- a/src/sql/engine/expr/ob_expr_substr.cpp +++ b/src/sql/engine/expr/ob_expr_substr.cpp @@ -234,7 +234,11 @@ int ObExprSubstr::calc_result_typeN(ObExprResType &type, if (OB_SUCC(ret) && ob_is_text_tc(type.get_type()) && 3 == param_num - && !types_array[2].get_param().is_null()) { + && !types_array[2].get_param().is_null() + // Compatible with mixing running different versions of observer, the result type is + // varchar only when all observer versions are higher than 4.2.0, otherwise is blob, + // which is not compatible with mysql + && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_0_0) { const ObObj &len_obj = types_array[2].get_param(); int64_t substr_len = len_obj.is_int() ? len_obj.get_int() : 0; if (substr_len > 0 && substr_len <= OB_MAX_CAST_CHAR_VARCHAR_LENGTH) {