diff --git a/ddl/db_integration_test.go b/ddl/db_integration_test.go index 4caab8c4fba8e..e4a54fccdf1c6 100644 --- a/ddl/db_integration_test.go +++ b/ddl/db_integration_test.go @@ -72,11 +72,11 @@ func (s *testIntegrationSuite) TestInvalidDefault(c *C) { _, err := tk.Exec("create table t(c1 decimal default 1.7976931348623157E308)") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, types.ErrInvalidDefault), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrInvalidDefault), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("create table t( c1 varchar(2) default 'TiDB');") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, types.ErrInvalidDefault), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrInvalidDefault), IsTrue, Commentf("err %v", err)) } // for issue #3848 @@ -87,15 +87,15 @@ func (s *testIntegrationSuite) TestInvalidNameWhenCreateTable(c *C) { _, err := tk.Exec("create table t(xxx.t.a bigint)") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, ddl.ErrWrongDBName), IsTrue) + c.Assert(terror.ErrorEqual(err, ddl.ErrWrongDBName), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("create table t(test.tttt.a bigint)") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, ddl.ErrWrongTableName), IsTrue) + c.Assert(terror.ErrorEqual(err, ddl.ErrWrongTableName), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("create table t(t.tttt.a bigint)") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, ddl.ErrWrongDBName), IsTrue) + c.Assert(terror.ErrorEqual(err, ddl.ErrWrongDBName), IsTrue, Commentf("err %v", err)) } // for issue #6879 @@ -112,7 +112,7 @@ func (s *testIntegrationSuite) TestCreateTableIfNotExists(c *C) { warnings := tk.Se.GetSessionVars().StmtCtx.GetWarnings() c.Assert(len(warnings), GreaterEqual, 1) lastWarn := warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(infoschema.ErrTableExists, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(infoschema.ErrTableExists, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) c.Assert(lastWarn.Level, Equals, stmtctx.WarnLevelNote) // Test duplicate create-table without `LIKE` clause diff --git a/ddl/schema_test.go b/ddl/schema_test.go index 0e1e833018709..b57d5f7343725 100644 --- a/ddl/schema_test.go +++ b/ddl/schema_test.go @@ -173,7 +173,7 @@ func (s *testSchemaSuite) TestSchema(c *C) { BinlogInfo: &model.HistoryInfo{}, } err := d.doDDLJob(ctx, job) - c.Assert(terror.ErrorEqual(err, infoschema.ErrDatabaseDropExists), IsTrue) + c.Assert(terror.ErrorEqual(err, infoschema.ErrDatabaseDropExists), IsTrue, Commentf("err %v", err)) // Drop a database without a table. dbInfo1 := testSchemaInfo(c, d, "test1") diff --git a/executor/aggregate_test.go b/executor/aggregate_test.go index f096dfed3066c..b02f691a3dcea 100644 --- a/executor/aggregate_test.go +++ b/executor/aggregate_test.go @@ -442,39 +442,39 @@ func (s *testSuite) TestOnlyFullGroupBy(c *C) { // test incompatible with sql_mode = ONLY_FULL_GROUP_BY var err error _, err = tk.Exec("select * from t group by d") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select b-c from t group by b+c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select (b-c)*(b+c), min(a) from t group by b+c, b-c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select b between c and d from t group by b,c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select case b when 1 then c when 2 then d else d end from t group by b,c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select c > (select b from t) from t group by b") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select c is null from t group by b") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select c is true from t group by b") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select (c+b)*d from t group by c,d") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select b in (c,d) from t group by b,c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select b like '%a' from t group by c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select c REGEXP '1.*' from t group by b") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select -b from t group by c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select a, max(b) from t") - c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select sum(a)+b from t") - c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select count(b), c from t") - c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select distinct a, b, count(a) from t") - c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrMixOfGroupFuncAndFields), IsTrue, Commentf("err %v", err)) // test compatible with sql_mode = ONLY_FULL_GROUP_BY tk.MustQuery("select a from t group by a,b,c") tk.MustQuery("select b from t group by b") @@ -503,7 +503,7 @@ func (s *testSuite) TestOnlyFullGroupBy(c *C) { tk.MustQuery("select * from t group by b,d") // test functional depend on a unique null column _, err = tk.Exec("select * from t group by b,c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) // test functional dependency derived from keys in where condition tk.MustQuery("select * from t where c = d group by b, c") tk.MustQuery("select t.*, x.* from t, x where t.a = x.a group by t.a") @@ -511,7 +511,7 @@ func (s *testSuite) TestOnlyFullGroupBy(c *C) { tk.MustQuery("select t.*, x.* from t, x where t.b = x.a group by t.b, t.d") tk.MustQuery("select t.b, x.* from t, x where t.b = x.a group by t.b") _, err = tk.Exec("select t.*, x.* from t, x where t.c = x.a group by t.b, t.c") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) // test functional dependency derived from keys in join tk.MustQuery("select t.*, x.* from t inner join x on t.a = x.a group by t.a") tk.MustQuery("select t.*, x.* from t inner join x on (t.b = x.b and t.d = x.d) group by t.b, x.d") @@ -521,9 +521,9 @@ func (s *testSuite) TestOnlyFullGroupBy(c *C) { tk.MustQuery("select x.b, t.* from t right join x on x.b = t.b group by x.b, t.d") tk.MustQuery("select x.b, t.* from t right join x on t.b = x.b group by x.b, t.d") _, err = tk.Exec("select t.b, x.* from t right join x on t.b = x.b group by t.b, x.d") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select t.b, x.* from t right join x on t.b = x.b group by t.b, x.d") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) // FixMe: test functional dependency of derived table //tk.MustQuery("select * from (select * from t) as e group by a") @@ -534,10 +534,10 @@ func (s *testSuite) TestOnlyFullGroupBy(c *C) { // test order by tk.MustQuery("select c from t group by c,d order by d") _, err = tk.Exec("select c from t group by c order by d") - c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrFieldNotInGroupBy), IsTrue, Commentf("err %v", err)) // test ambiguous column _, err = tk.Exec("select c from t,x group by t.c") - c.Assert(terror.ErrorEqual(err, plan.ErrAmbiguous), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrAmbiguous), IsTrue, Commentf("err %v", err)) } func (s *testSuite) TestHaving(c *C) { diff --git a/executor/ddl_test.go b/executor/ddl_test.go index f91bcf6d3be8e..87c69c5b95ac2 100644 --- a/executor/ddl_test.go +++ b/executor/ddl_test.go @@ -411,11 +411,11 @@ func (s *testSuite) TestSetDDLReorgWorkerCnt(c *C) { tk.MustExec("set tidb_ddl_reorg_worker_cnt = 100") c.Assert(variable.GetDDLReorgWorkerCounter(), Equals, int32(100)) _, err := tk.Exec("set tidb_ddl_reorg_worker_cnt = invalid_val") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) tk.MustExec("set tidb_ddl_reorg_worker_cnt = 100") c.Assert(variable.GetDDLReorgWorkerCounter(), Equals, int32(100)) _, err = tk.Exec("set tidb_ddl_reorg_worker_cnt = -1") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) tk.MustExec("set tidb_ddl_reorg_worker_cnt = 100") res := tk.MustQuery("select @@tidb_ddl_reorg_worker_cnt") diff --git a/executor/executor_test.go b/executor/executor_test.go index 634c5badbd6ea..7a8343240bcdb 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -987,7 +987,7 @@ func (s *testSuite) TestUnion(c *C) { c.Assert(terr.Code(), Equals, terror.ErrCode(mysql.ErrWrongUsage)) _, 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") - c.Assert(terror.ErrorEqual(err, plan.ErrWrongUsage), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrWrongUsage), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("(select a from t limit 1) union all select a from t limit 1") c.Assert(err, IsNil) @@ -1821,7 +1821,7 @@ func (s *testSuite) TestHistoryRead(c *C) { // Set snapshot to a time before save point will fail. _, err := tk.Exec("set @@tidb_snapshot = '2006-01-01 15:04:05.999999'") - c.Assert(terror.ErrorEqual(err, variable.ErrSnapshotTooOld), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrSnapshotTooOld), IsTrue, Commentf("err %v", err)) // SnapshotTS Is not updated if check failed. c.Assert(tk.Se.GetSessionVars().SnapshotTS, Equals, uint64(0)) @@ -1991,7 +1991,7 @@ func (s *testSuite) TestTiDBCurrentTS(c *C) { tk.MustQuery("select @@tidb_current_ts").Check(testkit.Rows("0")) _, err := tk.Exec("set @@tidb_current_ts = '1'") - c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue, Commentf("err %v", err)) } func (s *testSuite) TestSelectForUpdate(c *C) { @@ -2074,9 +2074,9 @@ func (s *testSuite) TestEmptyEnum(c *C) { tk.MustExec("create table t (e enum('Y', 'N'))") tk.MustExec("set sql_mode='STRICT_TRANS_TABLES'") _, err := tk.Exec("insert into t values (0)") - c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue) + c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("insert into t values ('abc')") - c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue) + c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err)) tk.MustExec("set sql_mode=''") tk.MustExec("insert into t values (0)") diff --git a/executor/prepared_test.go b/executor/prepared_test.go index 215b6eb97007f..c22bbcdb699aa 100644 --- a/executor/prepared_test.go +++ b/executor/prepared_test.go @@ -61,7 +61,7 @@ func (s *testSuite) TestPrepared(c *C) { // incorrect SQLs in prepare. issue #3738, SQL in prepare stmt is parsed in DoPrepare. _, err = tk.Exec(`prepare p from "delete from t where a = 7 or 1=1/*' and b = 'p'";`) - c.Assert(terror.ErrorEqual(err, errors.New(`[parser:1064]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*' and b = 'p'' at line 1`)), IsTrue) + c.Assert(terror.ErrorEqual(err, errors.New(`[parser:1064]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/*' and b = 'p'' at line 1`)), IsTrue, Commentf("err %v", err)) // The `stmt_test5` should not be found. _, err = tk.Exec(`set @a = 1; execute stmt_test_5 using @a;`) diff --git a/executor/set_test.go b/executor/set_test.go index a2c7c6c2773e1..c02eabf9e466f 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -252,19 +252,19 @@ func (s *testSuite) TestValidateSetVar(c *C) { tk := testkit.NewTestKit(c, s.store) _, err := tk.Exec("set global tidb_distsql_scan_concurrency='fff';") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set global tidb_distsql_scan_concurrency=-1;") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set @@tidb_distsql_scan_concurrency='fff';") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set @@tidb_distsql_scan_concurrency=-1;") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set @@tidb_batch_delete='ok';") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) tk.MustExec("set @@tidb_batch_delete='On';") tk.MustExec("set @@tidb_batch_delete='oFf';") @@ -272,10 +272,10 @@ func (s *testSuite) TestValidateSetVar(c *C) { tk.MustExec("set @@tidb_batch_delete=0;") _, err = tk.Exec("set @@tidb_batch_delete=3;") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set @@tidb_mem_quota_mergejoin='tidb';") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongValueForVar), IsTrue, Commentf("err %v", err)) tk.MustExec("set @@group_concat_max_len=1") tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect group_concat_max_len value: '1'")) @@ -283,11 +283,11 @@ func (s *testSuite) TestValidateSetVar(c *C) { result.Check(testkit.Rows("4")) _, err = tk.Exec("set @@group_concat_max_len = 18446744073709551616") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) // Test illegal type _, err = tk.Exec("set @@group_concat_max_len='hello'") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) tk.MustExec("set @@default_week_format=-1") tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect default_week_format value: '-1'")) @@ -300,10 +300,10 @@ func (s *testSuite) TestValidateSetVar(c *C) { result.Check(testkit.Rows("7")) _, err = tk.Exec("set @@error_count = 0") - c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("set @@warning_count = 0") - c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrReadOnly), IsTrue, Commentf("err %v", err)) tk.MustExec("set time_zone='SySTeM'") result = tk.MustQuery("select @@time_zone;") diff --git a/executor/simple_test.go b/executor/simple_test.go index bc2b9d505d091..208fcb79caaf2 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -172,7 +172,7 @@ func (s *testSuite) TestUser(c *C) { // Test 'identified by password' createUserSQL = `CREATE USER 'test1'@'localhost' identified by password 'xxx';` _, err = tk.Exec(createUserSQL) - c.Assert(terror.ErrorEqual(executor.ErrPasswordFormat, err), IsTrue) + c.Assert(terror.ErrorEqual(executor.ErrPasswordFormat, err), IsTrue, Commentf("err %v", err)) createUserSQL = `CREATE USER 'test1'@'localhost' identified by password '*3D56A309CD04FA2EEF181462E59011F075C89548';` tk.MustExec(createUserSQL) dropUserSQL = `DROP USER 'test1'@'localhost';` @@ -187,7 +187,7 @@ func (s *testSuite) TestUser(c *C) { // Test drop user meet error _, err = tk.Exec(dropUserSQL) - c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenByArgs("DROP USER", "")), IsTrue) + c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenByArgs("DROP USER", "")), IsTrue, Commentf("err %v", err)) createUserSQL = `CREATE USER 'test1'@'localhost'` tk.MustExec(createUserSQL) @@ -196,7 +196,7 @@ func (s *testSuite) TestUser(c *C) { dropUserSQL = `DROP USER 'test1'@'localhost', 'test2'@'localhost', 'test3'@'localhost';` _, err = tk.Exec(dropUserSQL) - c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenByArgs("DROP USER", "")), IsTrue) + c.Assert(terror.ErrorEqual(err, executor.ErrCannotUser.GenByArgs("DROP USER", "")), IsTrue, Commentf("err %v", err)) } func (s *testSuite) TestSetPwd(c *C) { @@ -223,7 +223,7 @@ func (s *testSuite) TestSetPwd(c *C) { ctx.GetSessionVars().User = &auth.UserIdentity{Username: "testpwd1", Hostname: "localhost"} // Session user doesn't exist. _, err = tk.Exec(setPwdSQL) - c.Check(terror.ErrorEqual(err, executor.ErrPasswordNoMatch), IsTrue) + c.Check(terror.ErrorEqual(err, executor.ErrPasswordNoMatch), IsTrue, Commentf("err %v", err)) // normal ctx.GetSessionVars().User = &auth.UserIdentity{Username: "testpwd", Hostname: "localhost"} tk.MustExec(setPwdSQL) diff --git a/executor/statement_context_test.go b/executor/statement_context_test.go index 4601a8ee2c979..5808488fed575 100644 --- a/executor/statement_context_test.go +++ b/executor/statement_context_test.go @@ -71,7 +71,7 @@ func (s *testSuite) TestStatementContext(c *C) { tk.MustExec(strictModeSQL) _, err = tk.Exec("insert sc2 values (unhex('4040ffff'))") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, table.ErrTruncateWrongValue), IsTrue) + c.Assert(terror.ErrorEqual(err, table.ErrTruncateWrongValue), IsTrue, Commentf("err %v", err)) tk.MustExec("set @@tidb_skip_utf8_check = '1'") _, err = tk.Exec("insert sc2 values (unhex('4040ffff'))") diff --git a/expression/builtin_cast_test.go b/expression/builtin_cast_test.go index 1c8bd20507229..ca8f63cb353ba 100644 --- a/expression/builtin_cast_test.go +++ b/expression/builtin_cast_test.go @@ -95,7 +95,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings := sc.GetWarnings() lastWarn := warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) originFlag := tp1.Flag tp1.Flag |= mysql.UnsignedFlag @@ -106,7 +106,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings = sc.GetWarnings() lastWarn = warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrCastNegIntAsUnsigned, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrCastNegIntAsUnsigned, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) tp1.Flag = originFlag previousWarnings := len(sc.GetWarnings()) @@ -125,7 +125,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings = sc.GetWarnings() lastWarn = warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) // cast('18446744073709551616' as signed); mask := ^mysql.UnsignedFlag @@ -137,7 +137,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings = sc.GetWarnings() lastWarn = warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrTruncatedWrongVal, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) // cast('18446744073709551614' as signed); f = BuildCastFunction(ctx, &Constant{Value: types.NewDatum("18446744073709551614"), RetType: types.NewFieldType(mysql.TypeString)}, tp1) @@ -147,7 +147,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings = sc.GetWarnings() lastWarn = warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrCastAsSignedOverflow, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrCastAsSignedOverflow, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) // create table t1(s1 time); // insert into t1 values('11:11:11'); @@ -169,7 +169,7 @@ func (s *testEvaluatorSuite) TestCast(c *C) { warnings = sc.GetWarnings() lastWarn = warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(types.ErrOverflow, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(types.ErrOverflow, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) sc = origSc // cast(bad_string as decimal) diff --git a/expression/builtin_encryption_test.go b/expression/builtin_encryption_test.go index 8b3ee9c2b5b5e..5d80199f15778 100644 --- a/expression/builtin_encryption_test.go +++ b/expression/builtin_encryption_test.go @@ -365,7 +365,7 @@ func (s *testEvaluatorSuite) TestPassword(c *C) { c.Assert(len(warnings), Equals, warnCount+1) lastWarn := warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(errDeprecatedSyntaxNoReplacement, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(errDeprecatedSyntaxNoReplacement, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) warnCount = len(warnings) } else { diff --git a/expression/builtin_string_test.go b/expression/builtin_string_test.go index 7341f7f1055dc..8cb7fd923e719 100644 --- a/expression/builtin_string_test.go +++ b/expression/builtin_string_test.go @@ -786,7 +786,7 @@ func (s *testEvaluatorSuite) TestSpaceSig(c *C) { warnings := s.ctx.GetSessionVars().StmtCtx.GetWarnings() c.Assert(len(warnings), Equals, 1) lastWarn := warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(errWarnAllowedPacketOverflowed, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(errWarnAllowedPacketOverflowed, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) } func (s *testEvaluatorSuite) TestLocate(c *C) { @@ -1350,7 +1350,7 @@ func (s *testEvaluatorSuite) TestRpadSig(c *C) { warnings := s.ctx.GetSessionVars().StmtCtx.GetWarnings() c.Assert(len(warnings), Equals, 1) lastWarn := warnings[len(warnings)-1] - c.Assert(terror.ErrorEqual(errWarnAllowedPacketOverflowed, lastWarn.Err), IsTrue) + c.Assert(terror.ErrorEqual(errWarnAllowedPacketOverflowed, lastWarn.Err), IsTrue, Commentf("err %v", lastWarn.Err)) } func (s *testEvaluatorSuite) TestInstr(c *C) { diff --git a/expression/integration_test.go b/expression/integration_test.go index 2bb7ba30c1f31..52ee004d0e1f4 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -1078,15 +1078,15 @@ func (s *testIntegrationSuite) TestTimeBuiltin(c *C) { tk.MustExec(`create table t(a bigint)`) _, err := tk.Exec(`insert into t select year("aa")`) c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue, Commentf("err %v", err)) _, err = tk.Exec(`insert into t select year("0000-00-00 00:00:00")`) c.Assert(err, NotNil) - c.Assert(types.ErrIncorrectDatetimeValue.Equal(err), IsTrue) + c.Assert(types.ErrIncorrectDatetimeValue.Equal(err), IsTrue, Commentf("err %v", err)) tk.MustExec(`insert into t select 1`) _, err = tk.Exec(`update t set a = year("aa")`) - c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue, Commentf("err %v", err)) _, err = tk.Exec(`delete from t where a = year("aa")`) - c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrInvalidTimeFormat), IsTrue, Commentf("err %v", err)) // for month result = tk.MustQuery(`select month("2013-01-09"), month("2013-00-09"), month("000-01-09"), month("1-01-09"), month("20131-01-09"), month(null);`) diff --git a/kv/union_store_test.go b/kv/union_store_test.go index c79c2207663a6..6241e853582de 100644 --- a/kv/union_store_test.go +++ b/kv/union_store_test.go @@ -119,7 +119,7 @@ func (s *testUnionStoreSuite) TestLazyConditionCheck(c *C) { s.us.SetOption(PresumeKeyNotExists, nil) s.us.SetOption(PresumeKeyNotExistsError, ErrNotExist) _, err = s.us.Get([]byte("2")) - c.Assert(terror.ErrorEqual(err, ErrNotExist), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrNotExist), IsTrue, Commentf("err %v", err)) err = s.us.CheckLazyConditionPairs() c.Assert(err, NotNil) diff --git a/server/conn_stmt_test.go b/server/conn_stmt_test.go index 507b455f05372..fdfce13a338fe 100644 --- a/server/conn_stmt_test.go +++ b/server/conn_stmt_test.go @@ -193,7 +193,7 @@ func (ts ConnTestSuite) TestParseStmtArgs(c *C) { } for _, tt := range tests { err := parseStmtArgs(tt.args.args, tt.args.boundParams, tt.args.nullBitmap, tt.args.paramTypes, tt.args.paramValues) - c.Assert(terror.ErrorEqual(err, tt.err), IsTrue) + c.Assert(terror.ErrorEqual(err, tt.err), IsTrue, Commentf("err %v", err)) c.Assert(tt.args.args[0], Equals, tt.expect) } } diff --git a/session/session_test.go b/session/session_test.go index 2179a89e1c7a2..05690a1e13e94 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -372,23 +372,23 @@ func (s *testSessionSuite) TestGetSysVariables(c *C) { tk.MustExec("select @@session.warning_count") tk.MustExec("select @@local.warning_count") _, err := tk.Exec("select @@global.warning_count") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) // Test ScopeGlobal tk.MustExec("select @@max_connections") tk.MustExec("select @@global.max_connections") _, err = tk.Exec("select @@session.max_connections") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select @@local.max_connections") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) // Test ScopeNone tk.MustExec("select @@performance_schema_max_mutex_classes") tk.MustExec("select @@global.performance_schema_max_mutex_classes") _, err = tk.Exec("select @@session.performance_schema_max_mutex_classes") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) _, err = tk.Exec("select @@local.performance_schema_max_mutex_classes") - c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrIncorrectScope), IsTrue, Commentf("err %v", err)) } func (s *testSessionSuite) TestRetryResetStmtCtx(c *C) { @@ -1259,12 +1259,12 @@ func (s *testSessionSuite) TestUnique(c *C) { _, err := tk.Exec("commit") c.Assert(err, NotNil) // Check error type and error message - c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue) + c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue, Commentf("err %v", err)) c.Assert(err.Error(), Equals, "[kv:1062]Duplicate entry '1' for key 'PRIMARY'") _, err = tk1.Exec("commit") c.Assert(err, NotNil) - c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue) + c.Assert(terror.ErrorEqual(err, kv.ErrKeyExists), IsTrue, Commentf("err %v", err)) c.Assert(err.Error(), Equals, "[kv:1062]Duplicate entry '2' for key 'val'") // Test for https://github.com/pingcap/tidb/issues/463 @@ -1596,7 +1596,7 @@ func (s *testSchemaSuite) TestCommitWhenSchemaChanged(c *C) { // When tk1 commit, it will find schema already changed. tk1.MustExec("insert into t values (4, 4)") _, err := tk1.Exec("commit") - c.Assert(terror.ErrorEqual(err, plan.ErrWrongValueCountOnRow), IsTrue) + c.Assert(terror.ErrorEqual(err, plan.ErrWrongValueCountOnRow), IsTrue, Commentf("err %v", err)) } func (s *testSchemaSuite) TestRetrySchemaChange(c *C) { @@ -2154,9 +2154,9 @@ func (s *testSessionSuite) TestSetGroupConcatMaxLen(c *C) { result.Check(testkit.Rows("4")) _, err := tk.Exec("set @@group_concat_max_len = 18446744073709551616") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) // Test illegal type _, err = tk.Exec("set @@group_concat_max_len='hello'") - c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue) + c.Assert(terror.ErrorEqual(err, variable.ErrWrongTypeForVar), IsTrue, Commentf("err %v", err)) } diff --git a/table/tables/index_test.go b/table/tables/index_test.go index d52f7835dd6dd..5e8350e8dd46c 100644 --- a/table/tables/index_test.go +++ b/table/tables/index_test.go @@ -106,7 +106,7 @@ func (s *testIndexSuite) TestIndex(c *C) { c.Assert(err, IsNil) _, _, err = it.Next() - c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue) + c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue, Commentf("err %v", err)) it.Close() _, err = index.Create(mockCtx, txn, values, 0) @@ -127,14 +127,14 @@ func (s *testIndexSuite) TestIndex(c *C) { c.Assert(hit, IsFalse) _, _, err = it.Next() - c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue) + c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue, Commentf("err %v", err)) it.Close() it, err = index.SeekFirst(txn) c.Assert(err, IsNil) _, _, err = it.Next() - c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue) + c.Assert(terror.ErrorEqual(err, io.EOF), IsTrue, Commentf("err %v", err)) it.Close() err = txn.Commit(context.Background()) diff --git a/types/convert_test.go b/types/convert_test.go index 659962177b314..b7ef6055a46ef 100644 --- a/types/convert_test.go +++ b/types/convert_test.go @@ -238,20 +238,20 @@ func (s *testTypeConvertSuite) TestConvertType(c *C) { c.Assert(err, IsNil, Commentf(errors.ErrorStack(err))) c.Assert(v.(*MyDecimal).String(), Equals, "3.1416") v, err = Convert("3.1415926", ft) - c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue, Commentf("err %v", err)) c.Assert(v.(*MyDecimal).String(), Equals, "3.1416") v, err = Convert("99999", ft) - c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue, Commentf("err %v", err)) c.Assert(v.(*MyDecimal).String(), Equals, "9999.9999") v, err = Convert("-10000", ft) - c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue, Commentf("err %v", err)) c.Assert(v.(*MyDecimal).String(), Equals, "-9999.9999") // Test Datum.ToDecimal with bad number. d := NewDatum("hello") sc := new(stmtctx.StatementContext) v, err = d.ToDecimal(sc) - c.Assert(terror.ErrorEqual(err, ErrBadNumber), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrBadNumber), IsTrue, Commentf("err %v", err)) sc.IgnoreTruncate = true v, err = d.ToDecimal(sc) @@ -288,7 +288,7 @@ func (s *testTypeConvertSuite) TestConvertType(c *C) { _, err = Convert("d", ft) c.Assert(err, NotNil) v, err = Convert(4, ft) - c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue, Commentf("err %v", err)) c.Assert(v, DeepEquals, Enum{}) ft = NewFieldType(mysql.TypeSet) @@ -343,7 +343,7 @@ func (s *testTypeConvertSuite) TestConvertToString(c *C) { ft.Flen = 10 ft.Decimal = 5 v, err := Convert(3.1415926, ft) - c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrTruncated), IsTrue, Commentf("err %v", err)) testToString(c, v, "3.14159") _, err = ToString(&invalidMockType{}) @@ -385,7 +385,7 @@ func testStrToInt(c *C, str string, expect int64, truncateAsErr bool, expectErr sc.IgnoreTruncate = !truncateAsErr val, err := StrToInt(sc, str) if expectErr != nil { - c.Assert(terror.ErrorEqual(err, expectErr), IsTrue) + c.Assert(terror.ErrorEqual(err, expectErr), IsTrue, Commentf("err %v", err)) } else { c.Assert(err, IsNil) c.Assert(val, Equals, expect) @@ -397,7 +397,7 @@ func testStrToUint(c *C, str string, expect uint64, truncateAsErr bool, expectEr sc.IgnoreTruncate = !truncateAsErr val, err := StrToUint(sc, str) if expectErr != nil { - c.Assert(terror.ErrorEqual(err, expectErr), IsTrue) + c.Assert(terror.ErrorEqual(err, expectErr), IsTrue, Commentf("err %v", err)) } else { c.Assert(err, IsNil) c.Assert(val, Equals, expect) @@ -409,7 +409,7 @@ func testStrToFloat(c *C, str string, expect float64, truncateAsErr bool, expect sc.IgnoreTruncate = !truncateAsErr val, err := StrToFloat(sc, str) if expectErr != nil { - c.Assert(terror.ErrorEqual(err, expectErr), IsTrue) + c.Assert(terror.ErrorEqual(err, expectErr), IsTrue, Commentf("err %v", err)) } else { c.Assert(err, IsNil) c.Assert(val, Equals, expect) @@ -685,9 +685,9 @@ func (s *testTypeConvertSuite) TestGetValidFloat(c *C) { c.Assert(err, IsNil) } _, err := floatStrToIntStr("1e9223372036854775807") - c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue, Commentf("err %v", err)) _, err = floatStrToIntStr("1e21") - c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue) + c.Assert(terror.ErrorEqual(err, ErrOverflow), IsTrue, Commentf("err %v", err)) } // TestConvertTime tests time related conversion. diff --git a/types/etc_test.go b/types/etc_test.go index 92e7304787f29..4a5e161f2e32e 100644 --- a/types/etc_test.go +++ b/types/etc_test.go @@ -190,6 +190,6 @@ func (s *testTypeEtcSuite) TestTruncate(c *C) { for _, t := range tbl { f, err := TruncateFloat(t.Input, t.Flen, t.Decimal) c.Assert(f, Equals, t.Expect) - c.Assert(terror.ErrorEqual(err, t.Err), IsTrue) + c.Assert(terror.ErrorEqual(err, t.Err), IsTrue, Commentf("err %v", err)) } } diff --git a/util/codec/codec_test.go b/util/codec/codec_test.go index 645d2357dc703..667213a4e6524 100644 --- a/util/codec/codec_test.go +++ b/util/codec/codec_test.go @@ -746,9 +746,9 @@ func (s *testCodecSuite) TestDecimal(c *C) { d := types.NewDecFromStringForTest("-123.123456789") _, err := EncodeDecimal(nil, d, 20, 5) - c.Assert(terror.ErrorEqual(err, types.ErrTruncated), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrTruncated), IsTrue, Commentf("err %v", err)) _, err = EncodeDecimal(nil, d, 12, 10) - c.Assert(terror.ErrorEqual(err, types.ErrOverflow), IsTrue) + c.Assert(terror.ErrorEqual(err, types.ErrOverflow), IsTrue, Commentf("err %v", err)) sc.IgnoreTruncate = true decimalDatum := types.NewDatum(d)