Skip to content

Commit

Permalink
executor: show warning for kill pid statement (pingcap#5210)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojian cai authored and winoros committed Nov 29, 2017
1 parent d8fa8ef commit f49413e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions executor/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ func (e *SimpleExec) executeKillStmt(s *ast.KillStmt) error {
return nil
}
sm.Kill(s.ConnectionID, s.Query)
} else {
err := errors.New("Invalid operation. Please use 'KILL TIDB [CONNECTION | QUERY] connectionID' instead")
e.ctx.GetSessionVars().StmtCtx.AppendWarning(err)
}
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions executor/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ func (s *testSuite) TestSetPwd(c *C) {
result.Check(testkit.Rows(auth.EncodePassword("pwd")))
}

func (s *testSuite) TestKillStmt(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("kill 1")

result := tk.MustQuery("show warnings")
result.Check(testkit.Rows("Warning 1105 Invalid operation. Please use 'KILL TIDB [CONNECTION | QUERY] connectionID' instead"))
}

func (s *testSuite) TestFlushPrivileges(c *C) {
// Global variables is really bad, when the test cases run concurrently.
save := privileges.Enable
Expand Down

0 comments on commit f49413e

Please sign in to comment.