Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
25d104df
O
oceanbase
项目概览
大炮V587
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
25d104df
编写于
3月 15, 2023
作者:
A
akaError
提交者:
ob-robot
3月 15, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix regexp expr bug: should consider collations of input params
上级
e9bec81a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
112 addition
and
31 deletion
+112
-31
src/sql/engine/expr/ob_expr_regexp.cpp
src/sql/engine/expr/ob_expr_regexp.cpp
+38
-30
tools/deploy/mysql_test/test_suite/expr/r/mysql/func_regexp.result
...loy/mysql_test/test_suite/expr/r/mysql/func_regexp.result
+46
-0
tools/deploy/mysql_test/test_suite/expr/t/func_regexp.test
tools/deploy/mysql_test/test_suite/expr/t/func_regexp.test
+28
-1
未找到文件。
src/sql/engine/expr/ob_expr_regexp.cpp
浏览文件 @
25d104df
...
...
@@ -66,43 +66,51 @@ int ObExprRegexp::calc_result_type2(ObExprResType &type,
{
int
ret
=
OB_SUCCESS
;
ObRawExpr
*
raw_expr
=
type_ctx
.
get_raw_expr
();
ObCollationType
res_cs_type
=
CS_TYPE_INVALID
;
ObCollationLevel
res_cs_level
=
CS_LEVEL_INVALID
;
CK
(
NULL
!=
type_ctx
.
get_raw_expr
());
if
(
type1
.
is_null
()
||
type2
.
is_null
())
{
type
.
set_int32
();
type
.
set_precision
(
DEFAULT_PRECISION_FOR_BOOL
);
type
.
set_scale
(
DEFAULT_SCALE_FOR_INTEGER
);
}
else
if
(
OB_UNLIKELY
(
!
is_type_valid
(
type1
.
get_type
())
||
!
is_type_valid
(
type2
.
get_type
())))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"the param is not castable"
,
K
(
ret
),
K
(
type1
),
K
(
type2
));
}
else
if
(
OB_FAIL
(
ObCharset
::
aggregate_collation
(
type1
.
get_calc_collation_level
(),
type1
.
get_calc_collation_type
(),
type2
.
get_calc_collation_level
(),
type2
.
get_calc_collation_type
(),
res_cs_level
,
res_cs_type
)))
{
LOG_WARN
(
"fail to aggregate collation"
,
K
(
ret
),
K
(
type1
),
K
(
type2
));
}
else
{
if
(
OB_UNLIKELY
(
!
is_type_valid
(
type1
.
get_type
())
||
!
is_type_valid
(
type2
.
get_type
())))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"the param is not castable"
,
K
(
ret
),
K
(
type1
),
K
(
type2
));
type
.
set_int32
();
type
.
set_precision
(
DEFAULT_PRECISION_FOR_BOOL
);
type
.
set_scale
(
DEFAULT_SCALE_FOR_INTEGER
);
//why we set the calc collation type is utf16, because the ICU regexp engine is used uft16,
//we need convert it the need collation in advance, and no need to think about in regexp.
bool
is_case_sensitive
=
ObCharset
::
is_bin_sort
(
res_cs_type
);
bool
need_utf8
=
false
;
type1
.
set_calc_type
(
ObVarcharType
);
type1
.
set_calc_collation_level
(
type
.
get_collation_level
());
type2
.
set_calc_type
(
ObVarcharType
);
type2
.
set_calc_collation_level
(
type
.
get_collation_level
());
if
(
OB_FAIL
(
ObExprRegexContext
::
check_need_utf8
(
raw_expr
->
get_param_expr
(
1
),
need_utf8
)))
{
LOG_WARN
(
"fail to check need utf8"
,
K
(
ret
));
}
else
if
(
need_utf8
)
{
type2
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF8MB4_BIN
:
CS_TYPE_UTF8MB4_GENERAL_CI
);
}
else
{
type
.
set_int32
();
type
.
set_precision
(
DEFAULT_PRECISION_FOR_BOOL
);
type
.
set_scale
(
DEFAULT_SCALE_FOR_INTEGER
);
//why we set the calc collation type is utf16, because the ICU regexp engine is used uft16,
//we need convert it the need collation in advance, and no need to think about in regexp.
bool
is_case_sensitive
=
ObCharset
::
is_bin_sort
(
type1
.
get_calc_collation_type
());
bool
need_utf8
=
false
;
type1
.
set_calc_type
(
ObVarcharType
);
type1
.
set_calc_collation_level
(
type
.
get_collation_level
());
type2
.
set_calc_type
(
ObVarcharType
);
type2
.
set_calc_collation_level
(
type
.
get_collation_level
());
if
(
OB_FAIL
(
ObExprRegexContext
::
check_need_utf8
(
raw_expr
->
get_param_expr
(
1
),
need_utf8
)))
{
LOG_WARN
(
"fail to check need utf8"
,
K
(
ret
));
}
else
if
(
need_utf8
)
{
type2
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF8MB4_BIN
:
CS_TYPE_UTF8MB4_GENERAL_CI
);
}
else
{
type2
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF16_BIN
:
CS_TYPE_UTF16_GENERAL_CI
);
}
need_utf8
=
false
;
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
OB_FAIL
(
ObExprRegexContext
::
check_need_utf8
(
raw_expr
->
get_param_expr
(
0
),
need_utf8
)))
{
LOG_WARN
(
"fail to check need utf8"
,
K
(
ret
));
}
else
if
(
need_utf8
)
{
type1
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF8MB4_BIN
:
CS_TYPE_UTF8MB4_GENERAL_CI
);
}
else
{
type1
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF16_BIN
:
CS_TYPE_UTF16_GENERAL_CI
);
}
type2
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF16_BIN
:
CS_TYPE_UTF16_GENERAL_CI
);
}
need_utf8
=
false
;
if
(
OB_FAIL
(
ret
))
{
}
else
if
(
OB_FAIL
(
ObExprRegexContext
::
check_need_utf8
(
raw_expr
->
get_param_expr
(
0
),
need_utf8
)))
{
LOG_WARN
(
"fail to check need utf8"
,
K
(
ret
));
}
else
if
(
need_utf8
)
{
type1
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF8MB4_BIN
:
CS_TYPE_UTF8MB4_GENERAL_CI
);
}
else
{
type1
.
set_calc_collation_type
(
is_case_sensitive
?
CS_TYPE_UTF16_BIN
:
CS_TYPE_UTF16_GENERAL_CI
);
}
}
return
ret
;
...
...
tools/deploy/mysql_test/test_suite/expr/r/mysql/func_regexp.result
浏览文件 @
25d104df
...
...
@@ -6328,3 +6328,49 @@ select * from t1 where c1 regexp '^U';
c1
UNPRESS123
UNPRESS456
set names gbk;
select 'a' collate gbk_bin regexp 'A';
'a' collate gbk_bin regexp 'A'
0
select 'a' collate gbk_chinese_ci regexp 'A';
'a' collate gbk_chinese_ci regexp 'A'
1
select 'a' regexp 'A' collate gbk_chinese_ci;
'a' regexp 'A' collate gbk_chinese_ci
1
select 'a' regexp 'A' collate gbk_bin;
'a' regexp 'A' collate gbk_bin
0
select 'a' collate gbk_bin regexp 'A' collate gbk_bin;
'a' collate gbk_bin regexp 'A' collate gbk_bin
0
select 'a' collate gbk_chinese_ci regexp 'A' collate gbk_chinese_ci;
'a' collate gbk_chinese_ci regexp 'A' collate gbk_chinese_ci
1
select 'a' collate gbk_bin regexp 'A' collate gbk_chinese_ci;
ERROR HY000: Illegal mix of collations
select 'a' collate gbk_chinese_ci regexp 'A' collate gbk_bin;
ERROR HY000: Illegal mix of collations
set names latin1;
select 'a' collate latin1_bin regexp 'A';
'a' collate latin1_bin regexp 'A'
0
select 'a' collate latin1_swedish_ci regexp 'A';
'a' collate latin1_swedish_ci regexp 'A'
1
select 'a' regexp 'A' collate latin1_swedish_ci;
'a' regexp 'A' collate latin1_swedish_ci
1
select 'a' regexp 'A' collate latin1_bin;
'a' regexp 'A' collate latin1_bin
0
select 'a' collate latin1_bin regexp 'A' collate latin1_bin;
'a' collate latin1_bin regexp 'A' collate latin1_bin
0
select 'a' collate latin1_swedish_ci regexp 'A' collate latin1_swedish_ci;
'a' collate latin1_swedish_ci regexp 'A' collate latin1_swedish_ci
1
select 'a' collate latin1_bin regexp 'A' collate latin1_swedish_ci;
ERROR HY000: Illegal mix of collations
select 'a' collate latin1_swedish_ci regexp 'A' collate latin1_bin;
ERROR HY000: Illegal mix of collations
tools/deploy/mysql_test/test_suite/expr/t/func_regexp.test
浏览文件 @
25d104df
...
...
@@ -454,4 +454,31 @@ drop table if exists t1;
create
table
t1
(
c1
blob
);
insert
into
t1
values
(
'UNPRESS123'
);
insert
into
t1
values
(
'UNPRESS456'
);
select
*
from
t1
where
c1
regexp
'^U'
;
\ No newline at end of file
select
*
from
t1
where
c1
regexp
'^U'
;
##bug48378677
set
names
gbk
;
select
'a'
collate
gbk_bin
regexp
'A'
;
select
'a'
collate
gbk_chinese_ci
regexp
'A'
;
select
'a'
regexp
'A'
collate
gbk_chinese_ci
;
select
'a'
regexp
'A'
collate
gbk_bin
;
select
'a'
collate
gbk_bin
regexp
'A'
collate
gbk_bin
;
select
'a'
collate
gbk_chinese_ci
regexp
'A'
collate
gbk_chinese_ci
;
--
error
1267
select
'a'
collate
gbk_bin
regexp
'A'
collate
gbk_chinese_ci
;
--
error
1267
select
'a'
collate
gbk_chinese_ci
regexp
'A'
collate
gbk_bin
;
set
names
latin1
;
select
'a'
collate
latin1_bin
regexp
'A'
;
select
'a'
collate
latin1_swedish_ci
regexp
'A'
;
select
'a'
regexp
'A'
collate
latin1_swedish_ci
;
select
'a'
regexp
'A'
collate
latin1_bin
;
select
'a'
collate
latin1_bin
regexp
'A'
collate
latin1_bin
;
select
'a'
collate
latin1_swedish_ci
regexp
'A'
collate
latin1_swedish_ci
;
--
error
1267
select
'a'
collate
latin1_bin
regexp
'A'
collate
latin1_swedish_ci
;
--
error
1267
select
'a'
collate
latin1_swedish_ci
regexp
'A'
collate
latin1_bin
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录