Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): fix parsing identifer.identifer failed #104

Merged
merged 2 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pisa-proxy/parser/mysql/src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,10 +641,16 @@ impl<'a> Scanner<'a> {
}
});

self.is_ident_dot = self.peek() == '.';

let ident_str = self.text[old_pos..self.pos].to_uppercase();

// Check whether has the `ident.ident` format.
if self.is_ident_dot {
self.pos -= 1;
return DefaultLexeme::new(T_IDENT, old_pos, ident_str.len());
}

self.is_ident_dot = self.peek() == '.';

if ident_str.starts_with('_') {
// check `UNDERSCORE_CHARSET` token
if CHARSETS.get(&*ident_str).is_some() {
Expand Down Expand Up @@ -896,7 +902,7 @@ mod test {

#[test]
fn test_scan_start_at() {
let inputs = vec![("@abc", 3), ("@@session.sss", 12)];
let inputs = vec![("@abc", 3), ("@@session.sss", 9)];

for (input, pos) in inputs {
let mut scanner = Scanner::new(input);
Expand Down
1 change: 1 addition & 0 deletions pisa-proxy/parser/mysql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ mod test {
//"SET character_set_client = \"gbk\";",
//"SET @@GLOBAL.character_set_client = gbk;",
//"SET @@SESSION.character_set_client = gbk;",
"SELECT * from mysql.select;",
"create database if not exists db CHARACTER SET = utf8;",
];

Expand Down