bug: 修复多出解析bug

This commit is contained in:
fanglei
2020-11-04 20:38:11 +08:00
parent 4b3ed4c714
commit f1089660a1
4 changed files with 24 additions and 10 deletions
@@ -9099,6 +9099,8 @@ public class MySqlStatementParser extends SQLStatementParser {
MySqlLeaveStatement leaveStmt = new MySqlLeaveStatement();
leaveStmt.setLabelName(exprParser.name().getSimpleName());
accept(Token.SEMI);
leaveStmt.setAfterSemi(true);
return leaveStmt;
}
@@ -9168,7 +9170,8 @@ public class MySqlStatementParser extends SQLStatementParser {
stmt.setSelect(select);
accept(Token.SEMI);
stmt.setAfterSemi(true);
return stmt;
}
@@ -9304,7 +9307,8 @@ public class MySqlStatementParser extends SQLStatementParser {
if (!(stmt.getSpStatement() instanceof SQLBlockStatement)) {
accept(Token.SEMI);
}
stmt.setAfterSemi(true);
return stmt;
}
@@ -168,6 +168,9 @@ public class OracleStatementParser extends SQLStatementParser {
SQLStatement stmt = parseBlock();
stmt.setParent(parent);
statementList.add(stmt);
if(parent instanceof SQLCreateTriggerStatement) {
return;
}
continue;
}
@@ -1953,6 +1956,8 @@ public class OracleStatementParser extends SQLStatementParser {
SQLExpr indexBy = this.exprParser.primary();
((SQLDataTypeImpl) dataType).setIndexBy(indexBy);
}
}else if (lexer.token() == Token.SEMI) {
dataType = new SQLDataTypeImpl("TABLE OF " + name.toString());
}
dataType.setDbType(dbType);
} else if (lexer.identifierEquals("VARRAY")) {
@@ -595,6 +595,9 @@ public class SQLStatementParser extends SQLParser {
SQLStatement dialectStmt = statementList.get(j);
dialectStmt.setParent(parent);
}
if (parent instanceof SQLCreateTriggerStatement) {
return;
}
}
continue;
@@ -3848,7 +3851,7 @@ public class SQLStatementParser extends SQLParser {
stmt.setWhen(condition);
}
List<SQLStatement> body = this.parseStatementList();
List<SQLStatement> body = this.parseStatementList(stmt);
if (body == null || body.isEmpty()) {
throw new ParserException("syntax error");
}
@@ -2890,6 +2890,8 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
} else if (expr instanceof SQLMethodInvokeExpr) {
visit((SQLMethodInvokeExpr) expr);
} else if (expr instanceof SQLListExpr) {
printAndAccept(((SQLListExpr) expr).getItems(), ",");
} else {
expr.accept(this);
}
@@ -4385,19 +4387,19 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
if (x.isDropStorage()) {
print0(ucase ? " DROP STORAGE" : " drop storage");
print0(ucase ? " DROP STORAGE" : " drop storage");
}
if (x.isReuseStorage()) {
print0(ucase ? " REUSE STORAGE" : " reuse storage");
print0(ucase ? " REUSE STORAGE" : " reuse storage");
}
if (x.isIgnoreDeleteTriggers()) {
print0(ucase ? " IGNORE DELETE TRIGGERS" : " ignore delete triggers");
print0(ucase ? " IGNORE DELETE TRIGGERS" : " ignore delete triggers");
}
if (x.isRestrictWhenDeleteTriggers()) {
print0(ucase ? " RESTRICT WHEN DELETE TRIGGERS" : " restrict when delete triggers");
print0(ucase ? " RESTRICT WHEN DELETE TRIGGERS" : " restrict when delete triggers");
}
if (x.isContinueIdentity()) {
@@ -4405,7 +4407,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
}
if (x.isImmediate()) {
print0(ucase ? " IMMEDIATE" : " immediate");
print0(ucase ? " IMMEDIATE" : " immediate");
}
return false;
@@ -5098,7 +5100,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
@Override
public boolean visit(SQLKeep x) {
if (x.getDenseRank() == SQLKeep.DenseRank.FIRST) {
print0(ucase ? "KEEP (DENSE_RANK FIRST " : "keep (dense_rank first ");
print0(ucase ? "KEEP (DENSE_RANK FIRST " : "keep (dense_rank first ");
} else {
print0(ucase ? "KEEP (DENSE_RANK LAST " : "keep (dense_rank last ");
}
@@ -7470,7 +7472,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
protected void printPartitions(List<SQLName> partitions) {
if (partitions.size() == 1 && "ALL".equalsIgnoreCase(partitions.get(0).getSimpleName())) {
print0(ucase ? "ALL" : "all");
print0(ucase ? "ALL" : "all");
} else {
printAndAccept(partitions, ", ");
}