Fix substr result type in mixing run of different versions of observer

This commit is contained in:
obdev 2023-09-01 15:14:24 +00:00 committed by ob-robot
parent 0b8f0353c5
commit 38cdda42f8

View File

@ -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) {