提交 dc1bb566 编写于 作者: martianzhang's avatar martianzhang

fix multi time `use db` bug

  use a;
  select * from ta;
  use b;
  select * from tb;
上级 b4744acf
......@@ -175,11 +175,17 @@ func main() {
// 建议去重,减少评审整个文件耗时
// TODO: 由于 a = 11 和 a = '11' 的 fingerprint 相同,这里一旦跳过即无法检查有些建议了,如: ARG.003
if _, ok := suggestMerged[id]; ok {
continue
// `use ?` 不可以去重,去重后将导致无法切换数据库
if !strings.HasPrefix(fingerprint, "use") {
continue
}
}
// 黑名单中的SQL不给建议
if advisor.InBlackList(fingerprint) {
continue
// `use ?` 不可以出现在黑名单中
if !strings.HasPrefix(fingerprint, "use") {
continue
}
}
}
tables[id] = ast.SchemaMetaInfo(sql, currentDB)
......@@ -389,6 +395,9 @@ func main() {
// +++++++++++++++++++++打印单条 SQL 优化建议[开始]++++++++++++++++++++++++++{
common.Log.Debug("start of print suggestions, Query: %s", q.Query)
if strings.HasPrefix(fingerprint, "use") {
continue
}
sug, str := advisor.FormatSuggest(q.Query, currentDB, common.Config.ReportType, heuristicSuggest, idxSuggest, expSuggest, proSuggest, traceSuggest, mysqlSuggest)
suggestMerged[id] = sug
switch common.Config.ReportType {
......
# 这是一个黑名单例子
## 不评审常见的SET, SHOW, SELECT CONST等完美请求
^use \?$
^set.*
^show.*
^select \?$
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册