improve sql parser

This commit is contained in:
wenshao
2013-03-27 18:21:08 +08:00
parent 255232a8a3
commit 4d85e96301
24 changed files with 597 additions and 97 deletions
@@ -263,15 +263,20 @@ public abstract class WallProvider {
sqlStat.incrementAndGetExecuteCount();
return result;
}
SQLStatementParser parser = createParser(sql);
if (!config.isCommentAllow()) {
parser.getLexer().setAllowComment(false); // deny comment
}
try {
SQLStatementParser parser = createParser(sql);
if (!config.isCommentAllow()) {
parser.getLexer().setAllowComment(false); // deny comment
}
parser.parseStatementList(result.getStatementList());
if (parser.getLexer().token() != Token.EOF) {
result.getViolations().add(new IllegalSQLObjectViolation(sql));
return result;
}
} catch (NotAllowCommentException e) {
result.getViolations().add(new SyntaxErrorViolation(e, sql));
incrementCommentDeniedCount();
@@ -286,11 +291,6 @@ public abstract class WallProvider {
return result;
}
if (parser.getLexer().token() != Token.EOF) {
result.getViolations().add(new IllegalSQLObjectViolation(sql));
return result;
}
if (result.getStatementList().size() == 0) {
return result;
}