Skip to content

Commit

Permalink
parser: fix parser identifier with dot (#46314) (#46322)
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 8040e28 commit 7241e78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,17 @@ func (s *Scanner) isTokenIdentifier(lit string, offset int) int {
if s.r.peek() == '.' {
return 0
}
if offset > 0 && s.r.s[offset-1] == '.' {
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 @@ -1017,6 +1017,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 7241e78

Please sign in to comment.