未验证 提交 21564ec6 编写于 作者: Y yu34po 提交者: GitHub

fix charset (#736)

上级 e5f59ea0
......@@ -4380,6 +4380,15 @@ BINARY opt_string_length_i_v2
$$->int32_values_[OB_NODE_CAST_C_LEN_IDX] = $2[0]; /* length */
$$->param_num_ = $2[1];
}
| CHARACTER opt_string_length_i_v2 CHARACTER SET charset_name
{
malloc_terminal_node($$, result->malloc_pool_, T_CAST_ARGUMENT);
$$->value_ = 0;
$$->int16_values_[OB_NODE_CAST_TYPE_IDX] = T_CHAR; /* data type */
$$->param_num_ = $2[1];
$$->str_value_ = $5->str_value_;
$$->str_len_ = $5->str_len_;
}
| cast_datetime_type_i opt_datetime_fsp_i
{
malloc_terminal_node($$, result->malloc_pool_, T_CAST_ARGUMENT);
......@@ -14577,4 +14586,4 @@ int obsql_mysql_fast_parse(ParseResult *p)
p->no_param_sql_[len] = '\0';
}
return ret;
}
\ No newline at end of file
}
......@@ -318,8 +318,23 @@ int ObRawExprResolverImpl::do_recursive_resolve(const ParseNode* node, ObRawExpr
} else if (ob_is_extend(data_type)) {
ret = OB_NOT_SUPPORTED;
}
if (OB_SUCC(ret)) {
val.set_int(node->value_);
if (node->str_value_) {
ObString cs_name = ObString(node->str_value_);
ObCharsetType charset_type = CHARSET_INVALID;
if (CHARSET_INVALID == (charset_type = ObCharset::charset_type(cs_name.trim()))) {
ret = OB_ERR_UNKNOWN_CHARSET;
LOG_WARN("unknown charset", K(ret), K(cs_name));
} else {
ParseNode tmp_node;
tmp_node.value_ = node->value_;
tmp_node.int16_values_[OB_NODE_CAST_COLL_IDX] = ObCharset::get_default_collation(charset_type);
val.set_int(tmp_node.value_);
}
} else {
val.set_int(node->value_);
}
c_expr->set_value(val);
c_expr->set_param(val);
expr = c_expr;
......
......@@ -501,4 +501,10 @@ utf8mb4_bin
select collation(cast('A' as char)), cast('A' as char) < 'a';
collation(cast('A' as char)) cast('A' as char) < 'a'
utf8mb4_bin 1
SELECT collation(CAST('A' AS char CHAR SET utf8mb4));
collation(CAST('A' AS char CHAR SET utf8mb4))
utf8mb4_general_ci
SELECT collation(CAST('A' AS char CHAR SET binary));
collation(CAST('A' AS char CHAR SET binary))
binary
drop table coll_test;
......@@ -247,6 +247,10 @@ select collation(cast(1 as char));
SELECT collation(DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y'));
select collation(cast('A' as char)), cast('A' as char) < 'a';
#set utf8 binary collation set
SELECT collation(CAST('A' AS char CHAR SET utf8mb4));
SELECT collation(CAST('A' AS char CHAR SET binary));
################################################################
# tear-down
drop table coll_test;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册