executor: add default database to query log (#5078)

This commit is contained in:
xiaojian cai
2017-11-13 11:26:56 +08:00
committed by tiancaiamao
parent a13d24cff5
commit cedc35ca8c

View File

@ -289,10 +289,12 @@ func (a *ExecStmt) logSlowQuery(succ bool) {
sql = fmt.Sprintf("%.*q(len:%d)", cfg.Log.QueryLogMaxLen, sql, len(a.Text))
}
connID := a.ctx.GetSessionVars().ConnectionID
currentDB := a.ctx.GetSessionVars().CurrentDB
logEntry := log.NewEntry(logutil.SlowQueryLogger)
logEntry.Data = log.Fields{
"connectionId": connID,
"costTime": costTime,
"database": currentDB,
"sql": sql,
}
if costTime < time.Duration(cfg.Log.SlowThreshold)*time.Millisecond {