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:
+28
@@ -25,7 +25,10 @@ public class OracleCreateSequenceStatement extends OracleStatementImpl {
|
||||
|
||||
private SQLExpr startWith;
|
||||
private SQLExpr incrementBy;
|
||||
private SQLExpr minValue;
|
||||
private SQLExpr maxValue;
|
||||
private boolean noMaxValue;
|
||||
private boolean noMinValue;
|
||||
|
||||
private Boolean cycle;
|
||||
private Boolean cache;
|
||||
@@ -37,6 +40,7 @@ public class OracleCreateSequenceStatement extends OracleStatementImpl {
|
||||
acceptChild(visitor, name);
|
||||
acceptChild(visitor, startWith);
|
||||
acceptChild(visitor, incrementBy);
|
||||
acceptChild(visitor, minValue);
|
||||
acceptChild(visitor, maxValue);
|
||||
}
|
||||
visitor.endVisit(this);
|
||||
@@ -98,4 +102,28 @@ public class OracleCreateSequenceStatement extends OracleStatementImpl {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public SQLExpr getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public void setMinValue(SQLExpr minValue) {
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
public boolean isNoMaxValue() {
|
||||
return noMaxValue;
|
||||
}
|
||||
|
||||
public void setNoMaxValue(boolean noMaxValue) {
|
||||
this.noMaxValue = noMaxValue;
|
||||
}
|
||||
|
||||
public boolean isNoMinValue() {
|
||||
return noMinValue;
|
||||
}
|
||||
|
||||
public void setNoMinValue(boolean noMinValue) {
|
||||
this.noMinValue = noMinValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1650,6 +1650,22 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
lexer.nextToken();
|
||||
stmt.setCycle(Boolean.FALSE);
|
||||
continue;
|
||||
} else if (identifierEquals("MINVALUE")) {
|
||||
lexer.nextToken();
|
||||
stmt.setMinValue(this.exprParser.expr());
|
||||
continue;
|
||||
} else if (identifierEquals("MAXVALUE")) {
|
||||
lexer.nextToken();
|
||||
stmt.setMaxValue(this.exprParser.expr());
|
||||
continue;
|
||||
} else if (identifierEquals("NOMAXVALUE")) {
|
||||
lexer.nextToken();
|
||||
stmt.setNoMaxValue(true);
|
||||
continue;
|
||||
} else if (identifierEquals("NOMINVALUE")) {
|
||||
lexer.nextToken();
|
||||
stmt.setNoMinValue(true);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+30
-14
@@ -185,24 +185,27 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
}
|
||||
|
||||
public void postVisit(SQLObject x) {
|
||||
if (!isPrintPostSemi()) {
|
||||
if (!(x instanceof SQLStatement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (x instanceof SQLStatement) {
|
||||
if (x instanceof OraclePLSQLCommitStatement) {
|
||||
return;
|
||||
}
|
||||
if (x.getParent() instanceof OracleCreateProcedureStatement) {
|
||||
return;
|
||||
}
|
||||
if ((!isPrintPostSemi()) //
|
||||
&& (!(x.getParent() instanceof OracleBlockStatement))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPrettyFormat()) {
|
||||
if (x.getParent() != null) {
|
||||
print(";");
|
||||
} else {
|
||||
println(";");
|
||||
}
|
||||
if (x instanceof OraclePLSQLCommitStatement) {
|
||||
return;
|
||||
}
|
||||
if (x.getParent() instanceof OracleCreateProcedureStatement) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPrettyFormat()) {
|
||||
if (x.getParent() != null) {
|
||||
print(";");
|
||||
} else {
|
||||
println(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2839,6 +2842,19 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
x.getMaxValue().accept(this);
|
||||
}
|
||||
|
||||
if (x.isNoMaxValue()) {
|
||||
print(" NOMAXVALUE");
|
||||
}
|
||||
|
||||
if (x.getMinValue() != null) {
|
||||
print(" MINVALUE ");
|
||||
x.getMinValue().accept(this);
|
||||
}
|
||||
|
||||
if (x.isNoMinValue()) {
|
||||
print(" NOMINVALUE");
|
||||
}
|
||||
|
||||
if (x.getCycle() != null) {
|
||||
if (x.getCycle().booleanValue()) {
|
||||
print(" CYCLE");
|
||||
|
||||
Reference in New Issue
Block a user