Skip to content

Commit

Permalink
remove extra space
Browse files Browse the repository at this point in the history
  • Loading branch information
imtbkcat committed Sep 1, 2020
1 parent 025d665 commit ade32f5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 32 deletions.
8 changes: 4 additions & 4 deletions ast/functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (ts *testFunctionsSuite) TestConvert(c *C) {
{`SELECT CONVERT("abc" USING laTiN1)`, "latin1", ""},
{`SELECT CONVERT("abc" USING "binary")`, "binary", ""},
{`SELECT CONVERT("abc" USING biNaRy)`, "binary", ""},
{`SELECT CONVERT(a USING a)`, "", `[parser:1115] Unknown character set: 'a'`}, // TiDB issue #4436.
{`SELECT CONVERT("abc" USING CONCAT("utf", "8"))`, "", `[parser:1115] Unknown character set: 'CONCAT'`},
{`SELECT CONVERT(a USING a)`, "", `[parser:1115]Unknown character set: 'a'`}, // TiDB issue #4436.
{`SELECT CONVERT("abc" USING CONCAT("utf", "8"))`, "", `[parser:1115]Unknown character set: 'CONCAT'`},
}
for _, testCase := range cases {
stmt, err := parser.New().ParseOneStmt(testCase.SQL, "", "")
Expand Down Expand Up @@ -191,8 +191,8 @@ func (ts *testFunctionsSuite) TestChar(c *C) {
{`SELECT CHAR("abc" USING laTiN1)`, "latin1", ""},
{`SELECT CHAR("abc" USING "binary")`, "binary", ""},
{`SELECT CHAR("abc" USING binary)`, "binary", ""},
{`SELECT CHAR(a USING a)`, "", `[parser:1115] Unknown character set: 'a'`},
{`SELECT CHAR("abc" USING CONCAT("utf", "8"))`, "", `[parser:1115] Unknown character set: 'CONCAT'`},
{`SELECT CHAR(a USING a)`, "", `[parser:1115]Unknown character set: 'a'`},
{`SELECT CHAR("abc" USING CONCAT("utf", "8"))`, "", `[parser:1115]Unknown character set: 'CONCAT'`},
}
for _, testCase := range cases {
stmt, err := parser.New().ParseOneStmt(testCase.SQL, "", "")
Expand Down
2 changes: 1 addition & 1 deletion charset/charset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *testCharsetSuite) TestGetCollationByName(c *C) {
}

_, err := GetCollationByName("non_exist")
c.Assert(err, ErrorMatches, "\\[ddl:1273\\] Unknown collation: 'non_exist'")
c.Assert(err, ErrorMatches, "\\[ddl:1273\\]Unknown collation: 'non_exist'")
}

