From 1fece192b093b35719a6c29833c39b4ebf92d4db Mon Sep 17 00:00:00 2001 From: Leon Zhang Date: Wed, 26 Dec 2018 14:18:57 +0800 Subject: [PATCH] fix #58 we change mymysql to go-sql-driver and use insert unhex() for any dangerous data type. --- cmd/soar/soar.go | 2 +- database/mysql.go | 2 +- database/sampling.go | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/soar/soar.go b/cmd/soar/soar.go index 31720e7..8c1f803 100644 --- a/cmd/soar/soar.go +++ b/cmd/soar/soar.go @@ -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 } // 查询请求切分 diff --git a/database/mysql.go b/database/mysql.go index 050c12a..df2153b 100644 --- a/database/mysql.go +++ b/database/mysql.go @@ -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) diff --git a/database/sampling.go b/database/sampling.go index 9cdd825..bb0daef 100644 --- a/database/sampling.go +++ b/database/sampling.go @@ -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 } -- GitLab