diff --git a/executor/executor_pkg_test.go b/executor/executor_pkg_test.go index 95f547ae68039..3712b829b16c0 100644 --- a/executor/executor_pkg_test.go +++ b/executor/executor_pkg_test.go @@ -52,9 +52,9 @@ func (msm *mockSessionManager) Kill(cid uint64, query bool) { func (s *testExecSuite) TestShowProcessList(c *C) { // Compose schema. - names := []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info"} + names := []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info", "Mem"} ftypes := []byte{mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar, - mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString} + mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString, mysql.TypeLonglong} schema := buildSchema(names, ftypes) // Compose a mocked session manager. diff --git a/executor/show.go b/executor/show.go index 1224d4a47dca6..a579294453fa1 100644 --- a/executor/show.go +++ b/executor/show.go @@ -204,6 +204,7 @@ func (e *ShowExec) fetchShowProcessList() error { t, fmt.Sprintf("%d", pi.State), info, + pi.Mem, }) } return nil diff --git a/plan/planbuilder.go b/plan/planbuilder.go index 2209b10fad146..b9340b5d14abf 100644 --- a/plan/planbuilder.go +++ b/plan/planbuilder.go @@ -1377,9 +1377,9 @@ func buildShowSchema(s *ast.ShowStmt) (schema *expression.Schema) { mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, } case ast.ShowProcessList: - names = []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info"} + names = []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info", "Mem"} ftypes = []byte{mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar, - mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString} + mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString, mysql.TypeLonglong} case ast.ShowStatsMeta: names = []string{"Db_name", "Table_name", "Update_time", "Modify_count", "Row_count"} ftypes = []byte{mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeDatetime, mysql.TypeLonglong, mysql.TypeLonglong} diff --git a/session/session.go b/session/session.go index 3d841e4662545..c080d76c93edb 100644 --- a/session/session.go +++ b/session/session.go @@ -1380,6 +1380,7 @@ func (s *session) ShowProcess() util.ProcessInfo { tmp := s.processInfo.Load() if tmp != nil { pi = tmp.(util.ProcessInfo) + pi.Mem = s.GetSessionVars().StmtCtx.MemTracker.BytesConsumed() } return pi } diff --git a/util/processinfo.go b/util/processinfo.go index c719ff62b0611..2d204c8a2a5c5 100644 --- a/util/processinfo.go +++ b/util/processinfo.go @@ -27,6 +27,7 @@ type ProcessInfo struct { Time time.Time State uint16 Info string + Mem int64 } // SessionManager is an interface for session manage. Show processlist and