mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved mysql parser
This commit is contained in:
@@ -141,6 +141,14 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
public MySqlDeleteStatement parseDeleteStatement() {
|
||||
MySqlDeleteStatement deleteStatement = new MySqlDeleteStatement();
|
||||
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
List<String> comments = lexer.readAndResetComments();
|
||||
|
||||
if (comments != null) {
|
||||
deleteStatement.addBeforeComment(comments);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.DELETE) {
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -5123,6 +5131,11 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
|
||||
public SQLStatement parseAlter() {
|
||||
List<String> comments = null;
|
||||
if (lexer.isKeepComments() && lexer.hasComment()) {
|
||||
comments = lexer.readAndResetComments();
|
||||
}
|
||||
|
||||
Lexer.SavePoint mark = lexer.mark();
|
||||
accept(Token.ALTER);
|
||||
|
||||
@@ -5150,7 +5163,12 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.TABLE) {
|
||||
return parseAlterTable(ignore, online, offline);
|
||||
SQLStatement alterTable = parseAlterTable(ignore, online, offline);
|
||||
if (comments != null) {
|
||||
alterTable.addBeforeComment(comments);
|
||||
}
|
||||
|
||||
return alterTable;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.DATABASE
|
||||
|
||||
@@ -1016,6 +1016,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isPrettyFormat() && x.hasBeforeComment()) {
|
||||
this.printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
|
||||
print0(ucase ? "DELETE " : "delete ");
|
||||
|
||||
for (int i = 0, size = x.getHintsSize(); i < size; ++i) {
|
||||
@@ -1101,6 +1105,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isPrettyFormat() && x.hasBeforeComment()) {
|
||||
this.printlnComments(x.getBeforeCommentsDirect());
|
||||
}
|
||||
|
||||
SQLWithSubqueryClause with = x.getWith();
|
||||
if (with != null) {
|
||||
visit(with);
|
||||
|
||||
@@ -4825,7 +4825,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLAlterViewStatement x) {
|
||||
print0(ucase ? "ALTER " : "atler ");
|
||||
print0(ucase ? "ALTER " : "alter ");
|
||||
|
||||
this.indentCount++;
|
||||
String algorithm = x.getAlgorithm();
|
||||
@@ -4844,7 +4844,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
String sqlSecurity = x.getSqlSecurity();
|
||||
if (sqlSecurity != null && sqlSecurity.length() > 0) {
|
||||
print0(ucase ? "SQL SECURITY = " : "sql security = ");
|
||||
print0(ucase ? "SQL SECURITY " : "sql security ");
|
||||
print0(sqlSecurity);
|
||||
println();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user