mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser performance
This commit is contained in:
@@ -1783,7 +1783,10 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
lexer.nextTokenLParen();
|
||||
|
||||
for (;;) {
|
||||
accept(Token.LPAREN);
|
||||
if (lexer.token() != Token.LPAREN) {
|
||||
throw new SQLParseException("syntax error, expect ')'");
|
||||
}
|
||||
lexer.nextTokenValue();
|
||||
|
||||
if (lexer.token() != Token.RPAREN) {
|
||||
List<SQLExpr> valueExprList;
|
||||
@@ -1810,7 +1813,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
valueExprList.add(expr);
|
||||
lexer.nextToken();
|
||||
lexer.nextTokenValue();
|
||||
continue;
|
||||
} else if (lexer.token() == Token.RPAREN) {
|
||||
valueExprList.add(expr);
|
||||
|
||||
@@ -221,6 +221,32 @@ public class Lexer {
|
||||
nextToken();
|
||||
}
|
||||
|
||||
public final void nextTokenValue() {
|
||||
if (ch == ' ') {
|
||||
scanChar();
|
||||
}
|
||||
|
||||
if (ch == '\'') {
|
||||
bufPos = 0;
|
||||
scanString();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
bufPos = 0;
|
||||
scanNumber();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ch == '?') {
|
||||
scanChar();
|
||||
token = Token.QUES;
|
||||
return;
|
||||
}
|
||||
|
||||
nextToken();
|
||||
}
|
||||
|
||||
public final void nextToken() {
|
||||
bufPos = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user