提交 c1e01ea7 编写于 作者: O obdev 提交者: wangzelin.wzl

[CP] Remove extra space in sql_mode

上级 609e9704
...@@ -425,6 +425,23 @@ public: ...@@ -425,6 +425,23 @@ public:
return ret; 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<obstr_size_t>(end - start));
}
return ret;
}
static ObString make_string(const char* cstr) static ObString make_string(const char* cstr)
{ {
return NULL == cstr ? ObString() : ObString(0, static_cast<obstr_size_t>(strlen(cstr)), const_cast<char*>(cstr)); return NULL == cstr ? ObString() : ObString(0, static_cast<obstr_size_t>(strlen(cstr)), const_cast<char*>(cstr));
......
...@@ -1457,11 +1457,12 @@ int ObSqlModeVar::do_check_and_convert(ObExecContext& ctx, const ObSetVar& set_v ...@@ -1457,11 +1457,12 @@ int ObSqlModeVar::do_check_and_convert(ObExecContext& ctx, const ObSetVar& set_v
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_ERROR("unexpected type", K(ret), K(in_val)); LOG_ERROR("unexpected type", K(ret), K(in_val));
} }
ObString val_without_space = str_val.trim_space_only();
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
} else if (OB_FAIL(find_set(str_val))) { } else if (OB_FAIL(find_set(val_without_space))) {
LOG_WARN("fail to find type", K(ret), K(str_val), K(in_val)); LOG_WARN("fail to find type", K(ret), K(val_without_space), K(in_val));
} else if (OB_FAIL(ob_str_to_sql_mode(str_val, sql_mode))) { } 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(str_val), K(in_val)); 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())) { } else if (ob_is_int_tc(in_val.get_type())) {
int64_t int64_val = 0; int64_t int64_val = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册