diff --git a/.bazelrc b/.bazelrc index 8339fc80e2d67..61356f086fda5 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,4 @@ -startup --host_jvm_args=-Xmx5g +startup --host_jvm_args=-Xmx8g startup --unlimit_coredumps run:ci --color=yes diff --git a/ddl/sequence_test.go b/ddl/sequence_test.go index df58df12b0ebd..9b798c9f45eea 100644 --- a/ddl/sequence_test.go +++ b/ddl/sequence_test.go @@ -62,8 +62,7 @@ func TestCreateSequence(t *testing.T) { // test unsupported table option in sequence. tk.MustGetErrCode("create sequence seq CHARSET=utf8", mysql.ErrSequenceUnsupportedTableOption) - _, err := tk.Exec("create sequence seq comment=\"test\"") - require.NoError(t, err) + tk.MustExec("create sequence seq comment=\"test\"") sequenceTable := external.GetTableByName(t, tk, "test", "seq") diff --git a/executor/admin_test.go b/executor/admin_test.go index 23b57e9c316b6..41b926cf2c377 100644 --- a/executor/admin_test.go +++ b/executor/admin_test.go @@ -133,7 +133,7 @@ func TestAdminCheckIndexInLocalTemporaryMode(t *testing.T) { tk.MustExec("drop table if exists local_temporary_admin_test;") tk.MustExec("create temporary table local_temporary_admin_test (c1 int, c2 int, c3 int default 1, primary key (c1), index (c1), unique key(c2))") tk.MustExec("insert local_temporary_admin_test (c1, c2) values (1,1), (2,2), (3,3);") - _, err := tk.Exec("admin check table local_temporary_admin_test;") + err := tk.ExecToErr("admin check table local_temporary_admin_test;") require.EqualError(t, err, core.ErrOptOnTemporaryTable.GenWithStackByArgs("admin check table").Error()) tk.MustExec("drop table if exists temporary_admin_test;") diff --git a/executor/autoidtest/autoid_test.go b/executor/autoidtest/autoid_test.go index d191e52e38cdf..7823a7488bf98 100644 --- a/executor/autoidtest/autoid_test.go +++ b/executor/autoidtest/autoid_test.go @@ -734,8 +734,7 @@ func TestAlterTableAutoIDCache(t *testing.T) { // Note that auto_id_cache=1 use a different implementation, switch between them is not allowed. // TODO: relax this restriction and update the test case. - _, err = tk.Exec("alter table t_473 auto_id_cache = 1") - require.Error(t, err) + tk.MustExecToErr("alter table t_473 auto_id_cache = 1") } func TestMockAutoIDServiceError(t *testing.T) { diff --git a/executor/executor_test.go b/executor/executor_test.go index 0bdfe1199eb61..bd64c39e5a134 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -4623,13 +4623,10 @@ func TestUnion2(t *testing.T) { terr = errors.Cause(err).(*terror.Error) require.Equal(t, errors.ErrCode(mysql.ErrWrongUsage), terr.Code()) - _, err = tk.Exec("(select a from t order by a) union all select a from t limit 1 union all select a from t limit 1") - require.Truef(t, terror.ErrorEqual(err, plannercore.ErrWrongUsage), "err %v", err) + tk.MustGetDBError("(select a from t order by a) union all select a from t limit 1 union all select a from t limit 1", plannercore.ErrWrongUsage) - _, err = tk.Exec("(select a from t limit 1) union all select a from t limit 1") - require.NoError(t, err) - _, err = tk.Exec("(select a from t order by a) union all select a from t order by a") - require.NoError(t, err) + tk.MustExec("(select a from t limit 1) union all select a from t limit 1") + tk.MustExec("(select a from t order by a) union all select a from t order by a") tk.MustExec("drop table if exists t") tk.MustExec("create table t(a int)") @@ -4700,8 +4697,8 @@ func TestUnion2(t *testing.T) { tk.MustExec("insert into t2 values(3,'c'),(4,'d'),(5,'f'),(6,'e')") tk.MustExec("analyze table t1") tk.MustExec("analyze table t2") - _, err = tk.Exec("(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b") - require.Equal(t, "[planner:1250]Table 't1' from one of the SELECTs cannot be used in global ORDER clause", err.Error()) + tk.MustGetErrMsg("(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b", + "[planner:1250]Table 't1' from one of the SELECTs cannot be used in global ORDER clause") // #issue 9900 tk.MustExec("drop table if exists t") @@ -4855,15 +4852,11 @@ func TestSQLMode(t *testing.T) { tk.MustExec("drop table if exists t") tk.MustExec("create table t (a tinyint not null)") tk.MustExec("set sql_mode = 'STRICT_TRANS_TABLES'") - _, err := tk.Exec("insert t values ()") - require.Error(t, err) - - _, err = tk.Exec("insert t values ('1000')") - require.Error(t, err) + tk.ExecToErr("insert t values ()") + tk.ExecToErr("insert t values ('1000')") tk.MustExec("create table if not exists tdouble (a double(3,2))") - _, err = tk.Exec("insert tdouble values (10.23)") - require.Error(t, err) + tk.ExecToErr("insert tdouble values (10.23)") tk.MustExec("set sql_mode = ''") tk.MustExec("insert t values ()") @@ -4891,8 +4884,7 @@ func TestSQLMode(t *testing.T) { tk2.MustQuery("select * from t2").Check(testkit.Rows("abc")) // session1 is still in strict mode. - _, err = tk.Exec("insert t2 values ('abcd')") - require.Error(t, err) + tk.ExecToErr("insert t2 values ('abcd')") // Restore original global strict mode. tk.MustExec("set @@global.sql_mode = 'STRICT_TRANS_TABLES'") } diff --git a/executor/grant_test.go b/executor/grant_test.go index 517bc716c2a40..3a7720d620673 100644 --- a/executor/grant_test.go +++ b/executor/grant_test.go @@ -99,10 +99,10 @@ func TestGrantDBScope(t *testing.T) { } // Grant in wrong scope. - _, err := tk.Exec(` grant create user on test.* to 'testDB1'@'localhost';`) + err := tk.ExecToErr(` grant create user on test.* to 'testDB1'@'localhost';`) require.True(t, terror.ErrorEqual(err, executor.ErrWrongUsage.GenWithStackByArgs("DB GRANT", "GLOBAL PRIVILEGES"))) - _, err = tk.Exec("GRANT SUPER ON test.* TO 'testDB1'@'localhost';") + err = tk.ExecToErr("GRANT SUPER ON test.* TO 'testDB1'@'localhost';") require.True(t, terror.ErrorEqual(err, executor.ErrWrongUsage.GenWithStackByArgs("DB GRANT", "NON-DB PRIVILEGES"))) } @@ -168,8 +168,8 @@ func TestGrantTableScope(t *testing.T) { require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1) } - _, err := tk.Exec("GRANT SUPER ON test2 TO 'testTbl1'@'localhost';") - require.EqualError(t, err, "[executor:1144]Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used") + tk.MustGetErrMsg("GRANT SUPER ON test2 TO 'testTbl1'@'localhost';", + "[executor:1144]Illegal GRANT/REVOKE command; please consult the manual to see which privileges can be used") } func TestGrantColumnScope(t *testing.T) { @@ -213,8 +213,8 @@ func TestGrantColumnScope(t *testing.T) { require.Greater(t, strings.Index(p, mysql.Priv2SetStr[v]), -1) } - _, err := tk.Exec("GRANT SUPER(c2) ON test3 TO 'testCol1'@'localhost';") - require.EqualError(t, err, "[executor:1221]Incorrect usage of COLUMN GRANT and NON-COLUMN PRIVILEGES") + tk.MustGetErrMsg("GRANT SUPER(c2) ON test3 TO 'testCol1'@'localhost';", + "[executor:1221]Incorrect usage of COLUMN GRANT and NON-COLUMN PRIVILEGES") } func TestIssue2456(t *testing.T) { diff --git a/executor/seqtest/seq_executor_test.go b/executor/seqtest/seq_executor_test.go index 849ad5cdbfa37..6c042340740e8 100644 --- a/executor/seqtest/seq_executor_test.go +++ b/executor/seqtest/seq_executor_test.go @@ -900,7 +900,7 @@ func TestPrepareMaxParamCountCheck(t *testing.T) { require.NoError(t, err) bigSQL, bigParams := generateBatchSQL(math.MaxUint16 + 2) - _, err = tk.Exec(bigSQL, bigParams...) + err = tk.ExecToErr(bigSQL, bigParams...) require.Error(t, err) require.EqualError(t, err, "[executor:1390]Prepared statement contains too many placeholders") } @@ -987,16 +987,12 @@ func TestBatchInsertDelete(t *testing.T) { // Test tidb_batch_insert could not work if enable-batch-dml is disabled. tk.MustExec("set @@session.tidb_batch_insert=1;") - _, err = tk.Exec("insert into batch_insert (c) select * from batch_insert;") - require.Error(t, err) - require.True(t, kv.ErrTxnTooLarge.Equal(err)) + tk.MustGetErrCode("insert into batch_insert (c) select * from batch_insert;", errno.ErrTxnTooLarge) tk.MustExec("set @@session.tidb_batch_insert=0;") // for on duplicate key - _, err = tk.Exec(`insert into batch_insert_on_duplicate select * from batch_insert_on_duplicate as tt - on duplicate key update batch_insert_on_duplicate.id=batch_insert_on_duplicate.id+1000;`) - require.Error(t, err) - require.Truef(t, kv.ErrTxnTooLarge.Equal(err), "%v", err) + tk.MustGetErrCode(`insert into batch_insert_on_duplicate select * from batch_insert_on_duplicate as tt + on duplicate key update batch_insert_on_duplicate.id=batch_insert_on_duplicate.id+1000;`, errno.ErrTxnTooLarge) r = tk.MustQuery("select count(*) from batch_insert;") r.Check(testkit.Rows("320")) @@ -1022,17 +1018,14 @@ func TestBatchInsertDelete(t *testing.T) { tk.MustExec("set @@session.tidb_dml_batch_size=50;") // for on duplicate key - _, err = tk.Exec(`insert into batch_insert_on_duplicate select * from batch_insert_on_duplicate as tt + tk.MustExec(`insert into batch_insert_on_duplicate select * from batch_insert_on_duplicate as tt on duplicate key update batch_insert_on_duplicate.id=batch_insert_on_duplicate.id+1000;`) - require.NoError(t, err) r = tk.MustQuery("select count(*) from batch_insert_on_duplicate;") r.Check(testkit.Rows("320")) // Disable BachInsert mode in transition. tk.MustExec("begin;") - _, err = tk.Exec("insert into batch_insert (c) select * from batch_insert;") - require.Error(t, err) - require.True(t, kv.ErrTxnTooLarge.Equal(err)) + tk.MustGetErrCode("insert into batch_insert (c) select * from batch_insert;", errno.ErrTxnTooLarge) tk.MustExec("rollback;") r = tk.MustQuery("select count(*) from batch_insert;") r.Check(testkit.Rows("640"))