diff --git a/deps/oblib/src/lib/string/ob_string.h b/deps/oblib/src/lib/string/ob_string.h index 7121543135c21411c6e901ee90da8a2d4a736599..2a54c4e7cd64a3ca5d65de49020c50b56b9dfb1c 100644 --- a/deps/oblib/src/lib/string/ob_string.h +++ b/deps/oblib/src/lib/string/ob_string.h @@ -425,6 +425,23 @@ public: return ret; } + const ObString trim_space_only() + { + ObString ret; + if (NULL != ptr_) { + char *start = ptr_; + char *end = ptr_ + data_length_; + while (start < end && ' ' == *start) { + start++; + } + while (start < end && ' ' == *(end - 1)) { + end--; + } + ret.assign_ptr(start, static_cast(end - start)); + } + return ret; + } + static ObString make_string(const char* cstr) { return NULL == cstr ? ObString() : ObString(0, static_cast(strlen(cstr)), const_cast(cstr)); diff --git a/src/share/system_variable/ob_system_variable.cpp b/src/share/system_variable/ob_system_variable.cpp index 02c9c5cabd0bb75c9b2a76e11e0034f1ba3d7b20..f88b580dcac4546216332f5bac0fa5f2187241d5 100644 --- a/src/share/system_variable/ob_system_variable.cpp +++ b/src/share/system_variable/ob_system_variable.cpp @@ -1457,11 +1457,12 @@ int ObSqlModeVar::do_check_and_convert(ObExecContext& ctx, const ObSetVar& set_v ret = OB_ERR_UNEXPECTED; LOG_ERROR("unexpected type", K(ret), K(in_val)); } + ObString val_without_space = str_val.trim_space_only(); if (OB_FAIL(ret)) { - } else if (OB_FAIL(find_set(str_val))) { - LOG_WARN("fail to find type", K(ret), K(str_val), K(in_val)); - } else if (OB_FAIL(ob_str_to_sql_mode(str_val, sql_mode))) { - LOG_WARN("fail to convert str to sql mode", K(ret), K(str_val), K(in_val)); + } else if (OB_FAIL(find_set(val_without_space))) { + LOG_WARN("fail to find type", K(ret), K(val_without_space), K(in_val)); + } else if (OB_FAIL(ob_str_to_sql_mode(val_without_space, sql_mode))) { + LOG_WARN("fail to convert str to sql mode", K(ret), K(val_without_space), K(in_val)); } } else if (ob_is_int_tc(in_val.get_type())) { int64_t int64_val = 0;