From 76b42855925a56e06c03380f59ad71283da0605c Mon Sep 17 00:00:00 2001 From: Hangjie Mo Date: Tue, 22 Aug 2023 22:36:34 +0800 Subject: [PATCH] This is an automated cherry-pick of #46314 Signed-off-by: ti-chi-bot --- parser/misc.go | 16 ++++++++++++++++ parser/parser_test.go | 1 + 2 files changed, 17 insertions(+) diff --git a/parser/misc.go b/parser/misc.go index 024779048a1e6..addef9bdfdaf7 100644 --- a/parser/misc.go +++ b/parser/misc.go @@ -995,11 +995,27 @@ 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() == '.' { +<<<<<<< HEAD return 0 } if offset > 0 && s.r.s[offset-1] == '.' { return 0 } +======= + 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 + } + } + +>>>>>>> 1769f3a1ac3 (parser: fix parser identifier with dot (#46314)) buf := &s.buf buf.Reset() buf.Grow(len(lit)) diff --git a/parser/parser_test.go b/parser/parser_test.go index 2b052ca422884..379cd44536cad 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -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"},