Skip to content

Commit

Permalink
parser: support select t.ReservedKeyword from t; (pingcap#2039)
Browse files Browse the repository at this point in the history
For example "select t.desc from t;"
  • Loading branch information
shenli authored Nov 20, 2016
1 parent 8fa03ee commit 81a3ba6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,11 @@ ColumnName:
{
$$ = &ast.ColumnName{Name: model.NewCIStr($1)}
}
| Identifier '.' Identifier
| Identifier '.' IdentifierOrReservedKeyword
{
$$ = &ast.ColumnName{Table: model.NewCIStr($1), Name: model.NewCIStr($3)}
}
| Identifier '.' Identifier '.' Identifier
| Identifier '.' Identifier '.' IdentifierOrReservedKeyword
{
$$ = &ast.ColumnName{Schema: model.NewCIStr($1), Table: model.NewCIStr($3), Name: model.NewCIStr($5)}
}
Expand Down
4 changes: 4 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (s *testParserSuite) TestSimple(c *C) {
src = fmt.Sprintf("SELECT * FROM %s.desc", kw)
_, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil, Commentf("source %s", src))

src = fmt.Sprintf("SELECT t.%s FROM t", kw)
_, err = parser.ParseOneStmt(src, "", "")
c.Assert(err, IsNil, Commentf("source %s", src))
}

// Testcase for unreserved keywords
Expand Down

0 comments on commit 81a3ba6

Please sign in to comment.