Skip to content

Commit

Permalink
[parser] *: fix type of MaxInt64 (pingcap#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjhuang2016 authored and crazycs520 committed Mar 25, 2019
1 parent 90a5853 commit cace326
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ func (s *testParserSuite) TestSimple(c *C) {
src = `insert into tb(v) (select v from tb);`
_, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil)

// for issue #9823
src = "SELECT 9223372036854775807;"
st, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil)
sel, ok := st.(*ast.SelectStmt)
c.Assert(ok, IsTrue)
expr := sel.Fields.Fields[0]
vExpr := expr.Expr.(*driver.ValueExpr)
c.Assert(vExpr.Kind(), Equals, types.KindInt64)
src = "SELECT 9223372036854775808;"
st, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil)
sel, ok = st.(*ast.SelectStmt)
c.Assert(ok, IsTrue)
expr = sel.Fields.Fields[0]
vExpr = expr.Expr.(*driver.ValueExpr)
c.Assert(vExpr.Kind(), Equals, types.KindUint64)
}

type testCase struct {
Expand Down
2 changes: 1 addition & 1 deletion parser/yy_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func toInt(l yyLexer, lval *yySymType, str string) int {
}

switch {
case n < math.MaxInt64:
case n <= math.MaxInt64:
lval.item = int64(n)
default:
lval.item = n
Expand Down

0 comments on commit cace326

Please sign in to comment.