mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved oracle sql parser support CreateSequence. issue #1923
This commit is contained in:
@@ -38,6 +38,8 @@ public class SQLCreateSequenceStatement extends SQLStatementImpl implements SQLD
|
||||
|
||||
private Boolean cycle;
|
||||
private Boolean cache;
|
||||
private SQLExpr cacheValue;
|
||||
|
||||
private Boolean order;
|
||||
|
||||
@Override
|
||||
@@ -144,4 +146,15 @@ public class SQLCreateSequenceStatement extends SQLStatementImpl implements SQLD
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SQLExpr getCacheValue() {
|
||||
return cacheValue;
|
||||
}
|
||||
|
||||
public void setCacheValue(SQLExpr cacheValue) {
|
||||
if (cacheValue != null) {
|
||||
cacheValue.setParent(this);
|
||||
}
|
||||
this.cacheValue = cacheValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2159,11 +2159,23 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
} else if (lexer.token() == Token.CACHE) {
|
||||
lexer.nextToken();
|
||||
stmt.setCache(Boolean.TRUE);
|
||||
|
||||
if (lexer.token() == Token.LITERAL_INT) {
|
||||
stmt.setCacheValue(this.exprParser.primary());
|
||||
}
|
||||
continue;
|
||||
} else if (lexer.token() == Token.NOCACHE) {
|
||||
lexer.nextToken();
|
||||
stmt.setCache(Boolean.FALSE);
|
||||
continue;
|
||||
} else if (lexer.token() == Token.ORDER) {
|
||||
lexer.nextToken();
|
||||
stmt.setOrder(Boolean.TRUE);
|
||||
continue;
|
||||
} else if (identifierEquals("NOORDER")) {
|
||||
lexer.nextToken();
|
||||
stmt.setOrder(Boolean.FALSE);
|
||||
continue;
|
||||
} else if (identifierEquals("CYCLE")) {
|
||||
lexer.nextToken();
|
||||
stmt.setCycle(Boolean.TRUE);
|
||||
|
||||
@@ -4444,14 +4444,30 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getCache() != null) {
|
||||
if (x.getCache().booleanValue()) {
|
||||
Boolean cache = x.getCache();
|
||||
if (cache != null) {
|
||||
if (cache.booleanValue()) {
|
||||
print0(ucase ? " CACHE" : " cache");
|
||||
|
||||
SQLExpr cacheValue = x.getCacheValue();
|
||||
if (cacheValue != null) {
|
||||
print(' ');
|
||||
cacheValue.accept(this);
|
||||
}
|
||||
} else {
|
||||
print0(ucase ? " NOCACHE" : " nocache");
|
||||
}
|
||||
}
|
||||
|
||||
Boolean order = x.getOrder();
|
||||
if (order != null) {
|
||||
if (order.booleanValue()) {
|
||||
print0(ucase ? " ORDER" : " order");
|
||||
} else {
|
||||
print0(ucase ? " NOORDER" : " noorder");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user