Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硕大的木艮
soar
提交
407db8a0
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,发现更多精彩内容 >>
提交
407db8a0
编写于
12月 28, 2018
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test cases
上级
425106ed
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
74 addition
and
38 deletion
+74
-38
CHANGES.md
CHANGES.md
+3
-1
cmd/soar/soar_test.go
cmd/soar/soar_test.go
+2
-0
common/config.go
common/config.go
+1
-0
common/config_test.go
common/config_test.go
+1
-0
common/testdata/TestParseDSN.golden
common/testdata/TestParseDSN.golden
+51
-29
database/testdata/TestTrace.golden
database/testdata/TestTrace.golden
+3
-2
database/trace_test.go
database/trace_test.go
+9
-6
env/env_test.go
env/env_test.go
+2
-0
env/testdata/TestNewVirtualEnv.golden
env/testdata/TestNewVirtualEnv.golden
+2
-0
未找到文件。
CHANGES.md
浏览文件 @
407db8a0
...
...
@@ -8,12 +8,14 @@
-
command line dsn args support '@', '/', ':' in password
-
add new heuristic rule RES.009, "SELECT
*
FROM tbl WHERE col = col = 'abc'"
-
add new heuristic rule RuleColumnNotAllowType COL.018
-
add string escape function for security
-
fix #122 single table select
*
don't auto-complete table name
-
fix #171 support socket access type
-
fix #58 sampling not deal with NULL able string
-
fix #172 compatible with mysql 5.1, which explain has no Index_Comment column
-
fix #163 column.Tp may be nil, which may raise panic
-
fix #151 bit type not config as int, when two columns compare will give ARG.003 suggestion.
-
## 2018-11
-
add all third-party lib into vendor
...
...
cmd/soar/soar_test.go
浏览文件 @
407db8a0
...
...
@@ -47,6 +47,8 @@ func Test_Main(_ *testing.T) {
common
.
Log
.
Debug
(
"Entering function: %s"
,
common
.
GetFunctionName
())
common
.
Config
.
OnlineDSN
.
Disable
=
true
common
.
Config
.
LogLevel
=
0
common
.
Config
.
Query
=
"select * syntaxError"
main
()
common
.
Config
.
Query
=
"select * from film;alter table city add index idx_country_id(country_id);"
main
()
common
.
Log
.
Debug
(
"Exiting function: %s"
,
common
.
GetFunctionName
())
...
...
common/config.go
浏览文件 @
407db8a0
...
...
@@ -426,6 +426,7 @@ func parseDSN(odbc string, d *Dsn) *Dsn {
func
ParseDSN
(
odbc
string
,
d
*
Dsn
)
*
Dsn
{
cfg
,
err
:=
mysql
.
ParseDSN
(
odbc
)
if
err
!=
nil
{
Log
.
Warn
(
"go-sql-driver/mysql.ParseDSN Error: %s, DSN: %s, try to use old version parseDSN"
,
err
.
Error
(),
odbc
)
return
parseDSN
(
odbc
,
d
)
}
return
newDSN
(
cfg
)
...
...
common/config_test.go
浏览文件 @
407db8a0
...
...
@@ -94,6 +94,7 @@ func TestParseDSN(t *testing.T) {
"user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped"
,
"user:password@/dbname"
,
"user:password@/"
,
"user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s"
,
}
err
:=
GoldenDiff
(
func
()
{
...
...
common/testdata/TestParseDSN.golden
浏览文件 @
407db8a0
...
...
@@ -17,7 +17,7 @@
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@hostname:3307/database
...
...
@@ -39,7 +39,7 @@ user:password@hostname:3307/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@hostname:3307/database?charset=utf8
...
...
@@ -61,7 +61,7 @@ user:password@hostname:3307/database?charset=utf8
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@hostname:3307
...
...
@@ -83,7 +83,7 @@ user:password@hostname:3307
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@hostname:/database
...
...
@@ -105,7 +105,7 @@ user:password@hostname:/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@:3307/database
...
...
@@ -127,7 +127,7 @@ user:password@:3307/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user@hostname/database
...
...
@@ -149,7 +149,7 @@ user@hostname/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:pwd:pwd@pwd/pwd@hostname/database
...
...
@@ -171,7 +171,7 @@ user:pwd:pwd@pwd/pwd@hostname/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@
...
...
@@ -193,7 +193,7 @@ user:password@
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
hostname:3307/database
...
...
@@ -215,7 +215,7 @@ hostname:3307/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
@hostname:3307/database
...
...
@@ -237,7 +237,7 @@ hostname:3307/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
@hostname
...
...
@@ -259,7 +259,7 @@ hostname:3307/database
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
hostname
...
...
@@ -281,7 +281,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
@/database
...
...
@@ -303,7 +303,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
@hostname:3307
...
...
@@ -325,7 +325,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
@:3307/database
...
...
@@ -347,7 +347,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
:3307/database
...
...
@@ -369,7 +369,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
/database
...
...
@@ -391,7 +391,7 @@ hostname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user@unix(/path/to/socket)/dbname
...
...
@@ -413,7 +413,7 @@ user@unix(/path/to/socket)/dbname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
...
...
@@ -435,7 +435,7 @@ root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
...
...
@@ -457,7 +457,7 @@ user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@/dbname?sql_mode=TRADITIONAL
...
...
@@ -479,7 +479,7 @@ user:password@/dbname?sql_mode=TRADITIONAL
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_unicode_ci
...
...
@@ -501,7 +501,7 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
id:password@tcp(your-amazonaws-uri.com:3306)/dbname
...
...
@@ -523,7 +523,7 @@ id:password@tcp(your-amazonaws-uri.com:3306)/dbname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user@cloudsql(project-id:instance-name)/dbname
...
...
@@ -545,7 +545,7 @@ user@cloudsql(project-id:instance-name)/dbname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user@cloudsql(project-id:regionname:instance-name)/dbname
...
...
@@ -567,7 +567,7 @@ user@cloudsql(project-id:regionname:instance-name)/dbname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped
...
...
@@ -589,7 +589,7 @@ user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@/dbname
...
...
@@ -611,7 +611,7 @@ user:password@/dbname
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable:
tru
e,
Disable:
fals
e,
Version: 99999,
}
user:password@/
...
...
@@ -633,6 +633,28 @@ user:password@/
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: true,
Disable: false,
Version: 99999,
}
user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s
&common.Dsn{
User: "user",
Password: "password",
Net: "tcp",
Addr: "localhost:3307",
Schema: "database",
Charset: "utf8",
Collation: "utf8_general_ci",
Loc: "UTC",
TLS: "",
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"charset":"utf8"},
Timeout: 5,
ReadTimeout: 0,
WriteTimeout: 0,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
Version: 99999,
}
database/testdata/TestTrace.golden
浏览文件 @
407db8a0
[]database.TraceRow{
select 1
[]database.TraceRow{
{Query:"explain select 1", Trace:"{\n \"steps\": [\n {\n \"join_preparation\": {\n \"select#\": 1,\n \"steps\": [\n {\n \"expanded_query\": \"/* select#1 */ select 1 AS `1`\"\n }\n ]\n }\n },\n {\n \"join_optimization\": {\n \"select#\": 1,\n \"steps\": [\n ]\n }\n },\n {\n \"join_explain\": {\n \"select#\": 1,\n \"steps\": [\n ]\n }\n }\n ]\n}", MissingBytesBeyondMaxMemSize:0, InsufficientPrivileges:0},
}
} nil
explain select 1 []database.TraceRow(nil) &errors.errorString{s:"no need trace"}
database/trace_test.go
浏览文件 @
407db8a0
...
...
@@ -26,13 +26,16 @@ import (
func
TestTrace
(
t
*
testing
.
T
)
{
common
.
Log
.
Debug
(
"Entering function: %s"
,
common
.
GetFunctionName
())
res
,
err
:=
connTest
.
Trace
(
"select 1"
)
if
err
!=
nil
{
t
.
Error
(
err
)
sqls
:=
[]
string
{
"select 1"
,
"explain select 1"
,
"show create table film"
,
}
err
=
common
.
GoldenDiff
(
func
()
{
pretty
.
Println
(
res
)
err
:=
common
.
GoldenDiff
(
func
()
{
for
_
,
sql
:=
range
sqls
{
res
,
err
:=
connTest
.
Trace
(
sql
)
pretty
.
Println
(
sql
,
res
,
err
)
}
},
t
.
Name
(),
update
)
if
err
!=
nil
{
t
.
Error
(
err
)
...
...
env/env_test.go
浏览文件 @
407db8a0
...
...
@@ -61,6 +61,8 @@ func TestMain(m *testing.M) {
func
TestNewVirtualEnv
(
t
*
testing
.
T
)
{
common
.
Log
.
Debug
(
"Entering function: %s"
,
common
.
GetFunctionName
())
testSQL
:=
[]
string
{
"use sakila"
,
"select frm syntaxError"
,
"create table t(id int,c1 varchar(20),PRIMARY KEY (id));"
,
"alter table t add index `idx_c1`(c1);"
,
"select * from city where country_id = 44;"
,
...
...
env/testdata/TestNewVirtualEnv.golden
浏览文件 @
407db8a0
use sakila OK
select frm syntaxError OK
create table t(id int,c1 varchar(20),PRIMARY KEY (id)); OK
alter table t add index `idx_c1`(c1); OK
select * from city where country_id = 44; OK
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录