bug fixed for mysql parser.

This commit is contained in:
wenshao
2017-06-25 19:04:59 +08:00
parent 4decf975c6
commit 54e9620dc3
3 changed files with 89 additions and 16 deletions
@@ -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);
}