diff --git a/executor/grant_test.go b/executor/grant_test.go index e16ec96c11..db198f94f4 100644 --- a/executor/grant_test.go +++ b/executor/grant_test.go @@ -183,19 +183,19 @@ func (s *testSuite) TestIssue2456(c *C) { func (s *testSuite) TestCreateUserWhenGrant(c *C) { tk := testkit.NewTestKit(c, s.store) - tk.MustExec("DROP USER IF EXISTS 'test'@'%'") - tk.MustExec("GRANT ALL PRIVILEGES ON *.* to 'test'@'%' IDENTIFIED BY 'xxx'") + tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`) + tk.MustExec(`GRANT ALL PRIVILEGES ON *.* to 'test'@'%' IDENTIFIED BY 'xxx'`) // Make sure user is created automatically when grant to a non-exists one. - tk.MustQuery("SELECT user FROM mysql.user WHERE user='test' and host='%'").Check( + tk.MustQuery(`SELECT user FROM mysql.user WHERE user='test' and host='%'`).Check( testkit.Rows("test"), ) } func (s *testSuite) TestIssue2654(c *C) { tk := testkit.NewTestKit(c, s.store) - tk.MustExec("DROP USER IF EXISTS 'test'@'%'") - tk.MustExec("CREATE USER 'test'@'%' IDENTIFIED BY 'test'") + tk.MustExec(`DROP USER IF EXISTS 'test'@'%'`) + tk.MustExec(`CREATE USER 'test'@'%' IDENTIFIED BY 'test'`) tk.MustExec("GRANT SELECT ON test.* to 'test'") - rows := tk.MustQuery("SELECT user,host FROM mysql.user WHERE user='test' and host='%'") - rows.Check(testkit.Rows("test %")) + rows := tk.MustQuery(`SELECT user,host FROM mysql.user WHERE user='test' and host='%'`) + rows.Check(testkit.Rows(`test %`)) } diff --git a/expression/evaluator_test.go b/expression/evaluator_test.go index c19fde11fe..5bae92c1be 100644 --- a/expression/evaluator_test.go +++ b/expression/evaluator_test.go @@ -544,7 +544,7 @@ func (s *testEvaluatorSuite) TestLike(c *C) { {"a", "a", 1}, {"a", "b", 0}, {"aA", "Aa", 0}, - {"aAb", "Aa%", 0}, + {"aAb", `Aa%`, 0}, {"aAb", "aA_", 1}, } for _, tt := range tests { diff --git a/expression/expr_to_pb_test.go b/expression/expr_to_pb_test.go index f72b3964a3..ef52f28352 100644 --- a/expression/expr_to_pb_test.go +++ b/expression/expr_to_pb_test.go @@ -328,7 +328,7 @@ func (s *testEvaluatorSuite) TestLikeFunc2Pb(c *C) { args := []Expression{ &Constant{RetType: retTp, Value: types.NewDatum("string")}, &Constant{RetType: retTp, Value: types.NewDatum("pattern")}, - &Constant{RetType: retTp, Value: types.NewDatum("%abc%")}, + &Constant{RetType: retTp, Value: types.NewDatum(`%abc%`)}, &Constant{RetType: retTp, Value: types.NewDatum("\\")}, } ctx := mock.NewContext() diff --git a/expression/integration_test.go b/expression/integration_test.go index c41e449e19..de6a10d6b6 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -1378,11 +1378,11 @@ func (s *testIntegrationSuite) TestTimeBuiltin(c *C) { result.Check(testkit.Rows("00:01:23 AM")) // for date_format - result = tk.MustQuery("SELECT DATE_FORMAT('2017-06-15', '%W %M %e %Y %r %y');") + result = tk.MustQuery(`SELECT DATE_FORMAT('2017-06-15', '%W %M %e %Y %r %y');`) result.Check(testkit.Rows("Thursday June 15 2017 12:00:00 AM 17")) - result = tk.MustQuery("SELECT DATE_FORMAT(151113102019.12, '%W %M %e %Y %r %y');") + result = tk.MustQuery(`SELECT DATE_FORMAT(151113102019.12, '%W %M %e %Y %r %y');`) result.Check(testkit.Rows("Friday November 13 2015 10:20:19 AM 15")) - result = tk.MustQuery("SELECT DATE_FORMAT('0000-00-00', '%W %M %e %Y %r %y');") + result = tk.MustQuery(`SELECT DATE_FORMAT('0000-00-00', '%W %M %e %Y %r %y');`) result.Check(testkit.Rows("")) // for yearweek @@ -2150,7 +2150,7 @@ func (s *testIntegrationSuite) TestBuiltin(c *C) { {"a", "a", 1}, {"a", "b", 0}, {"aA", "Aa", 0}, - {"aA%", "aAab", 1}, + {`aA%`, "aAab", 1}, {"aA_", "Aaab", 0}, {"Aa_", "Aab", 1}, {"", "", 1}, diff --git a/expression/typeinfer_test.go b/expression/typeinfer_test.go index 5ea9e68832..ac0b71e673 100644 --- a/expression/typeinfer_test.go +++ b/expression/typeinfer_test.go @@ -273,7 +273,7 @@ func (s *testInferTypeSuite) createTestCase4StrFuncs() []typeInferTestCase { {"trim(c_binary)", mysql.TypeVarString, charset.CharsetBin, mysql.BinaryFlag, 20, types.UnspecifiedLength}, {"ascii(c_char)", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag, 3, 0}, {"ord(c_char)", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag, 10, 0}, - {"c_int_d like 'abc%'", mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag, 1, 0}, + {`c_int_d like 'abc%'`, mysql.TypeLonglong, charset.CharsetBin, mysql.BinaryFlag, 1, 0}, {"tidb_version()", mysql.TypeVarString, charset.CharsetUTF8, 0, len(printer.GetTiDBInfo()), types.UnspecifiedLength}, {"password(c_char)", mysql.TypeVarString, charset.CharsetUTF8, 0, mysql.PWDHashLen + 1, types.UnspecifiedLength}, {"elt(c_int_d, c_char, c_char, c_char)", mysql.TypeVarString, charset.CharsetUTF8, 0, 20, types.UnspecifiedLength}, @@ -1191,14 +1191,14 @@ func (s *testInferTypeSuite) createTestCase4OtherFuncs() []typeInferTestCase { func (s *testInferTypeSuite) createTestCase4TimeFuncs() []typeInferTestCase { return []typeInferTestCase{ - {"time_format('150:02:28', '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"time_format(123456, '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"time_format('bad string', '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"time_format(null, '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`time_format('150:02:28', '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`time_format(123456, '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`time_format('bad string', '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`time_format(null, '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"date_format(null, '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"date_format('2017-06-15', '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, - {"date_format(151113102019.12, '%r%r%r%r')", mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`date_format(null, '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`date_format('2017-06-15', '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, + {`date_format(151113102019.12, '%r%r%r%r')`, mysql.TypeVarString, charset.CharsetUTF8, 0, 44, types.UnspecifiedLength}, {"timestampadd(HOUR, c_int_d, c_timestamp_d)", mysql.TypeString, charset.CharsetUTF8, 0, 19, types.UnspecifiedLength}, {"timestampadd(minute, c_double_d, c_timestamp_d)", mysql.TypeString, charset.CharsetUTF8, 0, 19, types.UnspecifiedLength}, diff --git a/parser/parser_test.go b/parser/parser_test.go index cd40e9b3ec..aea081687d 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -476,8 +476,8 @@ func (s *testParserSuite) TestDBAStmt(c *C) { {"SHOW STATUS", true}, {"SHOW GLOBAL STATUS", true}, {"SHOW SESSION STATUS", true}, - {"SHOW STATUS LIKE 'Up%'", true}, - {"SHOW STATUS WHERE Variable_name LIKE 'Up%'", true}, + {`SHOW STATUS LIKE 'Up%'`, true}, + {`SHOW STATUS WHERE Variable_name LIKE 'Up%'`, true}, {`SHOW FULL TABLES FROM icar_qa LIKE play_evolutions`, true}, {`SHOW FULL TABLES WHERE Table_Type != 'VIEW'`, true}, {`SHOW GRANTS`, true}, @@ -505,7 +505,7 @@ func (s *testParserSuite) TestDBAStmt(c *C) { {"show charset", true}, // for show collation {"show collation", true}, - {"show collation like 'utf8%'", true}, + {`show collation like 'utf8%'`, true}, {"show collation where Charset = 'utf8' and Collation = 'utf8_bin'", true}, // for show full columns {"show columns in t;", true}, @@ -868,7 +868,7 @@ func (s *testParserSuite) TestBuiltin(c *C) { {"SELECT DATE('2003-12-31 01:02:03');", true}, {"SELECT DATE();", true}, {"SELECT DATE('2003-12-31 01:02:03', '');", true}, - {"SELECT DATE_FORMAT('2003-12-31 01:02:03', '%W %M %Y');", true}, + {`SELECT DATE_FORMAT('2003-12-31 01:02:03', '%W %M %Y');`, true}, {"SELECT DAY('2007-02-03');", true}, {"SELECT DAYOFMONTH('2007-02-03');", true}, {"SELECT DAYOFWEEK('2007-02-03');", true}, @@ -930,7 +930,7 @@ func (s *testParserSuite) TestBuiltin(c *C) { {"SELECT SEC_TO_TIME(2378)", true}, // for TIME_FORMAT - {"SELECT TIME_FORMAT('100:00:00', '%H %k %h %I %l')", true}, + {`SELECT TIME_FORMAT('100:00:00', '%H %k %h %I %l')`, true}, // for TIME_TO_SEC {"SELECT TIME_TO_SEC('22:23:00')", true}, diff --git a/plan/physical_plan_test.go b/plan/physical_plan_test.go index 91dc562c93..150d49a6ad 100644 --- a/plan/physical_plan_test.go +++ b/plan/physical_plan_test.go @@ -1015,7 +1015,7 @@ func (s *testPlanSuite) TestRefine(c *C) { best: "TableReader(Table(t)->Sel([like(test.t.c_str, _abc, 92)]))->Projection", }, { - sql: "select a from t where c_str like 'abc%'", + sql: `select a from t where c_str like 'abc%'`, best: "IndexReader(Index(t.c_d_e_str)[[abc,abd)])->Projection", }, { diff --git a/session/bootstrap_test.go b/session/bootstrap_test.go index b4d96a1301..66cb14bbad 100644 --- a/session/bootstrap_test.go +++ b/session/bootstrap_test.go @@ -55,7 +55,7 @@ func (s *testBootstrapSuite) TestBootstrap(c *C) { c.Assert(err, IsNil) c.Assert(chk.NumRows() == 0, IsFalse) datums := ast.RowToDatums(chk.GetRow(0), r.Fields()) - match(c, datums, []byte("%"), []byte("root"), []byte(""), "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y") + match(c, datums, []byte(`%`), []byte("root"), []byte(""), "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y") c.Assert(se.Auth(&auth.UserIdentity{Username: "root", Hostname: "anyhost"}, []byte(""), []byte("")), IsTrue) mustExecSQL(c, se, "USE test;") @@ -153,7 +153,7 @@ func (s *testBootstrapSuite) testBootstrapWithError(c *C) { c.Assert(chk.NumRows() == 0, IsFalse) row := chk.GetRow(0) datums := ast.RowToDatums(row, r.Fields()) - match(c, datums, []byte("%"), []byte("root"), []byte(""), "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y") + match(c, datums, []byte(`%`), []byte("root"), []byte(""), "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y") mustExecSQL(c, se, "USE test;") // Check privilege tables. mustExecSQL(c, se, "SELECT * from mysql.db;") diff --git a/session/session_test.go b/session/session_test.go index 63a8170a66..755bac23b7 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -564,8 +564,8 @@ func (s *testSessionSuite) TestSkipWithGrant(c *C) { c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "user_not_exist"}, []byte("yyy"), []byte("zzz")), IsFalse) privileges.SkipWithGrant = true - c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "xxx", Hostname: "%"}, []byte("yyy"), []byte("zzz")), IsTrue) - c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, []byte(""), []byte("")), IsTrue) + c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "xxx", Hostname: `%`}, []byte("yyy"), []byte("zzz")), IsTrue) + c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: `%`}, []byte(""), []byte("")), IsTrue) tk.MustExec("create table t (id int)") privileges.Enable = save1 diff --git a/session/tidb_test.go b/session/tidb_test.go index f5d2d344e9..0a41ff89e6 100644 --- a/session/tidb_test.go +++ b/session/tidb_test.go @@ -242,7 +242,7 @@ func newSession(c *C, store kv.Storage, dbName string) Session { id := atomic.AddUint64(&testConnID, 1) se.SetConnectionID(id) c.Assert(err, IsNil) - se.Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, []byte("012345678901234567890")) + se.Auth(&auth.UserIdentity{Username: "root", Hostname: `%`}, nil, []byte("012345678901234567890")) mustExecSQL(c, se, "create database if not exists "+dbName) mustExecSQL(c, se, "use "+dbName) return se diff --git a/util/prefix_helper_test.go b/util/prefix_helper_test.go index 9e3e7c62c0..9edcef49a6 100644 --- a/util/prefix_helper_test.go +++ b/util/prefix_helper_test.go @@ -127,7 +127,7 @@ func (s *testPrefixSuite) TestPrefix(c *C) { txn, err = s.s.Begin() c.Assert(err, IsNil) k := []byte("key100jfowi878230") - err = txn.Set(k, []byte("val32dfaskli384757^*&%^")) + err = txn.Set(k, []byte(`val32dfaskli384757^*&%^`)) c.Assert(err, IsNil) err = util.ScanMetaWithPrefix(txn, k, func(kv.Key, []byte) bool { return true @@ -138,7 +138,7 @@ func (s *testPrefixSuite) TestPrefix(c *C) { } func (s *testPrefixSuite) TestPrefixFilter(c *C) { - rowKey := []byte("test@#$%l(le[0]..prefix) 2uio") + rowKey := []byte(`test@#$%l(le[0]..prefix) 2uio`) rowKey[8] = 0x00 rowKey[9] = 0x00 f := util.RowKeyPrefixFilter(rowKey)