func BenchmarkGetCharsetDesc(b *testing.B) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/cznic/y v0.0.0-20170802143616-045f81c6662a
github.com/go-sql-driver/mysql v1.5.0
github.com/pingcap/check v0.0.0-20190102082844-67f458068fc8
github.com/pingcap/errors v0.11.5-0.20200820105733-2b6fabf184ae
github.com/pingcap/errors v0.11.5-0.20200901084736-22e4480db80c
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 // indirect
go.uber.org/zap v1.15.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ github.com/pingcap/errors v0.11.5-0.20200820023525-77f66aa24026 h1:klbc7oP3/xRPe
github.com/pingcap/errors v0.11.5-0.20200820023525-77f66aa24026/go.mod h1:g4vx//d6VakjJ0mk7iLBlKA8LFavV/sAVINT/1PFxeQ=
github.com/pingcap/errors v0.11.5-0.20200820105733-2b6fabf184ae h1:LjL3t9xqp1kqwJwtlxPg7Qsxf/yDVP6WeIBwaUHEHm8=
github.com/pingcap/errors v0.11.5-0.20200820105733-2b6fabf184ae/go.mod h1:g4vx//d6VakjJ0mk7iLBlKA8LFavV/sAVINT/1PFxeQ=
github.com/pingcap/errors v0.11.5-0.20200901084736-22e4480db80c h1:eC9ijf5AaM3tp4PDuKFVKvijjWt5AYxW/HAKb3dDFz8=
github.com/pingcap/errors v0.11.5-0.20200901084736-22e4480db80c/go.mod h1:g4vx//d6VakjJ0mk7iLBlKA8LFavV/sAVINT/1PFxeQ=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9 h1:AJD9pZYm72vMgPcQDww9rkZ1DnWfl0pXV3BOWlkYIjA=
github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8=
github.com/pingcap/log v0.0.0-20200511115504-543df19646ad h1:SveG82rmu/GFxYanffxsSF503SiQV+2JLnWEiGiF+Tc=
Expand Down
50 changes: 25 additions & 25 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3045,40 +3045,40 @@ func (s *testParserSuite) TestErrorMsg(c *C) {
c.Assert(err.Error(), Equals, "line 1 column 36 near \"> t2.a;\" ")

_, _, err = parser.Parse("create table t(f_year year(5))ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;", "", "")
c.Assert(err.Error(), Equals, "[parser:1818] Supports only YEAR or YEAR(4) column")
c.Assert(err.Error(), Equals, "[parser:1818]Supports only YEAR or YEAR(4) column")

_, _, err = parser.Parse("select ifnull(a,0) & ifnull(a,0) like '55' ESCAPE '\\\\a' from t;", "", "")
c.Assert(err.Error(), Equals, "[parser:1210] Incorrect arguments to ESCAPE")
c.Assert(err.Error(), Equals, "[parser:1210]Incorrect arguments to ESCAPE")

_, _, err = parser.Parse("load data infile 'aaa' into table aaa FIELDS Enclosed by '\\\\b';", "", "")
c.Assert(err.Error(), Equals, "[parser:1083] Field separator argument is not what is expected; check the manual")
c.Assert(err.Error(), Equals, "[parser:1083]Field separator argument is not what is expected; check the manual")

_, _, err = parser.Parse("load data infile 'aaa' into table aaa FIELDS Escaped by '\\\\b';", "", "")
c.Assert(err.Error(), Equals, "[parser:1083] Field separator argument is not what is expected; check the manual")
c.Assert(err.Error(), Equals, "[parser:1083]Field separator argument is not what is expected; check the manual")

_, _, err = parser.Parse("load data infile 'aaa' into table aaa FIELDS Enclosed by '\\\\b' Escaped by '\\\\b' ;", "", "")
c.Assert(err.Error(), Equals, "[parser:1083] Field separator argument is not what is expected; check the manual")
c.Assert(err.Error(), Equals, "[parser:1083]Field separator argument is not what is expected; check the manual")

_, _, err = parser.Parse("ALTER DATABASE `` CHARACTER SET = ''", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: ''")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: ''")

_, _, err = parser.Parse("ALTER DATABASE t CHARACTER SET = ''", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: ''")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: ''")

_, _, err = parser.Parse("ALTER SCHEMA t CHARACTER SET = 'SOME_INVALID_CHARSET'", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: 'SOME_INVALID_CHARSET'")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: 'SOME_INVALID_CHARSET'")

_, _, err = parser.Parse("ALTER DATABASE t COLLATE = ''", "", "")
c.Assert(err.Error(), Equals, "[ddl:1273] Unknown collation: ''")
c.Assert(err.Error(), Equals, "[ddl:1273]Unknown collation: ''")

_, _, err = parser.Parse("ALTER SCHEMA t COLLATE = 'SOME_INVALID_COLLATION'", "", "")
c.Assert(err.Error(), Equals, "[ddl:1273] Unknown collation: 'SOME_INVALID_COLLATION'")
c.Assert(err.Error(), Equals, "[ddl:1273]Unknown collation: 'SOME_INVALID_COLLATION'")

_, _, err = parser.Parse("ALTER DATABASE CHARSET = 'utf8mb4' COLLATE = 'utf8_bin'", "", "")
c.Assert(err.Error(), Equals, "line 1 column 24 near \"= 'utf8mb4' COLLATE = 'utf8_bin'\" ")

_, _, err = parser.Parse("ALTER DATABASE t ENCRYPTION = ''", "", "")
c.Assert(err.Error(), Equals, "[parser:1525] Incorrect argument (should be Y or N) value: ''")
c.Assert(err.Error(), Equals, "[parser:1525]Incorrect argument (should be Y or N) value: ''")

_, _, err = parser.Parse("ALTER DATABASE", "", "")
c.Assert(err.Error(), Equals, "line 1 column 14 near \"\" ")
Expand All @@ -3087,46 +3087,46 @@ func (s *testParserSuite) TestErrorMsg(c *C) {
c.Assert(err.Error(), Equals, "line 1 column 26 near \"\" ")

_, _, err = parser.Parse("alter table t partition by range FIELDS(a)", "", "")
c.Assert(err.Error(), Equals, "[ddl:1492] For RANGE partitions each partition must be defined")
c.Assert(err.Error(), Equals, "[ddl:1492]For RANGE partitions each partition must be defined")

_, _, err = parser.Parse("alter table t partition by list FIELDS(a)", "", "")
c.Assert(err.Error(), Equals, "[ddl:1492] For LIST partitions each partition must be defined")
c.Assert(err.Error(), Equals, "[ddl:1492]For LIST partitions each partition must be defined")

_, _, err = parser.Parse("alter table t partition by list FIELDS(a)", "", "")
c.Assert(err.Error(), Equals, "[ddl:1492] For LIST partitions each partition must be defined")
c.Assert(err.Error(), Equals, "[ddl:1492]For LIST partitions each partition must be defined")

_, _, err = parser.Parse("alter table t partition by list FIELDS(a,b,c)", "", "")
c.Assert(err.Error(), Equals, "[ddl:1492] For LIST partitions each partition must be defined")
c.Assert(err.Error(), Equals, "[ddl:1492]For LIST partitions each partition must be defined")

_, _, err = parser.Parse("alter table t lock = first", "", "")
c.Assert(err.Error(), Equals, "[parser:1801] Unknown LOCK type 'first'")
c.Assert(err.Error(), Equals, "[parser:1801]Unknown LOCK type 'first'")

_, _, err = parser.Parse("alter table t lock = start", "", "")
c.Assert(err.Error(), Equals, "[parser:1801] Unknown LOCK type 'start'")
c.Assert(err.Error(), Equals, "[parser:1801]Unknown LOCK type 'start'")

_, _, err = parser.Parse("alter table t lock = commit", "", "")
c.Assert(err.Error(), Equals, "[parser:1801] Unknown LOCK type 'commit'")
c.Assert(err.Error(), Equals, "[parser:1801]Unknown LOCK type 'commit'")

_, _, err = parser.Parse("alter table t lock = binlog", "", "")
c.Assert(err.Error(), Equals, "[parser:1801] Unknown LOCK type 'binlog'")
c.Assert(err.Error(), Equals, "[parser:1801]Unknown LOCK type 'binlog'")

_, _, err = parser.Parse("alter table t lock = randomStr123", "", "")
c.Assert(err.Error(), Equals, "[parser:1801] Unknown LOCK type 'randomStr123'")
c.Assert(err.Error(), Equals, "[parser:1801]Unknown LOCK type 'randomStr123'")

_, _, err = parser.Parse("create table t (a longtext unicode)", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: 'ucs2'")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: 'ucs2'")

_, _, err = parser.Parse("create table t (a long byte, b text unicode)", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: 'ucs2'")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: 'ucs2'")

_, _, err = parser.Parse("create table t (a long ascii, b long unicode)", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: 'ucs2'")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: 'ucs2'")

_, _, err = parser.Parse("create table t (a text unicode, b mediumtext ascii, c int)", "", "")
c.Assert(err.Error(), Equals, "[parser:1115] Unknown character set: 'ucs2'")
c.Assert(err.Error(), Equals, "[parser:1115]Unknown character set: 'ucs2'")

_, _, err = parser.Parse("select 1 collate some_unknown_collation", "", "")
c.Assert(err.Error(), Equals, "[ddl:1273] Unknown collation: 'some_unknown_collation'")
c.Assert(err.Error(), Equals, "[ddl:1273]Unknown collation: 'some_unknown_collation'")
}

func (s *testParserSuite) TestOptimizerHints(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion terror/terror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (s *testTErrorSuite) TestTError(c *C) {
c.Assert(optimizerErr.Equal(optimizerErr.FastGen("def: %s", "def")), IsTrue)
kvErr := ClassKV.New(1062, "key already exist")
e := kvErr.FastGen("Duplicate entry '%d' for key 'PRIMARY'", 1)
c.Assert(e.Error(), Equals, "[kv:1062] Duplicate entry '1' for key 'PRIMARY'")
c.Assert(e.Error(), Equals, "[kv:1062]Duplicate entry '1' for key 'PRIMARY'")
sqlErr := ToSQLError(errors.Cause(e).(*Error))
c.Assert(sqlErr.Message, Equals, "Duplicate entry '1' for key 'PRIMARY'")
c.Assert(sqlErr.Code, Equals, uint16(1062))
Expand Down

0 comments on commit ade32f5

Please sign in to comment.