mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for mysql parser.
This commit is contained in:
@@ -262,22 +262,22 @@ public class MySqlLexer extends Lexer {
|
||||
ch = charAt(++pos);
|
||||
|
||||
if (!isIdentifierChar(ch)) {
|
||||
if (ch == '-' && pos < text.length() - 1) {
|
||||
if (mark > 0 && text.charAt(mark - 1) == '.') {
|
||||
break;
|
||||
}
|
||||
|
||||
char next_char = text.charAt(pos + 1);
|
||||
if (isIdentifierChar(next_char)) {
|
||||
bufPos++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (last_ch == '-' && charAt(pos-2) != '-') {
|
||||
ch = last_ch;
|
||||
bufPos--;
|
||||
pos--;
|
||||
}
|
||||
// if (ch == '-' && pos < text.length() - 1) {
|
||||
// if (mark > 0 && text.charAt(mark - 1) == '.') {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// char next_char = text.charAt(pos + 1);
|
||||
// if (isIdentifierChar(next_char)) {
|
||||
// bufPos++;
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// if (last_ch == '-' && charAt(pos-2) != '-') {
|
||||
// ch = last_ch;
|
||||
// bufPos--;
|
||||
// pos--;
|
||||
// }
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1583,6 +1583,16 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
if (lexer.token() == Token.FROM) {
|
||||
lexer.nextToken();
|
||||
SQLName database = exprParser.name();
|
||||
if (lexer.token() == Token.SUB && database instanceof SQLIdentifierExpr) {
|
||||
lexer.mark();
|
||||
lexer.nextToken();
|
||||
String strVal = lexer.stringVal();
|
||||
lexer.nextToken();
|
||||
if (database instanceof SQLIdentifierExpr) {
|
||||
SQLIdentifierExpr ident = (SQLIdentifierExpr) database;
|
||||
ident.setName(ident.getName() + "-" + strVal);
|
||||
}
|
||||
}
|
||||
stmt.setDatabase(database);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user