improve sql parser performance

This commit is contained in:
wenshao
2013-01-12 23:31:04 +08:00
parent 6c875e1ee0
commit 2c25af9bc1
2 changed files with 31 additions and 2 deletions
@@ -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;