Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: support ACCOUNT (UN)LOCK when creating/altering user #37052

Merged
merged 24 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,11 +736,11 @@ func TestPrivileges(t *testing.T) {
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, index idx(a))")
tk.MustExec("create global binding for select * from t using select * from t use index(idx)")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
rows := tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 1)
tk.MustExec("create user test@'%'")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "test", Hostname: "%"}, nil, nil))
rows = tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 0)
}
Expand Down
38 changes: 19 additions & 19 deletions bindinfo/capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestDMLCapturePlanBaseline(t *testing.T) {
rows := tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 0)

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("delete from t where b = 1 and c > 1")
tk.MustExec("delete from t where b = 1 and c > 1")
tk.MustExec("update t set a = 1 where b = 1 and c > 1")
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestCapturePlanBaseline(t *testing.T) {
rows := tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 0)

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t where a > 10")
tk.MustExec("select * from t where a > 10")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestCapturePlanBaseline4DisabledStatus(t *testing.T) {
rows := tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 0)

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t where a > 10")
tk.MustExec("select * from t where a > 10")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestCaptureDBCaseSensitivity(t *testing.T) {
tk.MustExec("use SPM")
tk.MustExec("create table t(a int, b int, key(b))")
tk.MustExec("create global binding for select * from t using select /*+ use_index(t) */ * from t")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select /*+ use_index(t,b) */ * from t")
tk.MustExec("select /*+ use_index(t,b) */ * from t")
tk.MustExec("admin capture bindings")
Expand All @@ -214,7 +214,7 @@ func TestCaptureBaselinesDefaultDB(t *testing.T) {
tk.MustExec("drop database if exists spm")
tk.MustExec("create database spm")
tk.MustExec("create table spm.t(a int, index idx_a(a))")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from spm.t ignore index(idx_a) where a > 10")
tk.MustExec("select * from spm.t ignore index(idx_a) where a > 10")
tk.MustExec("admin capture bindings")
Expand All @@ -241,7 +241,7 @@ func TestCapturePreparedStmt(t *testing.T) {
tk := testkit.NewTestKit(t, store)

stmtsummary.StmtSummaryByDigestMap.Clear()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, c int, key idx_b(b), key idx_c(c))")
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestCapturePlanBaselineIgnoreTiFlash(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int, key(a), key(b))")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t")
tk.MustExec("select * from t")
// Create virtual tiflash replica info.
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestBindingSource(t *testing.T) {
tk.MustExec("SET GLOBAL tidb_capture_plan_baselines = off")
}()
tk.MustExec("use test")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t ignore index(idx_a) where a < 10")
tk.MustExec("select * from t ignore index(idx_a) where a < 10")
tk.MustExec("admin capture bindings")
Expand All @@ -371,7 +371,7 @@ func TestCapturedBindingCharset(t *testing.T) {
tk := testkit.NewTestKit(t, store)

stmtsummary.StmtSummaryByDigestMap.Clear()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("use test")
tk.MustExec("create table t(name varchar(25), index idx(name))")

Expand Down Expand Up @@ -404,7 +404,7 @@ func TestConcurrentCapture(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int, b int)")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t")
tk.MustExec("select * from t")
tk.MustExec("admin capture bindings")
Expand All @@ -424,7 +424,7 @@ func TestUpdateSubqueryCapture(t *testing.T) {
tk.MustExec("create table t1(a int, b int, c int, key idx_b(b))")
tk.MustExec("create table t2(a int, b int)")
stmtsummary.StmtSummaryByDigestMap.Clear()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("update t1 set b = 1 where b = 2 and (a in (select a from t2 where b = 1) or c in (select a from t2 where b = 1))")
tk.MustExec("update t1 set b = 1 where b = 2 and (a in (select a from t2 where b = 1) or c in (select a from t2 where b = 1))")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestIssue20417(t *testing.T) {
stmtsummary.StmtSummaryByDigestMap.Clear()
tk.MustExec("SET GLOBAL tidb_capture_plan_baselines = on")
dom.BindHandle().CaptureBaselines()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t where b=2 and c=213124")
tk.MustExec("select * from t where b=2 and c=213124")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -522,7 +522,7 @@ func TestCaptureWithZeroSlowLogThreshold(t *testing.T) {
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
stmtsummary.StmtSummaryByDigestMap.Clear()
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("set tidb_slow_log_threshold = 0")
tk.MustExec("select * from t")
tk.MustExec("select * from t")
Expand All @@ -548,7 +548,7 @@ func TestIssue25505(t *testing.T) {
tk.MustExec("create table t (a int(11) default null,b int(11) default null,key b (b),key ba (b))")
tk.MustExec("create table t1 (a int(11) default null,b int(11) default null,key idx_ab (a,b),key idx_a (a),key idx_b (b))")
tk.MustExec("create table t2 (a int(11) default null,b int(11) default null,key idx_ab (a,b),key idx_a (a),key idx_b (b))")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))

spmMap := map[string]string{}
spmMap["with recursive `cte` ( `a` ) as ( select ? union select `a` + ? from `test` . `t1` where `a` < ? ) select * from `cte`"] =
Expand Down Expand Up @@ -615,7 +615,7 @@ func TestCaptureUserFilter(t *testing.T) {
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t where a > 10")
tk.MustExec("select * from t where a > 10")
tk.MustExec("admin capture bindings")
Expand All @@ -638,7 +638,7 @@ func TestCaptureUserFilter(t *testing.T) {
tk.MustExec(`grant all on *.* to usr1 with grant option`)
tk2 := testkit.NewTestKit(t, store)
tk2.MustExec("use test")
require.True(t, tk2.Session().Auth(&auth.UserIdentity{Username: "usr1", Hostname: "%"}, nil, nil))
require.NoError(t, tk2.Session().Auth(&auth.UserIdentity{Username: "usr1", Hostname: "%"}, nil, nil))
tk2.MustExec("select * from t where a > 10")
tk2.MustExec("select * from t where a > 10")
tk2.MustExec("admin capture bindings")
Expand Down Expand Up @@ -702,7 +702,7 @@ func TestCaptureWildcardFilter(t *testing.T) {
tk.MustExec("SET GLOBAL tidb_capture_plan_baselines = off")
}()

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
dbs := []string{"db11", "db12", "db2"}
tbls := []string{"t11", "t12", "t2"}
for _, db := range dbs {
Expand Down Expand Up @@ -808,7 +808,7 @@ func TestCaptureFilter(t *testing.T) {
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")

require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("select * from t where a > 10")
tk.MustExec("select * from t where a > 10")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -960,7 +960,7 @@ func TestCaptureHints(t *testing.T) {
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(pk int primary key, a int, b int, key(a), key(b))")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))

captureCases := []struct {
query string
Expand Down
4 changes: 2 additions & 2 deletions bindinfo/session_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func TestBaselineDBLowerCase(t *testing.T) {
tk.MustExec("create database SPM")
tk.MustExec("use SPM")
tk.MustExec("create table t(a int, b int)")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("update t set a = a + 1")
tk.MustExec("update t set a = a + 1")
tk.MustExec("admin capture bindings")
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestShowGlobalBindings(t *testing.T) {
tk.MustExec("use SPM")
tk.MustExec("create table t(a int, b int, key(a))")
tk.MustExec("create table t0(a int, b int, key(a))")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
rows := tk.MustQuery("show global bindings").Rows()
require.Len(t, rows, 0)
// Simulate existing bindings in the mysql.bind_info.
Expand Down
2 changes: 1 addition & 1 deletion ddl/db_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestIssue34069(t *testing.T) {
defer sem.Disable()

tk := testkit.NewTestKit(t, store)
tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil)
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("use test;")
tk.MustExec("create table t_34069 (t int);")
// No error when SEM is enabled.
Expand Down
10 changes: 5 additions & 5 deletions ddl/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestCreateSequence(t *testing.T) {
tk1 := testkit.NewTestKit(t, store)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
require.True(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
tk1.SetSession(se)

// grant the myuser the access to database test.
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestDropSequence(t *testing.T) {
tk1 := testkit.NewTestKit(t, store)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
require.True(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
tk1.SetSession(se)

// grant the myuser the access to database test.
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestShowCreateSequence(t *testing.T) {
tk1 := testkit.NewTestKit(t, store)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
require.True(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
tk1.SetSession(se)

// Grant the myuser the access to table t in database test, but sequence seq.
Expand Down Expand Up @@ -910,7 +910,7 @@ func TestSequenceFunctionPrivilege(t *testing.T) {
tk1 := testkit.NewTestKit(t, store)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
require.True(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
tk1.SetSession(se)

// grant the myuser the create access to the sequence.
Expand Down Expand Up @@ -1103,7 +1103,7 @@ func TestAlterSequencePrivilege(t *testing.T) {
tk1 := testkit.NewTestKit(t, store)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)
require.True(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, se.Auth(&auth.UserIdentity{Username: "myuser", Hostname: "localhost"}, nil, nil))
tk1.SetSession(se)

// grant the myuser the access to database test.
Expand Down
1 change: 1 addition & 0 deletions errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ const (
ErrGeneratedColumnNonPrior = 3107
ErrDependentByGeneratedColumn = 3108
ErrGeneratedColumnRefAutoInc = 3109
ErrAccountHasBeenLocked = 3118
ErrWarnConflictingHint = 3126
ErrUnresolvedHintName = 3128
ErrInvalidJSONText = 3140
Expand Down
1 change: 1 addition & 0 deletions errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrGeneratedColumnNonPrior: mysql.Message("Generated column can refer only to generated columns defined prior to it.", nil),
ErrDependentByGeneratedColumn: mysql.Message("Column '%s' has a generated column dependency.", nil),
ErrGeneratedColumnRefAutoInc: mysql.Message("Generated column '%s' cannot refer to auto-increment column.", nil),
ErrAccountHasBeenLocked: mysql.Message("Access denied for user '%s'@'%s'. Account is locked.", nil),
ErrWarnConflictingHint: mysql.Message("Hint %s is ignored as conflicting/duplicated.", nil),
ErrUnresolvedHintName: mysql.Message("Unresolved name '%s' for %s hint", nil),
ErrInvalidFieldSize: mysql.Message("Invalid size for column '%s'.", nil),
Expand Down
14 changes: 7 additions & 7 deletions executor/cluster_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestSQLDigestTextRetriever(t *testing.T) {

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("insert into test_sql_digest_text_retriever values (1, 1)")

insertNormalized, insertDigest := parser.NormalizeDigest("insert into test_sql_digest_text_retriever values (1, 1)")
Expand All @@ -307,7 +307,7 @@ func TestFunctionDecodeSQLDigests(t *testing.T) {

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("set global tidb_enable_stmt_summary = 1")
tk.MustQuery("select @@global.tidb_enable_stmt_summary").Check(testkit.Rows("1"))
tk.MustExec("drop table if exists test_func_decode_sql_digests")
Expand Down Expand Up @@ -366,21 +366,21 @@ func TestFunctionDecodeSQLDigestsPrivilege(t *testing.T) {
defer srv.Stop()

dropUserTk := testkit.NewTestKit(t, store)
require.True(t, dropUserTk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, dropUserTk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))

tk := testkit.NewTestKit(t, store)
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("create user 'testuser'@'localhost'")
defer dropUserTk.MustExec("drop user 'testuser'@'localhost'")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "testuser", Hostname: "localhost"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "testuser", Hostname: "localhost"}, nil, nil))
tk.MustGetErrMsg("select tidb_decode_sql_digests('[\"aa\"]')", "[expression:1227]Access denied; you need (at least one of) the PROCESS privilege(s) for this operation")

tk = testkit.NewTestKit(t, store)
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("create user 'testuser2'@'localhost'")
defer dropUserTk.MustExec("drop user 'testuser2'@'localhost'")
tk.MustExec("grant process on *.* to 'testuser2'@'localhost'")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "testuser2", Hostname: "localhost"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "testuser2", Hostname: "localhost"}, nil, nil))
tk.MustExec("select tidb_decode_sql_digests('[\"aa\"]')")
}

Expand Down
2 changes: 1 addition & 1 deletion executor/executor_issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ func TestIndexJoin31494(t *testing.T) {
dom.ExpensiveQueryHandle().SetSessionManager(sm)
defer tk.MustExec("SET GLOBAL tidb_mem_oom_action = DEFAULT")
tk.MustExec("SET GLOBAL tidb_mem_oom_action='CANCEL'")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("set @@tidb_mem_quota_query=2097152;")
// This bug will be reproduced in 10 times.
for i := 0; i < 10; i++ {
Expand Down
2 changes: 1 addition & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5937,7 +5937,7 @@ func TestSummaryFailedUpdate(t *testing.T) {
dom.ExpensiveQueryHandle().SetSessionManager(sm)
defer tk.MustExec("SET GLOBAL tidb_mem_oom_action = DEFAULT")
tk.MustExec("SET GLOBAL tidb_mem_oom_action='CANCEL'")
require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
tk.MustExec("set @@tidb_mem_quota_query=1")
tk.MustMatchErrMsg("update t set t.a = t.a - 1 where t.a in (select a from t where a < 4)", "Out Of Memory Quota!.*")
tk.MustExec("set @@tidb_mem_quota_query=1000000000")
Expand Down
Loading