Skip to content

Commit

Permalink
daily update vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
martianzhang committed Dec 5, 2018
1 parent 5eb250b commit 6eddefa
Show file tree
Hide file tree
Showing 19 changed files with 710 additions and 80 deletions.
4 changes: 2 additions & 2 deletions advisor/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ func init() {
Item: "TBL.005",
Severity: "L4",
Summary: "请使用推荐的字符集",
Content: `表字符集只允许设置为` + strings.Join(common.Config.AllowCharsets, ","),
Content: `表字符集只允许设置为'` + strings.Join(common.Config.AllowCharsets, ",") + "'",
Case: "CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;",
Func: (*Query4Audit).RuleTableCharsetCheck,
},
Expand All @@ -1117,7 +1117,7 @@ func init() {
Item: "TBL.008",
Severity: "L4",
Summary: "请使用推荐的COLLATE",
Content: `COLLATE 只允许设置为` + strings.Join(common.Config.AllowCollates, ","),
Content: `COLLATE 只允许设置为'` + strings.Join(common.Config.AllowCollates, ",") + "'",
Case: "CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;",
Func: (*Query4Audit).RuleTableCharsetCheck,
},
Expand Down
4 changes: 2 additions & 2 deletions advisor/testdata/TestListHeuristicRules.golden
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;

* **Item**:TBL.005
* **Severity**:L4
* **Content**:表字符集只允许设置为utf8,utf8mb4
* **Content**:表字符集只允许设置为'utf8,utf8mb4'
* **Case**:

```sql
Expand Down Expand Up @@ -1206,7 +1206,7 @@ CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;

* **Item**:TBL.008
* **Severity**:L4
* **Content**:COLLATE 只允许设置为
* **Content**:COLLATE 只允许设置为''
* **Case**:

```sql
Expand Down
4 changes: 2 additions & 2 deletions advisor/testdata/TestMergeConflictHeuristicRules.golden
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ advisor.Rule{Item:"TBL.001", Severity:"L4", Summary:"不建议使用分区表",
advisor.Rule{Item:"TBL.002", Severity:"L4", Summary:"请为表选择合适的存储引擎", Content:"建表或修改表的存储引擎时建议使用推荐的存储引擎,如:innodb", Case:"create table test(`id` int(11) NOT NULL AUTO_INCREMENT)", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.003", Severity:"L8", Summary:"以DUAL命名的表在数据库中有特殊含义", Content:"DUAL表为虚拟表,不需要创建即可使用,也不建议服务以DUAL命名表。", Case:"create table dual(id int, primary key (id));", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.004", Severity:"L2", Summary:"表的初始AUTO_INCREMENT值不为0", Content:"AUTO_INCREMENT不为0会导致数据空洞。", Case:"CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.005", Severity:"L4", Summary:"请使用推荐的字符集", Content:"表字符集只允许设置为utf8,utf8mb4", Case:"CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.005", Severity:"L4", Summary:"请使用推荐的字符集", Content:"表字符集只允许设置为'utf8,utf8mb4'", Case:"CREATE TABLE tbl (a int) DEFAULT CHARSET = latin1;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.006", Severity:"L1", Summary:"不建议使用视图", Content:"不建议使用视图", Case:"create view v_today (today) AS SELECT CURRENT_DATE;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.007", Severity:"L1", Summary:"不建议使用临时表", Content:"不建议使用临时表", Case:"CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.008", Severity:"L4", Summary:"请使用推荐的COLLATE", Content:"COLLATE 只允许设置为", Case:"CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
advisor.Rule{Item:"TBL.008", Severity:"L4", Summary:"请使用推荐的COLLATE", Content:"COLLATE 只允许设置为''", Case:"CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;", Position:0, Func:func(*advisor.Query4Audit) advisor.Rule {...}}
9 changes: 4 additions & 5 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,10 @@ func readCmdFlags() error {
Config.IgnoreRules = strings.Split(*ignoreRules, ",")
Config.RewriteRules = strings.Split(*rewriteRules, ",")
*blackList = strings.TrimSpace(*blackList)
if strings.HasPrefix(*blackList, "/") || *blackList == "" {
if filepath.IsAbs(*blackList) || *blackList == "" {
Config.BlackList = *blackList
} else {
pwd, _ := os.Getwd()
Config.BlackList = pwd + "/" + *blackList
Config.BlackList = filepath.Join(BaseDir, *blackList)
}
Config.MaxJoinTableCount = *maxJoinTableCount
Config.MaxGroupByColsCount = *maxGroupByColsCount
Expand Down Expand Up @@ -688,8 +687,8 @@ func ParseConfig(configFile string) error {
if configFile == "" {
configs = []string{
"/etc/soar.yaml",
BaseDir + "/etc/soar.yaml",
BaseDir + "/soar.yaml",
filepath.Join(BaseDir, "etc", "soar.yaml"),
filepath.Join(BaseDir, "soar.yaml"),
}
} else {
configs = []string{
Expand Down
12 changes: 11 additions & 1 deletion doc/heuristic.md
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ CREATE TABLE tbl (a int) AUTO_INCREMENT = 10;

* **Item**:TBL.005
* **Severity**:L4
* **Content**:表字符集只允许设置为utf8,utf8mb4
* **Content**:表字符集只允许设置为'utf8,utf8mb4'
* **Case**:

```sql
Expand All @@ -1202,3 +1202,13 @@ create view v_today (today) AS SELECT CURRENT_DATE;
```sql
CREATE TEMPORARY TABLE `work` (`time` time DEFAULT NULL) ENGINE=InnoDB;
```
## 请使用推荐的COLLATE

* **Item**:TBL.008
* **Severity**:L4
* **Content**:COLLATE 只允许设置为''
* **Case**:

```sql
CREATE TABLE tbl (a int) DEFAULT COLLATE = latin1_bin;
```
3 changes: 3 additions & 0 deletions vendor/github.com/pingcap/parser/ast/ast.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6eddefa

Please sign in to comment.