Skip to content

Commit 8823f12

Browse files
authored
session: set Sleep state for process info (#7826) (#7839)
1 parent 6a1e94f commit 8823f12

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

server/tidb_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -526,3 +526,17 @@ func (ts *TidbTestSuite) TestSumAvg(c *C) {
526526
c.Parallel()
527527
runTestSumAvg(c)
528528
}
529+
530+
func (ts *TidbTestSuite) TestShowProcess(c *C) {
531+
qctx, err := ts.tidbdrv.OpenCtx(uint64(0), 0, uint8(tmysql.DefaultCollationID), "test", nil)
532+
c.Assert(err, IsNil)
533+
ctx := context.Background()
534+
results, err := qctx.Execute(ctx, "select 1")
535+
c.Assert(err, IsNil)
536+
pi := qctx.ShowProcess()
537+
c.Assert(pi.Command, Equals, "Query")
538+
results[0].Close()
539+
pi = qctx.ShowProcess()
540+
c.Assert(pi.Command, Equals, "Sleep")
541+
qctx.Close()
542+
}

session/session.go

+3
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ func (s *session) SetProcessInfo(sql string) {
712712
State: s.Status(),
713713
Info: sql,
714714
}
715+
if sql == "" {
716+
pi.Command = "Sleep"
717+
}
715718
if s.sessionVars.User != nil {
716719
pi.User = s.sessionVars.User.Username
717720
pi.Host = s.sessionVars.User.Hostname

0 commit comments

Comments
 (0)