From f00bcea5d51bb49875fe38afb1c7ebe3850ae629 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 23 May 2018 15:51:18 +0800 Subject: [PATCH 01/15] fix drop user bug --- executor/simple.go | 7 +++++++ executor/simple_test.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/executor/simple.go b/executor/simple.go index 077b5b4f4a489..ce0aedc13aa76 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -232,6 +232,13 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) + + if user.Hostname == "%" { + sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Username) + } else { + sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) + } + _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) if err != nil { failedUsers = append(failedUsers, user.String()) } diff --git a/executor/simple_test.go b/executor/simple_test.go index eabeea8af3de6..983f17bc6f5dc 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -177,6 +177,12 @@ func (s *testSuite) TestUser(c *C) { tk.MustExec(createUserSQL) dropUserSQL = `DROP USER 'test1'@'localhost';` tk.MustExec(dropUserSQL) + tk.MustQuery("select * from mysql.db").Check(testkit.Rows( + "localhost test testDB Y Y Y Y Y Y Y N Y Y N N N N N N Y N N", + "localhost test testDB1 Y Y Y Y Y Y Y N Y Y N N N N N N Y N N] [% dddb_% dduser Y Y Y Y Y Y Y N Y Y N N N N N N Y N N", + "% test test Y N N N N N N N N N N N N N N N N N N", + "localhost test testDBRevoke N N N N N N N N N N N N N N N N N N N", + )) } func (s *testSuite) TestSetPwd(c *C) { From a739674170053f711ba7d1affb662276cfdfae65 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 23 May 2018 19:31:27 +0800 Subject: [PATCH 02/15] address reviewer's comment --- executor/simple.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/executor/simple.go b/executor/simple.go index ce0aedc13aa76..113fe786e2b86 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -232,6 +232,10 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) + if err != nil { + failedUsers = append(failedUsers, user.String()) + err = nil + } if user.Hostname == "%" { sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Username) From f95fcfa2cffdb619707c739d2a9cd0f5b7552259 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 23 May 2018 19:34:11 +0800 Subject: [PATCH 03/15] address reviewer's comment --- executor/simple.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index 113fe786e2b86..75386cc94f10d 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -234,7 +234,6 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) if err != nil { failedUsers = append(failedUsers, user.String()) - err = nil } if user.Hostname == "%" { @@ -242,8 +241,8 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { } else { sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) } - _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) - if err != nil { + _, _, err2 := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) + if err2 != nil { failedUsers = append(failedUsers, user.String()) } } From 00123ea7853fa8710f7b9350a0fd2b6664446214 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Thu, 24 May 2018 13:51:08 +0800 Subject: [PATCH 04/15] delete privileges from mysql.tables_priv --- executor/simple.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index 75386cc94f10d..b391c2103e37c 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -236,15 +236,21 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { failedUsers = append(failedUsers, user.String()) } - if user.Hostname == "%" { - sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Username) - } else { - sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) - } + // delete privileges from mysql.db + sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) _, _, err2 := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) if err2 != nil { failedUsers = append(failedUsers, user.String()) } + + // delete privileges from mysql.tables_priv + sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.TablePrivTable, user.Hostname, user.Username) + _, _, err3 := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) + if err3 != nil { + failedUsers = append(failedUsers, user.String()) + } + + //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. } if len(failedUsers) > 0 { // Commit the transaction even if we returns error From 7791b938899c71191ef2207b258206966772a36d Mon Sep 17 00:00:00 2001 From: zhexuany Date: Thu, 24 May 2018 15:17:03 +0800 Subject: [PATCH 05/15] address reviewer's comment --- executor/simple.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index b391c2103e37c..e3cf4e3b526b9 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -230,36 +230,36 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { } continue } + + // begin a transaction to delete. + if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "begin"); err != nil { + return errors.Trace("Failed to begin a transaction during drop user.") + } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) - _, _, err = e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) - if err != nil { + if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { failedUsers = append(failedUsers, user.String()) } // delete privileges from mysql.db sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) - _, _, err2 := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) - if err2 != nil { + if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { failedUsers = append(failedUsers, user.String()) } // delete privileges from mysql.tables_priv sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.TablePrivTable, user.Hostname, user.Username) - _, _, err3 := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql) - if err3 != nil { + if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { failedUsers = append(failedUsers, user.String()) } //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. + if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "commit"); err != nil { + return errors.Trace("Failed to commit a transaction during drop user.") + } } if len(failedUsers) > 0 { - // Commit the transaction even if we returns error - err := e.ctx.Txn().Commit(sessionctx.SetCommitCtx(context.Background(), e.ctx)) - if err != nil { - return errors.Trace(err) - } errMsg := "Operation DROP USER failed for " + strings.Join(failedUsers, ",") - return terror.ClassExecutor.New(CodeCannotUser, errMsg) + eturn terror.ClassExecutor.New(CodeCannotUser, errMsg) } domain.GetDomain(e.ctx).NotifyUpdatePrivilege(e.ctx) return nil From 602a2750e3ce8427836bf7d36b4bc837f03ab000 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Thu, 24 May 2018 15:20:37 +0800 Subject: [PATCH 06/15] correct typo --- executor/simple.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/simple.go b/executor/simple.go index e3cf4e3b526b9..cc25b6068087a 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -259,7 +259,7 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { } if len(failedUsers) > 0 { errMsg := "Operation DROP USER failed for " + strings.Join(failedUsers, ",") - eturn terror.ClassExecutor.New(CodeCannotUser, errMsg) + return terror.ClassExecutor.New(CodeCannotUser, errMsg) } domain.GetDomain(e.ctx).NotifyUpdatePrivilege(e.ctx) return nil From 3f5ec4a81a9b25e869a34972d058347162dd1801 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Thu, 24 May 2018 15:22:50 +0800 Subject: [PATCH 07/15] use errors.New --- executor/simple.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index cc25b6068087a..a898b9d443624 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -233,7 +233,7 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { // begin a transaction to delete. if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "begin"); err != nil { - return errors.Trace("Failed to begin a transaction during drop user.") + return errors.Trace(errors.New("Failed to begin a transaction during drop user.")) } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { @@ -254,7 +254,7 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "commit"); err != nil { - return errors.Trace("Failed to commit a transaction during drop user.") + return errors.Trace(errors.New("Failed to commit a transaction during drop user.")) } } if len(failedUsers) > 0 { From 20545687735a69ff6b0f8b1bb4a333680b793267 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Thu, 24 May 2018 17:14:02 +0800 Subject: [PATCH 08/15] avoid use restrictedSQL mode --- executor/simple.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index a898b9d443624..d9bcae26f55cc 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -231,33 +231,39 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { continue } - // begin a transaction to delete. - if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "begin"); err != nil { - return errors.Trace(errors.New("Failed to begin a transaction during drop user.")) + // begin a transaction to delete a user. + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "begin"); err != nil { + fmt.Println(err) + return errors.Trace(err) } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) - if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) } // delete privileges from mysql.db sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) - if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) } // delete privileges from mysql.tables_priv sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.TablePrivTable, user.Hostname, user.Username) - if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, sql); err != nil { + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) } //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. - if _, _, err := e.ctx.(sqlexec.RestrictedSQLExecutor).ExecRestrictedSQL(e.ctx, "commit"); err != nil { - return errors.Trace(errors.New("Failed to commit a transaction during drop user.")) + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "commit"); err != nil { + return errors.Trace(err) } } if len(failedUsers) > 0 { + // Commit the transaction even if we returns error + // err := e.ctx.Txn().Commit(sessionctx.SetCommitCtx(context.Background(), e.ctx)) + // if err != nil { + // return errors.Trace(err) + // } errMsg := "Operation DROP USER failed for " + strings.Join(failedUsers, ",") return terror.ClassExecutor.New(CodeCannotUser, errMsg) } From ba992960f573615ccc3df7f6097c0073101bfb03 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Fri, 25 May 2018 14:13:12 +0800 Subject: [PATCH 09/15] address reviewer's comment --- executor/simple.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/executor/simple.go b/executor/simple.go index d9bcae26f55cc..193d4739ecec2 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -255,15 +255,10 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "commit"); err != nil { - return errors.Trace(err) + failedUsers = append(failedUsers, user.String()) } } if len(failedUsers) > 0 { - // Commit the transaction even if we returns error - // err := e.ctx.Txn().Commit(sessionctx.SetCommitCtx(context.Background(), e.ctx)) - // if err != nil { - // return errors.Trace(err) - // } errMsg := "Operation DROP USER failed for " + strings.Join(failedUsers, ",") return terror.ClassExecutor.New(CodeCannotUser, errMsg) } From 89e5973e7ca70388aa132ac02b6df27e6a880345 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 30 May 2018 09:31:47 +0800 Subject: [PATCH 10/15] remove debug code --- executor/simple.go | 1 - 1 file changed, 1 deletion(-) diff --git a/executor/simple.go b/executor/simple.go index 193d4739ecec2..237eba98dccb5 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -233,7 +233,6 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { // begin a transaction to delete a user. if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "begin"); err != nil { - fmt.Println(err) return errors.Trace(err) } sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) From 542dde55091aa395c051179898c14a03973f6fc5 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Mon, 4 Jun 2018 15:03:54 +0800 Subject: [PATCH 11/15] address reviewer's comment --- executor/simple.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/executor/simple.go b/executor/simple.go index 237eba98dccb5..5d8f86ce597f3 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -252,7 +252,7 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { failedUsers = append(failedUsers, user.String()) } - //TODO: (tidb-team) need delete columns_priv once we implement columns_priv functionality. + //TODO: need delete columns_priv once we implement columns_priv functionality. if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "commit"); err != nil { failedUsers = append(failedUsers, user.String()) } From 9c625136bf9a683c91c9cd06c5b1f8d0c8c352e0 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Tue, 5 Jun 2018 16:10:42 +0800 Subject: [PATCH 12/15] rollback when meet failure during batch delete stmts --- executor/simple.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/executor/simple.go b/executor/simple.go index 5d8f86ce597f3..0ef744f642aca 100644 --- a/executor/simple.go +++ b/executor/simple.go @@ -238,18 +238,30 @@ func (e *SimpleExec) executeDropUser(s *ast.DropUserStmt) error { sql := fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.UserTable, user.Hostname, user.Username) if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "rollback"); err != nil { + return errors.Trace(err) + } + continue } // delete privileges from mysql.db sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.DBTable, user.Hostname, user.Username) if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "rollback"); err != nil { + return errors.Trace(err) + } + continue } // delete privileges from mysql.tables_priv sql = fmt.Sprintf(`DELETE FROM %s.%s WHERE Host = "%s" and User = "%s";`, mysql.SystemDB, mysql.TablePrivTable, user.Hostname, user.Username) if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), sql); err != nil { failedUsers = append(failedUsers, user.String()) + if _, err := e.ctx.(sqlexec.SQLExecutor).Execute(context.Background(), "rollback"); err != nil { + return errors.Trace(err) + } + continue } //TODO: need delete columns_priv once we implement columns_priv functionality. From 5cbbc29ae1b2916fc1e09accef2fc87c72a137db Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 6 Jun 2018 15:39:37 +0800 Subject: [PATCH 13/15] add a test case when drop user meet failure --- executor/simple_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/executor/simple_test.go b/executor/simple_test.go index 983f17bc6f5dc..354b2888f9a32 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -183,6 +183,8 @@ func (s *testSuite) TestUser(c *C) { "% test test Y N N N N N N N N N N N N N N N N N N", "localhost test testDBRevoke N N N N N N N N N N N N N N N N N N N", )) + _, err = tk.Exec(dropUserSQL) + c.Assert(terror.ErrorEqual(err, terror.ClassExecutor.New(executor.CodeCannotUser, "")), IsTrue) } func (s *testSuite) TestSetPwd(c *C) { From 1f05eef0e36d073437288b12c2625407ce102e83 Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 6 Jun 2018 16:01:35 +0800 Subject: [PATCH 14/15] add batch drop when meet error --- executor/simple_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/executor/simple_test.go b/executor/simple_test.go index 354b2888f9a32..c338850bf5aae 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -183,6 +183,16 @@ func (s *testSuite) TestUser(c *C) { "% test test Y N N N N N N N N N N N N N N N N N N", "localhost test testDBRevoke N N N N N N N N N N N N N N N N N N N", )) + + // Test drop user meet error + _, err = tk.Exec(dropUserSQL) + c.Assert(terror.ErrorEqual(err, terror.ClassExecutor.New(executor.CodeCannotUser, "")), IsTrue) + + createUserSQL = `CREATE USER 'test1'@'localhost'` + createUserSQL = `CREATE USER 'test2'@'localhost'` + tk.Exec(createUserSQL) + + dropUserSQL = `DROP USER 'test1'@'localhost', 'test2'@'localhost', 'test3'@'localhost';` _, err = tk.Exec(dropUserSQL) c.Assert(terror.ErrorEqual(err, terror.ClassExecutor.New(executor.CodeCannotUser, "")), IsTrue) } From ad10072b546946f2ec40aa3eea965fe2a5e87c2b Mon Sep 17 00:00:00 2001 From: zhexuany Date: Wed, 6 Jun 2018 16:34:00 +0800 Subject: [PATCH 15/15] use MustExec instead of exec --- executor/simple_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/executor/simple_test.go b/executor/simple_test.go index c338850bf5aae..06ed2e99dda77 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -189,8 +189,9 @@ func (s *testSuite) TestUser(c *C) { c.Assert(terror.ErrorEqual(err, terror.ClassExecutor.New(executor.CodeCannotUser, "")), IsTrue) createUserSQL = `CREATE USER 'test1'@'localhost'` + tk.MustExec(createUserSQL) createUserSQL = `CREATE USER 'test2'@'localhost'` - tk.Exec(createUserSQL) + tk.MustExec(createUserSQL) dropUserSQL = `DROP USER 'test1'@'localhost', 'test2'@'localhost', 'test3'@'localhost';` _, err = tk.Exec(dropUserSQL)