Skip to content

Commit

Permalink
parser: fix bug hexadecimal parsed as string (pingcap#1871)
Browse files Browse the repository at this point in the history
x'13181C76734725455A' should be parsed as a hexLit, but it's parsed as a string
  • Loading branch information
tiancaiamao authored Oct 25, 2016
1 parent ba4d6ba commit c0c9729
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,8 @@ func (s *testParserSuite) TestType(c *C) {
{"CREATE TABLE t( c1 TIME(2), c2 DATETIME(2), c3 TIMESTAMP(2) );", true},

// For hexadecimal
{"SELECT x'0a', X'11', 0x11", true},
{"select x'0a', X'11', 0x11", true},
{"select x'13181C76734725455A'", true},
{"select x'0xaa'", false},
{"select 0X11", false},
{"select 0x4920616D2061206C6F6E672068657820737472696E67", true},
Expand Down
1 change: 1 addition & 0 deletions parser/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (s *testLexerSuite) TestLiteral(c *C) {
{"23416", intLit},
{"0", intLit},
{"0x3c26", hexLit},
{"x'13181C76734725455A'", hexLit},
{"0b01", bitLit},
}
runTest(c, table)
Expand Down
2 changes: 1 addition & 1 deletion parser/yy_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func toHex(l yyLexer, lval *yySymType, str string) int {
return int(unicode.ReplacementChar)
}
lval.item = hexStr
return stringLit
return hexLit
}
lval.item = h
return hexLit
Expand Down

0 comments on commit c0c9729

Please sign in to comment.