Skip to content

Commit

Permalink
executor: Improve the aesthetics of code review (#6137)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangxiaoning authored and coocood committed Mar 31, 2018
1 parent 1b3440c commit 67f920a
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
14 changes: 7 additions & 7 deletions executor/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 %`))
}
2 changes: 1 addition & 1 deletion expression/evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion expression/expr_to_pb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("<nil>"))

// for yearweek
Expand Down Expand Up @@ -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},
Expand Down
18 changes: 9 additions & 9 deletions expression/typeinfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},

{"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},
{`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},

{"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},
Expand Down
10 changes: 5 additions & 5 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion plan/physical_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand Down
4 changes: 2 additions & 2 deletions session/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;")
Expand Down Expand Up @@ -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;")
Expand Down
4 changes: 2 additions & 2 deletions session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion session/tidb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions util/prefix_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 67f920a

Please sign in to comment.