Skip to content

Commit

Permalink
parser: fix parser identifier with dot (#46314) (#46323)
Browse files Browse the repository at this point in the history
close #35031
  • Loading branch information
ti-chi-bot authored Aug 23, 2023
1 parent 74a9595 commit d927657
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 @@ -1054,10 +1054,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 @@ -1046,6 +1046,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 d927657

Please sign in to comment.