Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿拉亮
soar
提交
5533b049
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,发现更多精彩内容 >>
提交
5533b049
编写于
4月 18, 2019
作者:
martianzhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #98
https://github.com/XiaoMi/soar/issues/98
上级
ba20f34c
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
545 addition
and
442 deletion
+545
-442
advisor/explainer.go
advisor/explainer.go
+1
-1
advisor/rules.go
advisor/rules.go
+76
-12
advisor/testdata/TestDigestExplainText.golden
advisor/testdata/TestDigestExplainText.golden
+2
-2
cmd/soar/soar.go
cmd/soar/soar.go
+8
-11
cmd/soar/testdata/Test_Main_verboseInfo.golden
cmd/soar/testdata/Test_Main_verboseInfo.golden
+2
-0
common/config.go
common/config.go
+1
-1
common/testdata/TestListReportTypes.golden
common/testdata/TestListReportTypes.golden
+10
-2
common/testdata/TestParseDSN.golden
common/testdata/TestParseDSN.golden
+90
-90
common/testdata/TestPrintConfiguration.golden
common/testdata/TestPrintConfiguration.golden
+6
-6
common/testdata/TestStringStorageReq.golden
common/testdata/TestStringStorageReq.golden
+310
-310
database/testdata/TestShowTables.golden
database/testdata/TestShowTables.golden
+3
-0
doc/report_type.md
doc/report_type.md
+1
-1
env/env.go
env/env.go
+18
-0
test/fixture/test_Check_soar_report_for_json.golden
test/fixture/test_Check_soar_report_for_json.golden
+17
-6
未找到文件。
advisor/explainer.go
浏览文件 @
5533b049
...
...
@@ -222,7 +222,7 @@ func DigestExplainText(text string) {
return
}
expSuggest
:=
ExplainAdvisor
(
explainInfo
)
_
,
output
:=
FormatSuggest
(
""
,
common
.
Config
.
ReportType
,
expSuggest
)
_
,
output
:=
FormatSuggest
(
""
,
""
,
common
.
Config
.
ReportType
,
expSuggest
)
if
common
.
Config
.
ReportType
==
"html"
{
fmt
.
Println
(
common
.
MarkdownHTMLHeader
())
fmt
.
Println
(
common
.
Markdown2HTML
(
output
))
...
...
advisor/rules.go
浏览文件 @
5533b049
...
...
@@ -1202,7 +1202,7 @@ func InBlackList(sql string) bool {
}
// FormatSuggest 格式化输出优化建议
func
FormatSuggest
(
sql
string
,
format
string
,
suggests
...
map
[
string
]
Rule
)
(
map
[
string
]
Rule
,
string
)
{
func
FormatSuggest
(
sql
string
,
currentDB
string
,
format
string
,
suggests
...
map
[
string
]
Rule
)
(
map
[
string
]
Rule
,
string
)
{
common
.
Log
.
Debug
(
"FormatSuggest, Query: %s"
,
sql
)
var
fingerprint
,
id
string
var
buf
[]
string
...
...
@@ -1252,17 +1252,7 @@ func FormatSuggest(sql string, format string, suggests ...map[string]Rule) (map[
common
.
Log
.
Debug
(
"FormatSuggest, format: %s"
,
format
)
switch
format
{
case
"json"
:
js
,
err
:=
json
.
MarshalIndent
(
Result
{
ID
:
id
,
Fingerprint
:
fingerprint
,
Sample
:
sql
,
Suggest
:
suggest
,
},
""
,
" "
)
if
err
==
nil
{
buf
=
append
(
buf
,
fmt
.
Sprintln
(
string
(
js
)))
}
else
{
common
.
Log
.
Error
(
"FormatSuggest json.Marshal Error: %v"
,
err
)
}
buf
=
append
(
buf
,
formatJSON
(
sql
,
currentDB
,
suggest
))
case
"text"
:
for
item
,
rule
:=
range
suggest
{
...
...
@@ -1452,6 +1442,80 @@ func FormatSuggest(sql string, format string, suggests ...map[string]Rule) (map[
return
suggest
,
str
}
// JSONSuggest json format suggestion
type
JSONSuggest
struct
{
ID
string
`json:"ID"`
Fingerprint
string
`json:"Fingerprint"`
Score
int
`json:"Score"`
Sample
string
`json:"Sample"`
Explain
[]
Rule
`json:"Explain"`
HeuristicRules
[]
Rule
`json:"HeuristicRules"`
IndexRules
[]
Rule
`json:"IndexRules"`
Tables
[]
string
`json:"Tables"`
}
func
formatJSON
(
sql
string
,
db
string
,
suggest
map
[
string
]
Rule
)
string
{
var
id
,
fingerprint
,
result
string
fingerprint
=
query
.
Fingerprint
(
sql
)
id
=
query
.
Id
(
fingerprint
)
sug
:=
JSONSuggest
{
ID
:
id
,
Fingerprint
:
fingerprint
,
Sample
:
sql
,
Tables
:
ast
.
SchemaMetaInfo
(
sql
,
db
),
}
// Explain info
var
sortItem
[]
string
for
item
:=
range
suggest
{
if
strings
.
HasPrefix
(
item
,
"EXP"
)
{
sortItem
=
append
(
sortItem
,
item
)
}
}
sort
.
Strings
(
sortItem
)
for
_
,
i
:=
range
sortItem
{
sug
.
Explain
=
append
(
sug
.
Explain
,
suggest
[
i
])
}
sortItem
=
make
([]
string
,
0
)
// Index advisor
for
item
:=
range
suggest
{
if
strings
.
HasPrefix
(
item
,
"IDX"
)
{
sortItem
=
append
(
sortItem
,
item
)
}
}
sort
.
Strings
(
sortItem
)
for
_
,
i
:=
range
sortItem
{
sug
.
IndexRules
=
append
(
sug
.
IndexRules
,
suggest
[
i
])
}
sortItem
=
make
([]
string
,
0
)
// Heuristic rules
for
item
:=
range
suggest
{
if
!
strings
.
HasPrefix
(
item
,
"EXP"
)
&&
!
strings
.
HasPrefix
(
item
,
"IDX"
)
{
if
strings
.
HasPrefix
(
item
,
"ERR"
)
&&
suggest
[
item
]
.
Content
==
""
{
continue
}
sortItem
=
append
(
sortItem
,
item
)
}
}
sort
.
Strings
(
sortItem
)
for
_
,
i
:=
range
sortItem
{
sug
.
HeuristicRules
=
append
(
sug
.
HeuristicRules
,
suggest
[
i
])
}
sortItem
=
make
([]
string
,
0
)
js
,
err
:=
json
.
MarshalIndent
(
sug
,
""
,
" "
)
if
err
==
nil
{
result
=
fmt
.
Sprint
(
string
(
js
))
}
else
{
common
.
Log
.
Error
(
"formatJSON json.Marshal Error: %v"
,
err
)
}
return
result
}
// ListHeuristicRules 打印支持的启发式规则,对应命令行参数-list-heuristic-rules
func
ListHeuristicRules
(
rules
...
map
[
string
]
Rule
)
{
switch
common
.
Config
.
ReportType
{
...
...
advisor/testdata/TestDigestExplainText.golden
浏览文件 @
5533b049
...
...
@@ -3,7 +3,7 @@
| id | select\_type | table | partitions | type | possible_keys | key | key\_len | ref | rows | filtered | scalability | Extra |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | *country* | NULL | index | PRIMARY,<br>country\_id | country | 152 | NULL | 0 | 0.00% | ☠️ **O(n)** | Using index |
| 1 | SIMPLE | *city* | NULL | ref | idx\_fk\_country\_id,<br>idx\_country\_id\_city,<br>idx\_all,<br>idx\_other | idx\_fk\_country\_id | 2 | sakila.country.country\_id | 0 | 0.00% |
☠️ **O(n)**
| Using index |
| 1 | SIMPLE | *city* | NULL | ref | idx\_fk\_country\_id,<br>idx\_country\_id\_city,<br>idx\_all,<br>idx\_other | idx\_fk\_country\_id | 2 | sakila.country.country\_id | 0 | 0.00% |
O(log n)
| Using index |
...
...
@@ -105,7 +105,7 @@ a:link,a:visited{text-decoration:none}h3,h4{margin-top:2em}h5,h6{margin-top:20px
<td>sakila.country.country_id</td>
<td>0</td>
<td>0.00%</td>
<td>
☠️ <strong>O(n)</strong>
</td>
<td>
O(log n)
</td>
<td>Using index</td>
</tr>
</tbody>
...
...
cmd/soar/soar.go
浏览文件 @
5533b049
...
...
@@ -37,11 +37,13 @@ func main() {
// 全局变量
var
err
error
var
sql
string
// 单条评审指定的 sql 或 explain
var
currentDB
string
// 当前 SQL 使用的 database
sqlCounter
:=
1
// SQL 计数器
lineCounter
:=
1
// 行计数器
var
alterSQLs
[]
string
// 待评审的 SQL 中所有 ALTER 请求
alterTableTimes
:=
make
(
map
[
string
]
int
)
// 待评审的 SQL 中同一经表 ALTER 请求计数器
suggestMerged
:=
make
(
map
[
string
]
map
[
string
]
advisor
.
Rule
)
// 优化建议去重, key 为 sql 的 fingerprint.ID
var
suggestStr
[]
string
// string 形式格式化之后的优化建议,用于 -report-type json
tables
:=
make
(
map
[
string
][]
string
)
// SQL 使用的库表名
// 配置文件&命令行参数解析
...
...
@@ -74,7 +76,7 @@ func main() {
// 对指定的库表进行索引重复检查
if
common
.
Config
.
ReportType
==
"duplicate-key-checker"
{
dupKeySuggest
:=
advisor
.
DuplicateKeyChecker
(
rEnv
)
_
,
str
:=
advisor
.
FormatSuggest
(
""
,
common
.
Config
.
ReportType
,
dupKeySuggest
)
_
,
str
:=
advisor
.
FormatSuggest
(
""
,
c
urrentDB
,
c
ommon
.
Config
.
ReportType
,
dupKeySuggest
)
if
str
==
""
{
fmt
.
Printf
(
"%s/%s 未发现重复索引
\n
"
,
common
.
Config
.
OnlineDSN
.
Addr
,
common
.
Config
.
OnlineDSN
.
Schema
)
}
else
{
...
...
@@ -129,6 +131,7 @@ func main() {
// +++++++++++++++++++++小工具集[开始]+++++++++++++++++++++++{
fingerprint
:=
strings
.
TrimSpace
(
query
.
Fingerprint
(
sql
))
currentDB
=
env
.
CurrentDB
(
sql
,
currentDB
)
switch
common
.
Config
.
ReportType
{
case
"fingerprint"
:
// SQL 指纹
...
...
@@ -176,6 +179,7 @@ func main() {
continue
}
}
tables
[
id
]
=
ast
.
SchemaMetaInfo
(
sql
,
currentDB
)
// +++++++++++++++++++++小工具集[结束]+++++++++++++++++++++++}
// +++++++++++++++++++++语法检查[开始]+++++++++++++++++++++++{
...
...
@@ -202,8 +206,6 @@ func main() {
switch
common
.
Config
.
ReportType
{
case
"tables"
:
env
.
ChangeDB
(
vEnv
.
Connector
,
q
.
Query
)
tables
[
id
]
=
ast
.
SchemaMetaInfo
(
sql
,
vEnv
.
Database
)
continue
case
"query-type"
:
fmt
.
Println
(
syntaxErr
)
...
...
@@ -384,10 +386,11 @@ func main() {
// +++++++++++++++++++++打印单条 SQL 优化建议[开始]++++++++++++++++++++++++++{
common
.
Log
.
Debug
(
"start of print suggestions, Query: %s"
,
q
.
Query
)
sug
,
str
:=
advisor
.
FormatSuggest
(
q
.
Query
,
common
.
Config
.
ReportType
,
heuristicSuggest
,
idxSuggest
,
expSuggest
,
proSuggest
,
traceSuggest
,
mysqlSuggest
)
sug
,
str
:=
advisor
.
FormatSuggest
(
q
.
Query
,
c
urrentDB
,
c
ommon
.
Config
.
ReportType
,
heuristicSuggest
,
idxSuggest
,
expSuggest
,
proSuggest
,
traceSuggest
,
mysqlSuggest
)
suggestMerged
[
id
]
=
sug
switch
common
.
Config
.
ReportType
{
case
"json"
:
suggestStr
=
append
(
suggestStr
,
str
)
case
"tables"
:
case
"duplicate-key-checker"
:
case
"rewrite"
:
...
...
@@ -428,13 +431,7 @@ func main() {
// 以 JSON 格式化输出
if
common
.
Config
.
ReportType
==
"json"
{
js
,
err
:=
json
.
MarshalIndent
(
suggestMerged
,
""
,
" "
)
if
err
==
nil
{
fmt
.
Println
(
string
(
js
))
}
else
{
common
.
Log
.
Error
(
"FormatSuggest json.Marshal Error: %v"
,
err
)
}
return
fmt
.
Println
(
"[
\n
"
,
strings
.
Join
(
suggestStr
,
",
\n
"
),
"
\n
]"
)
}
// 以 JSON 格式输出 SQL 影响的库表名
...
...
cmd/soar/testdata/Test_Main_verboseInfo.golden
浏览文件 @
5533b049
Syntax check OK!
MySQL environment verbose info
* test-dsn: 127.0.0.1:3306 is disable, please check log.
* online-dsn: 127.0.0.1:3306 is disable, please check log.
MySQL environment verbose info
* test-dsn: 127.0.0.1:3306 is disable, please check log.
* online-dsn: 127.0.0.1:3306 is disable, please check log.
common/config.go
浏览文件 @
5533b049
...
...
@@ -882,7 +882,7 @@ var ReportTypes = []ReportType{
{
Name
:
"tables"
,
Description
:
"以 JSON 格式输出 SQL 使用的库表名"
,
Example
:
`echo "select * from film" | soar -report-type
meta
`
,
Example
:
`echo "select * from film" | soar -report-type
tables
`
,
},
{
Name
:
"query-type"
,
...
...
common/testdata/TestListReportTypes.golden
浏览文件 @
5533b049
...
...
@@ -58,13 +58,21 @@ echo "select * from film" | soar -report-type tiast
```bash
echo "select * from film" | soar -report-type tiast-json
```
##
meta
##
tables
* **Description**:以 JSON 格式输出 SQL 使用的库表名
* **Example**:
```bash
echo "select * from film" | soar -report-type meta
echo "select * from film" | soar -report-type tables
```
## query-type
* **Description**:SQL 语句的请求类型
* **Example**:
```bash
echo "select * from film" | soar -report-type query-type
```
## fingerprint
* **Description**:输出SQL的指纹
...
...
common/testdata/TestParseDSN.golden
浏览文件 @
5533b049
...
...
@@ -12,9 +12,9 @@
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -34,9 +34,9 @@ user:password@hostname:3307/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -56,9 +56,9 @@ user:password@hostname:3307/database?charset=utf8
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -78,9 +78,9 @@ user:password@hostname:3307
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -100,9 +100,9 @@ user:password@hostname:/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -122,9 +122,9 @@ user:password@:3307/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -144,9 +144,9 @@ user@hostname/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -166,9 +166,9 @@ user:pwd:pwd@pwd/pwd@hostname/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -188,9 +188,9 @@ user:password@
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -210,9 +210,9 @@ hostname:3307/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -232,9 +232,9 @@ hostname:3307/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -254,9 +254,9 @@ hostname:3307/database
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -276,9 +276,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -298,9 +298,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -320,9 +320,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -342,9 +342,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -364,9 +364,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"3s"
,
ReadTimeout:
""
,
WriteTimeout:
""
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -386,9 +386,9 @@ hostname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -408,9 +408,9 @@ user@unix(/path/to/socket)/dbname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -430,9 +430,9 @@ root:pw@unix(/tmp/mysql.sock)/myDatabase?loc=Local
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -452,9 +452,9 @@ user:password@tcp(localhost:5555)/dbname?tls=skip-verify&autocommit=true
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"autocommit":"true"},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -474,9 +474,9 @@ user:password@/dbname?sql_mode=TRADITIONAL
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"sql_mode":"TRADITIONAL"},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -496,9 +496,9 @@ user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname?timeout=90s&collation=utf8mb4_
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
90
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"1m30s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -518,9 +518,9 @@ id:password@tcp(your-amazonaws-uri.com:3306)/dbname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -540,9 +540,9 @@ user@cloudsql(project-id:instance-name)/dbname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -562,9 +562,9 @@ user@cloudsql(project-id:regionname:instance-name)/dbname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -584,9 +584,9 @@ user:password@tcp/dbname?charset=utf8mb4,utf8&sys_var=esc%40ped
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"charset":"utf8mb4,utf8", "sys_var":"esc@ped"},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -606,9 +606,9 @@ user:password@/dbname
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -628,9 +628,9 @@ user:password@/
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {},
Timeout:
0
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"0s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
@@ -650,9 +650,9 @@ user:password@tcp(localhost:3307)/database?charset=utf8&timeout=5s
ServerPubKey: "",
MaxAllowedPacket: 4194304,
Params: {"charset":"utf8"},
Timeout:
5
,
ReadTimeout:
0
,
WriteTimeout:
0
,
Timeout:
"5s"
,
ReadTimeout:
"0s"
,
WriteTimeout:
"0s"
,
AllowNativePasswords: true,
AllowOldPasswords: false,
Disable: false,
...
...
common/testdata/TestPrintConfiguration.golden
浏览文件 @
5533b049
...
...
@@ -12,9 +12,9 @@ online-dsn:
maxallowedpacket: 4194304
params:
charset: utf8
timeout:
0
read-timeout: 0
write-timeout: 0
timeout:
3s
read-timeout: 0
s
write-timeout: 0
s
allow-native-passwords: true
allow-old-passwords: false
disable: false
...
...
@@ -32,9 +32,9 @@ test-dsn:
maxallowedpacket: 4194304
params:
charset: utf8
timeout:
0
read-timeout: 0
write-timeout: 0
timeout:
3s
read-timeout: 0
s
write-timeout: 0
s
allow-native-passwords: true
allow-old-passwords: false
disable: false
...
...
common/testdata/TestStringStorageReq.golden
浏览文件 @
5533b049
char(10) latin7 10
char(256) latin7 255
binary(10) latin7 10
binary(256) latin7 255
varchar(10) latin7 11
varbinary(10) latin7 11
enum('G','PG','PG-13','R','NC-17') latin7 1
set('one', 'two') latin7 1
not_exist latin7 0
char(-1) latin7 0
char(10) ujis 30
char(256) ujis 765
binary(10) ujis 10
binary(256) ujis 255
varchar(10) ujis 31
varbinary(10) ujis 31
enum('G','PG','PG-13','R','NC-17') ujis 1
set('one', 'two') ujis 1
not_exist ujis 0
char(-1) ujis 0
char(10) cp1256 10
char(256) cp1256 255
binary(10) cp1256 10
binary(256) cp1256 255
varchar(10) cp1256 11
varbinary(10) cp1256 11
enum('G','PG','PG-13','R','NC-17') cp1256 1
set('one', 'two') cp1256 1
not_exist cp1256 0
char(-1) cp1256 0
char(10) hebrew 10
char(256) hebrew 255
binary(10) hebrew 10
binary(256) hebrew 255
varchar(10) hebrew 11
varbinary(10) hebrew 11
enum('G','PG','PG-13','R','NC-17') hebrew 1
set('one', 'two') hebrew 1
not_exist hebrew 0
char(-1) hebrew 0
char(10) latin2 10
char(256) latin2 255
binary(10) latin2 10
binary(256) latin2 255
varchar(10) latin2 11
varbinary(10) latin2 11
enum('G','PG','PG-13','R','NC-17') latin2 1
set('one', 'two') latin2 1
not_exist latin2 0
char(-1) latin2 0
char(10) big5 20
char(256) big5 510
binary(10) big5 10
binary(256) big5 255
varchar(10) big5 21
varbinary(10) big5 21
enum('G','PG','PG-13','R','NC-17') big5 1
set('one', 'two') big5 1
not_exist big5 0
char(-1) big5 0
char(10) cp1250 10
char(256) cp1250 255
binary(10) cp1250 10
binary(256) cp1250 255
varchar(10) cp1250 11
varbinary(10) cp1250 11
enum('G','PG','PG-13','R','NC-17') cp1250 1
set('one', 'two') cp1250 1
not_exist cp1250 0
char(-1) cp1250 0
char(10) eucjpms 30
char(256) eucjpms 765
binary(10) eucjpms 10
binary(256) eucjpms 255
varchar(10) eucjpms 31
varbinary(10) eucjpms 31
enum('G','PG','PG-13','R','NC-17') eucjpms 1
set('one', 'two') eucjpms 1
not_exist eucjpms 0
char(-1) eucjpms 0
char(10) latin1 10
char(256) latin1 255
binary(10) latin1 10
binary(256) latin1 255
varchar(10) latin1 11
varbinary(10) latin1 11
enum('G','PG','PG-13','R','NC-17') latin1 1
set('one', 'two') latin1 1
not_exist latin1 0
char(-1) latin1 0
char(10) macce 10
char(256) macce 255
binary(10) macce 10
binary(256) macce 255
varchar(10) macce 11
varbinary(10) macce 11
enum('G','PG','PG-13','R','NC-17') macce 1
set('one', 'two') macce 1
not_exist macce 0
char(-1) macce 0
char(10) tis620 10
char(256) tis620 255
binary(10) tis620 10
binary(256) tis620 255
varchar(10) tis620 11
varbinary(10) tis620 11
enum('G','PG','PG-13','R','NC-17') tis620 1
set('one', 'two') tis620 1
not_exist tis620 0
char(-1) tis620 0
char(10) utf16 40
char(256) utf16 1020
binary(10) utf16 10
binary(256) utf16 255
varchar(10) utf16 41
varbinary(10) utf16 41
enum('G','PG','PG-13','R','NC-17') utf16 1
set('one', 'two') utf16 1
not_exist utf16 0
char(-1) utf16 0
char(10) utf16le 40
char(256) utf16le 1020
binary(10) utf16le 10
binary(256) utf16le 255
varchar(10) utf16le 41
varbinary(10) utf16le 41
enum('G','PG','PG-13','R','NC-17') utf16le 1
set('one', 'two') utf16le 1
not_exist utf16le 0
char(-1) utf16le 0
char(10) binary 10
char(256) binary 255
binary(10) binary 10
binary(256) binary 255
varchar(10) binary 11
varbinary(10) binary 11
enum('G','PG','PG-13','R','NC-17') binary 1
set('one', 'two') binary 1
not_exist binary 0
char(-1) binary 0
char(10) cp852 10
char(256) cp852 255
binary(10) cp852 10
...
...
@@ -38,36 +118,36 @@ enum('G','PG','PG-13','R','NC-17') cp852 1
set('one', 'two') cp852 1
not_exist cp852 0
char(-1) cp852 0
char(10) cp
866 1
0
char(256) cp
866 255
binary(10) cp
866
10
binary(256) cp
866
255
varchar(10) cp
866 1
1
varbinary(10) cp
866 1
1
enum('G','PG','PG-13','R','NC-17') cp
866
1
set('one', 'two') cp
866
1
not_exist cp
866
0
char(-1) cp
866
0
char(10) g
eostd8 1
0
char(256) g
eostd8 255
binary(10) g
eostd8
10
binary(256) g
eostd8
255
varchar(10) g
eostd8 1
1
varbinary(10) g
eostd8 1
1
enum('G','PG','PG-13','R','NC-17') g
eostd8
1
set('one', 'two') g
eostd8
1
not_exist g
eostd8
0
char(-1) g
eostd8
0
char(10)
keybcs2
10
char(256)
keybcs2
255
binary(10)
keybcs2
10
binary(256)
keybcs2
255
varchar(10)
keybcs2
11
varbinary(10)
keybcs2
11
enum('G','PG','PG-13','R','NC-17')
keybcs2
1
set('one', 'two')
keybcs2
1
not_exist
keybcs2
0
char(-1)
keybcs2
0
char(10) cp
932 2
0
char(256) cp
932 510
binary(10) cp
932
10
binary(256) cp
932
255
varchar(10) cp
932 2
1
varbinary(10) cp
932 2
1
enum('G','PG','PG-13','R','NC-17') cp
932
1
set('one', 'two') cp
932
1
not_exist cp
932
0
char(-1) cp
932
0
char(10) g
bk 2
0
char(256) g
bk 510
binary(10) g
bk
10
binary(256) g
bk
255
varchar(10) g
bk 2
1
varbinary(10) g
bk 2
1
enum('G','PG','PG-13','R','NC-17') g
bk
1
set('one', 'two') g
bk
1
not_exist g
bk
0
char(-1) g
bk
0
char(10)
hp8
10
char(256)
hp8
255
binary(10)
hp8
10
binary(256)
hp8
255
varchar(10)
hp8
11
varbinary(10)
hp8
11
enum('G','PG','PG-13','R','NC-17')
hp8
1
set('one', 'two')
hp8
1
not_exist
hp8
0
char(-1)
hp8
0
char(10) ucs2 20
char(256) ucs2 510
binary(10) ucs2 10
...
...
@@ -78,36 +158,26 @@ enum('G','PG','PG-13','R','NC-17') ucs2 1
set('one', 'two') ucs2 1
not_exist ucs2 0
char(-1) ucs2 0
char(10) utf32 40
char(256) utf32 1020
binary(10) utf32 10
binary(256) utf32 255
varchar(10) utf32 41
varbinary(10) utf32 41
enum('G','PG','PG-13','R','NC-17') utf32 1
set('one', 'two') utf32 1
not_exist utf32 0
char(-1) utf32 0
char(10) armscii8 10
char(256) armscii8 255
binary(10) armscii8 10
binary(256) armscii8 255
varchar(10) armscii8 11
varbinary(10) armscii8 11
enum('G','PG','PG-13','R','NC-17') armscii8 1
set('one', 'two') armscii8 1
not_exist armscii8 0
char(-1) armscii8 0
char(10) ascii 10
char(256) ascii 255
binary(10) ascii 10
binary(256) ascii 255
varchar(10) ascii 11
varbinary(10) ascii 11
enum('G','PG','PG-13','R','NC-17') ascii 1
set('one', 'two') ascii 1
not_exist ascii 0
char(-1) ascii 0
char(10) cp1251 10
char(256) cp1251 255
binary(10) cp1251 10
binary(256) cp1251 255
varchar(10) cp1251 11
varbinary(10) cp1251 11
enum('G','PG','PG-13','R','NC-17') cp1251 1
set('one', 'two') cp1251 1
not_exist cp1251 0
char(-1) cp1251 0
char(10) cp1256 10
char(256) cp1256 255
binary(10) cp1256 10
binary(256) cp1256 255
varchar(10) cp1256 11
varbinary(10) cp1256 11
enum('G','PG','PG-13','R','NC-17') cp1256 1
set('one', 'two') cp1256 1
not_exist cp1256 0
char(-1) cp1256 0
char(10) dec8 10
char(256) dec8 255
binary(10) dec8 10
...
...
@@ -118,56 +188,26 @@ enum('G','PG','PG-13','R','NC-17') dec8 1
set('one', 'two') dec8 1
not_exist dec8 0
char(-1) dec8 0
char(10) eucjpms 30
char(256) eucjpms 765
binary(10) eucjpms 10
binary(256) eucjpms 255
varchar(10) eucjpms 31
varbinary(10) eucjpms 31
enum('G','PG','PG-13','R','NC-17') eucjpms 1
set('one', 'two') eucjpms 1
not_exist eucjpms 0
char(-1) eucjpms 0
char(10) latin2 10
char(256) latin2 255
binary(10) latin2 10
binary(256) latin2 255
varchar(10) latin2 11
varbinary(10) latin2 11
enum('G','PG','PG-13','R','NC-17') latin2 1
set('one', 'two') latin2 1
not_exist latin2 0
char(-1) latin2 0
char(10) cp1257 10
char(256) cp1257 255
binary(10) cp1257 10
binary(256) cp1257 255
varchar(10) cp1257 11
varbinary(10) cp1257 11
enum('G','PG','PG-13','R','NC-17') cp1257 1
set('one', 'two') cp1257 1
not_exist cp1257 0
char(-1) cp1257 0
char(10) cp932 20
char(256) cp932 510
binary(10) cp932 10
binary(256) cp932 255
varchar(10) cp932 21
varbinary(10) cp932 21
enum('G','PG','PG-13','R','NC-17') cp932 1
set('one', 'two') cp932 1
not_exist cp932 0
char(-1) cp932 0
char(10) cp1250 10
char(256) cp1250 255
binary(10) cp1250 10
binary(256) cp1250 255
varchar(10) cp1250 11
varbinary(10) cp1250 11
enum('G','PG','PG-13','R','NC-17') cp1250 1
set('one', 'two') cp1250 1
not_exist cp1250 0
char(-1) cp1250 0
char(10) euckr 20
char(256) euckr 510
binary(10) euckr 10
binary(256) euckr 255
varchar(10) euckr 21
varbinary(10) euckr 21
enum('G','PG','PG-13','R','NC-17') euckr 1
set('one', 'two') euckr 1
not_exist euckr 0
char(-1) euckr 0
char(10) geostd8 10
char(256) geostd8 255
binary(10) geostd8 10
binary(256) geostd8 255
varchar(10) geostd8 11
varbinary(10) geostd8 11
enum('G','PG','PG-13','R','NC-17') geostd8 1
set('one', 'two') geostd8 1
not_exist geostd8 0
char(-1) geostd8 0
char(10) greek 10
char(256) greek 255
binary(10) greek 10
...
...
@@ -178,36 +218,26 @@ enum('G','PG','PG-13','R','NC-17') greek 1
set('one', 'two') greek 1
not_exist greek 0
char(-1) greek 0
char(10) swe7 10
char(256) swe7 255
binary(10) swe7 10
binary(256) swe7 255
varchar(10) swe7 11
varbinary(10) swe7 11
enum('G','PG','PG-13','R','NC-17') swe7 1
set('one', 'two') swe7 1
not_exist swe7 0
char(-1) swe7 0
char(10) utf8 30
char(256) utf8 765
binary(10) utf8 10
binary(256) utf8 255
varchar(10) utf8 31
varbinary(10) utf8 31
enum('G','PG','PG-13','R','NC-17') utf8 1
set('one', 'two') utf8 1
not_exist utf8 0
char(-1) utf8 0
char(10) utf8mb4 40
char(256) utf8mb4 1020
binary(10) utf8mb4 10
binary(256) utf8mb4 255
varchar(10) utf8mb4 41
varbinary(10) utf8mb4 41
enum('G','PG','PG-13','R','NC-17') utf8mb4 1
set('one', 'two') utf8mb4 1
not_exist utf8mb4 0
char(-1) utf8mb4 0
char(10) macroman 10
char(256) macroman 255
binary(10) macroman 10
binary(256) macroman 255
varchar(10) macroman 11
varbinary(10) macroman 11
enum('G','PG','PG-13','R','NC-17') macroman 1
set('one', 'two') macroman 1
not_exist macroman 0
char(-1) macroman 0
char(10) armscii8 10
char(256) armscii8 255
binary(10) armscii8 10
binary(256) armscii8 255
varchar(10) armscii8 11
varbinary(10) armscii8 11
enum('G','PG','PG-13','R','NC-17') armscii8 1
set('one', 'two') armscii8 1
not_exist armscii8 0
char(-1) armscii8 0
char(10) cp850 10
char(256) cp850 255
binary(10) cp850 10
...
...
@@ -218,26 +248,6 @@ enum('G','PG','PG-13','R','NC-17') cp850 1
set('one', 'two') cp850 1
not_exist cp850 0
char(-1) cp850 0
char(10) euckr 20
char(256) euckr 510
binary(10) euckr 10
binary(256) euckr 255
varchar(10) euckr 21
varbinary(10) euckr 21
enum('G','PG','PG-13','R','NC-17') euckr 1
set('one', 'two') euckr 1
not_exist euckr 0
char(-1) euckr 0
char(10) hp8 10
char(256) hp8 255
binary(10) hp8 10
binary(256) hp8 255
varchar(10) hp8 11
varbinary(10) hp8 11
enum('G','PG','PG-13','R','NC-17') hp8 1
set('one', 'two') hp8 1
not_exist hp8 0
char(-1) hp8 0
char(10) koi8u 10
char(256) koi8u 255
binary(10) koi8u 10
...
...
@@ -248,36 +258,36 @@ enum('G','PG','PG-13','R','NC-17') koi8u 1
set('one', 'two') koi8u 1
not_exist koi8u 0
char(-1) koi8u 0
char(10)
macce 1
0
char(256)
macce 25
5
binary(10)
macce
10
binary(256)
macce
255
varchar(10)
macce 1
1
varbinary(10)
macce 1
1
enum('G','PG','PG-13','R','NC-17')
macce
1
set('one', 'two')
macce
1
not_exist
macce
0
char(-1)
macce
0
char(10)
binary 1
0
char(256)
binary 255
binary(10)
binary
10
binary(256)
binary
255
varchar(10)
binary 1
1
varbinary(10)
binary 1
1
enum('G','PG','PG-13','R','NC-17')
binary
1
set('one', 'two')
binary
1
not_exist
binary
0
char(-1)
binary
0
char(10)
gb18030 4
0
char(256)
gb18030 1020
binary(10)
gb18030
10
binary(256)
gb18030
255
varchar(10)
gb18030 4
1
varbinary(10)
gb18030 4
1
enum('G','PG','PG-13','R','NC-17')
gb18030
1
set('one', 'two')
gb18030
1
not_exist
gb18030
0
char(-1)
gb18030
0
char(10)
ujis 3
0
char(256)
ujis 76
5
binary(10)
ujis
10
binary(256)
ujis
255
varchar(10)
ujis 3
1
varbinary(10)
ujis 3
1
enum('G','PG','PG-13','R','NC-17')
ujis
1
set('one', 'two')
ujis
1
not_exist
ujis
0
char(-1)
ujis
0
char(10)
utf32 4
0
char(256)
utf32 1020
binary(10)
utf32
10
binary(256)
utf32
255
varchar(10)
utf32 4
1
varbinary(10)
utf32 4
1
enum('G','PG','PG-13','R','NC-17')
utf32
1
set('one', 'two')
utf32
1
not_exist
utf32
0
char(-1)
utf32
0
char(10)
cp866 1
0
char(256)
cp866 255
binary(10)
cp866
10
binary(256)
cp866
255
varchar(10)
cp866 1
1
varbinary(10)
cp866 1
1
enum('G','PG','PG-13','R','NC-17')
cp866
1
set('one', 'two')
cp866
1
not_exist
cp866
0
char(-1)
cp866
0
char(10) gb2312 20
char(256) gb2312 510
binary(10) gb2312 10
...
...
@@ -288,6 +298,36 @@ enum('G','PG','PG-13','R','NC-17') gb2312 1
set('one', 'two') gb2312 1
not_exist gb2312 0
char(-1) gb2312 0
char(10) swe7 10
char(256) swe7 255
binary(10) swe7 10
binary(256) swe7 255
varchar(10) swe7 11
varbinary(10) swe7 11
enum('G','PG','PG-13','R','NC-17') swe7 1
set('one', 'two') swe7 1
not_exist swe7 0
char(-1) swe7 0
char(10) utf8mb4 40
char(256) utf8mb4 1020
binary(10) utf8mb4 10
binary(256) utf8mb4 255
varchar(10) utf8mb4 41
varbinary(10) utf8mb4 41
enum('G','PG','PG-13','R','NC-17') utf8mb4 1
set('one', 'two') utf8mb4 1
not_exist utf8mb4 0
char(-1) utf8mb4 0
char(10) ascii 10
char(256) ascii 255
binary(10) ascii 10
binary(256) ascii 255
varchar(10) ascii 11
varbinary(10) ascii 11
enum('G','PG','PG-13','R','NC-17') ascii 1
set('one', 'two') ascii 1
not_exist ascii 0
char(-1) ascii 0
char(10) latin5 10
char(256) latin5 255
binary(10) latin5 10
...
...
@@ -298,16 +338,6 @@ enum('G','PG','PG-13','R','NC-17') latin5 1
set('one', 'two') latin5 1
not_exist latin5 0
char(-1) latin5 0
char(10) big5 20
char(256) big5 510
binary(10) big5 10
binary(256) big5 255
varchar(10) big5 21
varbinary(10) big5 21
enum('G','PG','PG-13','R','NC-17') big5 1
set('one', 'two') big5 1
not_exist big5 0
char(-1) big5 0
char(10) koi8r 10
char(256) koi8r 255
binary(10) koi8r 10
...
...
@@ -318,6 +348,16 @@ enum('G','PG','PG-13','R','NC-17') koi8r 1
set('one', 'two') koi8r 1
not_exist koi8r 0
char(-1) koi8r 0
char(10) latin7 10
char(256) latin7 255
binary(10) latin7 10
binary(256) latin7 255
varchar(10) latin7 11
varbinary(10) latin7 11
enum('G','PG','PG-13','R','NC-17') latin7 1
set('one', 'two') latin7 1
not_exist latin7 0
char(-1) latin7 0
char(10) sjis 20
char(256) sjis 510
binary(10) sjis 10
...
...
@@ -328,83 +368,43 @@ enum('G','PG','PG-13','R','NC-17') sjis 1
set('one', 'two') sjis 1
not_exist sjis 0
char(-1) sjis 0
char(10) utf16le 40
char(256) utf16le 1020
binary(10) utf16le 10
binary(256) utf16le 255
varchar(10) utf16le 41
varbinary(10) utf16le 41
enum('G','PG','PG-13','R','NC-17') utf16le 1
set('one', 'two') utf16le 1
not_exist utf16le 0
char(-1) utf16le 0
char(10) tis620 10
char(256) tis620 255
binary(10) tis620 10
binary(256) tis620 255
varchar(10) tis620 11
varbinary(10) tis620 11
enum('G','PG','PG-13','R','NC-17') tis620 1
set('one', 'two') tis620 1
not_exist tis620 0
char(-1) tis620 0
char(10) utf16 40
char(256) utf16 1020
binary(10) utf16 10
binary(256) utf16 255
varchar(10) utf16 41
varbinary(10) utf16 41
enum('G','PG','PG-13','R','NC-17') utf16 1
set('one', 'two') utf16 1
not_exist utf16 0
char(-1) utf16 0
char(10) cp1251 10
char(256) cp1251 255
binary(10) cp1251 10
binary(256) cp1251 255
varchar(10) cp1251 11
varbinary(10) cp1251 11
enum('G','PG','PG-13','R','NC-17') cp1251 1
set('one', 'two') cp1251 1
not_exist cp1251 0
char(-1) cp1251 0
char(10) gbk 20
char(256) gbk 510
binary(10) gbk 10
binary(256) gbk 255
varchar(10) gbk 21
varbinary(10) gbk 21
enum('G','PG','PG-13','R','NC-17') gbk 1
set('one', 'two') gbk 1
not_exist gbk 0
char(-1) gbk 0
char(10) hebrew 10
char(256) hebrew 255
binary(10) hebrew 10
binary(256) hebrew 255
varchar(10) hebrew 11
varbinary(10) hebrew 11
enum('G','PG','PG-13','R','NC-17') hebrew 1
set('one', 'two') hebrew 1
not_exist hebrew 0
char(-1) hebrew 0
char(10) latin1 10
char(256) latin1 255
binary(10) latin1 10
binary(256) latin1 255
varchar(10) latin1 11
varbinary(10) latin1 11
enum('G','PG','PG-13','R','NC-17') latin1 1
set('one', 'two') latin1 1
not_exist latin1 0
char(-1) latin1 0
char(10) macroman 10
char(256) macroman 255
binary(10) macroman 10
binary(256) macroman 255
varchar(10) macroman 11
varbinary(10) macroman 11
enum('G','PG','PG-13','R','NC-17') macroman 1
set('one', 'two') macroman 1
not_exist macroman 0
char(-1) macroman 0
char(10) utf8 30
char(256) utf8 765
binary(10) utf8 10
binary(256) utf8 255
varchar(10) utf8 31
varbinary(10) utf8 31
enum('G','PG','PG-13','R','NC-17') utf8 1
set('one', 'two') utf8 1
not_exist utf8 0
char(-1) utf8 0
char(10) cp1257 10
char(256) cp1257 255
binary(10) cp1257 10
binary(256) cp1257 255
varchar(10) cp1257 11
varbinary(10) cp1257 11
enum('G','PG','PG-13','R','NC-17') cp1257 1
set('one', 'two') cp1257 1
not_exist cp1257 0
char(-1) cp1257 0
char(10) gb18030 40
char(256) gb18030 1020
binary(10) gb18030 10
binary(256) gb18030 255
varchar(10) gb18030 41
varbinary(10) gb18030 41
enum('G','PG','PG-13','R','NC-17') gb18030 1
set('one', 'two') gb18030 1
not_exist gb18030 0
char(-1) gb18030 0
char(10) keybcs2 10
char(256) keybcs2 255
binary(10) keybcs2 10
binary(256) keybcs2 255
varchar(10) keybcs2 11
varbinary(10) keybcs2 11
enum('G','PG','PG-13','R','NC-17') keybcs2 1
set('one', 'two') keybcs2 1
not_exist keybcs2 0
char(-1) keybcs2 0
database/testdata/TestShowTables.golden
浏览文件 @
5533b049
...
...
@@ -21,3 +21,6 @@ sales_by_store
staff
staff_list
store
t_clinic_info
t_partition_list
test_id
doc/report_type.md
浏览文件 @
5533b049
...
...
@@ -64,7 +64,7 @@ echo "select * from film" | soar -report-type tiast-json
*
**Example**
:
```
bash
echo
"select * from film"
| soar
-report-type
meta
echo
"select * from film"
| soar
-report-type
tables
```
## query-type
*
**Description**
:SQL 语句的请求类型
...
...
env/env.go
浏览文件 @
5533b049
...
...
@@ -209,6 +209,24 @@ func ChangeDB(env *database.Connector, sql string) {
}
}
func
CurrentDB
(
sql
,
db
string
)
string
{
stmt
,
err
:=
sqlparser
.
Parse
(
sql
)
if
err
!=
nil
{
return
common
.
Config
.
TestDSN
.
Schema
}
switch
stmt
:=
stmt
.
(
type
)
{
case
*
sqlparser
.
Use
:
if
stmt
.
DBName
.
String
()
!=
""
{
db
=
stmt
.
DBName
.
String
()
}
}
if
db
==
""
{
db
=
common
.
Config
.
TestDSN
.
Schema
}
return
db
}
// BuildVirtualEnv rEnv 为 SQL 源环境,DB 使用的信息从接口获取
// 注意:如果是 USE, DDL 等语句,执行完第一条就会返回,后面的 SQL 不会执行
func
(
vEnv
*
VirtualEnv
)
BuildVirtualEnv
(
rEnv
*
database
.
Connector
,
SQLs
...
string
)
bool
{
...
...
test/fixture/test_Check_soar_report_for_json.golden
浏览文件 @
5533b049
{
"687D590364E29465": {
"CLA.001": {
[
{
"ID": "687D590364E29465",
"Fingerprint": "select * from film",
"Score": 0,
"Sample": "select * from film",
"Explain": null,
"HeuristicRules": [
{
"Item": "CLA.001",
"Severity": "L4",
"Summary": "最外层 SELECT 未指定 WHERE 条件",
...
...
@@ -8,7 +14,7 @@
"Case": "select id from tbl",
"Position": 0
},
"COL.001":
{
{
"Item": "COL.001",
"Severity": "L1",
"Summary": "不建议使用 SELECT * 类型查询",
...
...
@@ -16,5 +22,10 @@
"Case": "select * from tbl where id=1",
"Position": 0
}
}
}
],
"IndexRules": null,
"Tables": [
"`information_schema`.`film`"
]
}
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录