mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve sql parser
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user