提交 f3588d6e 编写于 作者: X xiyangxixian

fix index advisor give wrong database name, `optimizer_xx` is temporary database

上级 3bae8043
......@@ -278,7 +278,7 @@ func main() {
explainInfo, err := rEnv.Explain(q.Query,
database.ExplainType[common.Config.ExplainType],
database.ExplainFormatType[common.Config.ExplainFormat])
if err != nil && strings.HasPrefix(vEnv.Database, "optimizer_") {
if err != nil {
// 线上环境执行失败才到测试环境 EXPLAIN,比如在用户提供建表语句及查询语句的场景
common.Log.Warn("rEnv.Explain Warn: %v", err)
explainInfo, err = vEnv.Explain(q.Query,
......
......@@ -122,6 +122,7 @@ func (ve VirtualEnv) RealDB(hash string) string {
if _, ok := ve.hash2Db[hash]; ok {
return ve.hash2Db[hash]
}
common.Log.Error("RealDB, missing hash map: %s", hash)
return hash
}
......@@ -355,7 +356,9 @@ func (ve VirtualEnv) createDatabase(rEnv database.Connector, dbName string) erro
}
// optimizer_YYMMDDHHmmss_xxxx
dbHash := fmt.Sprintf("optimizer_%s_%s", time.Now().Format("060102150405"), uniuri.New())
dbHash := fmt.Sprintf("optimizer_%s_%s", // Total 39 bytes
time.Now().Format("060102150405"), // 12 Bytes 20180102030405
strings.ToLower(uniuri.New())) // 16 Bytes random string
common.Log.Debug("createDatabase, mapping `%s` :`%s`-->`%s`", dbName, dbName, dbHash)
ddl, err := rEnv.ShowCreateDatabase(dbName)
if err != nil {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册