Skip to content

Commit

Permalink
fix XiaoMi#58
Browse files Browse the repository at this point in the history
  we change mymysql to go-sql-driver and use insert unhex()
  for any dangerous data type.
  • Loading branch information
martianzhang committed Dec 26, 2018
1 parent a583e9d commit 1fece19
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/soar/soar.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func main() {
mysqlSuggest := make(map[string]advisor.Rule) // MySQL 返回的 ERROR 信息

if buf == "" {
common.Log.Debug("buf: %s, sql: %s empty", buf, sql)
common.Log.Debug("Ending, buf: '%s', sql: '%s'", buf, sql)
break
}
// 查询请求切分
Expand Down
2 changes: 1 addition & 1 deletion database/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (db *Connector) ColumnCardinality(tb, col string) float64 {

// IsView 判断表是否是视图
func (db *Connector) IsView(tbName string) bool {
common.Log.Debug("IsView, ShowTableStatus check `%s` is view", tbName)
common.Log.Debug("IsView, ShowTableStatus check if `%s` is view", tbName)
tbStatus, err := db.ShowTableStatus(tbName)
if err != nil {
common.Log.Error("(db *Connector) IsView Error: %v:", err)
Expand Down
6 changes: 6 additions & 0 deletions database/sampling.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ func (db *Connector) startSampling(onlineConn *sql.DB, database, table string, w
valuesCount = 0
}
}
if len(valuesStr) > 0 {
err = db.doSampling(table, columnsStr, strings.Join(valuesStr, `,`))
if err != nil {
common.LogIfWarn(err, "")
}
}
res.Close()
return err
}
Expand Down

0 comments on commit 1fece19

Please sign in to comment.