Skip to content

Commit

Permalink
parser: fix parser identifier with dot
Browse files Browse the repository at this point in the history
  • Loading branch information
Defined2014 committed Aug 22, 2023
1 parent 7e476a5 commit b19d2f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1066,10 +1066,20 @@ var hintTokenMap = map[string]int{
func (s *Scanner) isTokenIdentifier(lit string, offset int) int {
// An identifier before or after '.' means it is part of a qualified identifier.
// We do not parse it as keyword.
if s.r.peek() == '.' || (offset > 0 && s.r.s[offset-1] == '.') {
if s.r.peek() == '.' {
return 0
}

for idx := offset - 1; idx >= 0; idx-- {
if s.r.s[idx] == ' ' {
continue
} else if s.r.s[idx] == '.' {
return 0
} else {
break
}
}

buf := &s.buf
buf.Reset()
buf.Grow(len(lit))
Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ AAAAAAAAAAAA5gm5Mg==

{"select `t`.`1a`.1 from t;", true, "SELECT `t`.`1a`.`1` FROM `t`"},
{"select * from 1db.1table;", true, "SELECT * FROM `1db`.`1table`"},
{"select * from t where t. status = 1;", true, "SELECT * FROM `t` WHERE `t`.`status`=1"},

// for show placement
{"SHOW PLACEMENT", true, "SHOW PLACEMENT"},
Expand Down

0 comments on commit b19d2f0

Please sign in to comment.