From 21dbb597672b6094bf14a9a793edae86810fc47d Mon Sep 17 00:00:00 2001 From: Jason Mo Date: Tue, 22 Aug 2023 17:18:19 +0800 Subject: [PATCH] parser: fix parser identifier with dot --- parser/misc.go | 12 +++++++++++- parser/parser_test.go | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/parser/misc.go b/parser/misc.go index 2f222af6ca85b..6f3d4018bb236 100644 --- a/parser/misc.go +++ b/parser/misc.go @@ -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)) diff --git a/parser/parser_test.go b/parser/parser_test.go index dcfa5a7a5c806..91ee4c4b1c68c 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -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"},