Skip to content

Commit

Permalink
session: set Sleep state for process info (#7826) (#7839)
Browse files Browse the repository at this point in the history
  • Loading branch information
coocood authored Oct 8, 2018
1 parent 6a1e94f commit 8823f12
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,3 +526,17 @@ func (ts *TidbTestSuite) TestSumAvg(c *C) {
c.Parallel()
runTestSumAvg(c)
}

func (ts *TidbTestSuite) TestShowProcess(c *C) {
qctx, err := ts.tidbdrv.OpenCtx(uint64(0), 0, uint8(tmysql.DefaultCollationID), "test", nil)
c.Assert(err, IsNil)
ctx := context.Background()
results, err := qctx.Execute(ctx, "select 1")
c.Assert(err, IsNil)
pi := qctx.ShowProcess()
c.Assert(pi.Command, Equals, "Query")
results[0].Close()
pi = qctx.ShowProcess()
c.Assert(pi.Command, Equals, "Sleep")
qctx.Close()
}
3 changes: 3 additions & 0 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,9 @@ func (s *session) SetProcessInfo(sql string) {
State: s.Status(),
Info: sql,
}
if sql == "" {
pi.Command = "Sleep"
}
if s.sessionVars.User != nil {
pi.User = s.sessionVars.User.Username
pi.Host = s.sessionVars.User.Hostname
Expand Down

0 comments on commit 8823f12

Please sign in to comment.