Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
上島
soar
提交
cb63ad79
S
soar
项目概览
上島
/
soar
与 Fork 源项目一致
Fork自
Xiaomi / soar
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
soar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cb63ad79
编写于
5月 17, 2021
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update soar ARG.003 check rules
string -> int can use index
上级
54e106ca
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
12 addition
and
6 deletion
+12
-6
advisor/heuristic.go
advisor/heuristic.go
+4
-1
advisor/index_test.go
advisor/index_test.go
+8
-5
未找到文件。
advisor/heuristic.go
浏览文件 @
cb63ad79
...
...
@@ -261,7 +261,8 @@ func (idxAdv *IndexAdvisor) RuleImplicitConversion() Rule {
common
.
Log
.
Debug
(
"DataType: `%s`.`%s` (%s) VS `%s`.`%s` (%s)"
,
colList
[
0
]
.
Table
,
colList
[
0
]
.
Name
,
type1
,
colList
[
1
]
.
Table
,
colList
[
1
]
.
Name
,
type2
)
if
strings
.
ToLower
(
type1
)
!=
strings
.
ToLower
(
type2
)
{
// case-insensitive check type1, type2
if
!
strings
.
EqualFold
(
type1
,
type2
)
{
content
=
append
(
content
,
fmt
.
Sprintf
(
"`%s`.`%s` (%s) VS `%s`.`%s` (%s) datatype not match"
,
colList
[
0
]
.
Table
,
colList
[
0
]
.
Name
,
type1
,
colList
[
1
]
.
Table
,
colList
[
1
]
.
Name
,
type2
))
...
...
@@ -296,6 +297,8 @@ func (idxAdv *IndexAdvisor) RuleImplicitConversion() Rule {
sqlparser
.
StrVal
:
{
"char"
,
"varchar"
,
"tinytext"
,
"text"
,
"mediumtext"
,
"longtext"
,
"date"
,
"time"
,
"datetime"
,
"timestamp"
,
"year"
,
"tinyint"
,
"smallint"
,
"mediumint"
,
"int"
,
"integer"
,
"bigint"
,
"float"
,
"double"
,
"real"
,
"decimal"
,
},
sqlparser
.
IntVal
:
{
"tinyint"
,
"smallint"
,
"mediumint"
,
"int"
,
"integer"
,
"bigint"
,
...
...
advisor/index_test.go
浏览文件 @
cb63ad79
...
...
@@ -83,6 +83,7 @@ func TestRuleImplicitConversion(t *testing.T) {
}
sqls
:=
[][]
string
{
// ARG.003
{
"SELECT * FROM t1 WHERE title >= 60;"
,
"SELECT * FROM t1, t2 WHERE t1.title = t2.title;"
,
...
...
@@ -90,11 +91,13 @@ func TestRuleImplicitConversion(t *testing.T) {
"SELECT * FROM t1 WHERE title in (60, '60');"
,
"SELECT * FROM t1 WHERE title in (60);"
,
"SELECT * FROM t1 WHERE title in (60, 60);"
,
"SELECT * FROM t
4 WHERE col = '1'
"
,
"SELECT * FROM t
1 WHERE title = 1
"
,
},
// OK
{
// https://github.com/XiaoMi/soar/issues/151
"SELECT * FROM t4 WHERE col = 1"
,
"SELECT * FROM t1 WHERE id = '1'"
,
// string -> int can use index
"SELECT * FROM t1 WHERE id = 1"
,
"SELECT * FROM t4 WHERE col = 1"
,
// https://github.com/XiaoMi/soar/issues/151
"SELECT * FROM sakila.film WHERE rental_rate > 1"
,
},
}
...
...
@@ -114,7 +117,7 @@ func TestRuleImplicitConversion(t *testing.T) {
if
idxAdvisor
!=
nil
{
rule
:=
idxAdvisor
.
RuleImplicitConversion
()
if
rule
.
Item
!=
"ARG.003"
{
t
.
Error
(
"Rule not match:"
,
rule
,
"Expect : ARG.003, SQL:"
,
sql
)
t
.
Error
(
"Rule not match:"
,
rule
.
Item
,
"Expect : ARG.003, SQL:"
,
sql
)
}
}
}
...
...
@@ -134,7 +137,7 @@ func TestRuleImplicitConversion(t *testing.T) {
if
idxAdvisor
!=
nil
{
rule
:=
idxAdvisor
.
RuleImplicitConversion
()
if
rule
.
Item
!=
"OK"
{
t
.
Error
(
"Rule not match:"
,
rule
,
"Expect : OK, SQL:"
,
sql
)
t
.
Error
(
"Rule not match:"
,
rule
.
Item
,
"Expect : OK, SQL:"
,
sql
)
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录