mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved create oracle createMaterializedView support. for issue #2211
This commit is contained in:
+1
-14
@@ -203,7 +203,7 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
|
||||
stmt.setPartitioning(partitionByHash);
|
||||
continue;
|
||||
} else if (lexer.identifierEquals("LIST")) {
|
||||
SQLPartitionByList partitionByList = partitionByList();
|
||||
SQLPartitionByList partitionByList = this.getExprParser().partitionByList();
|
||||
this.getExprParser().partitionClauseRest(partitionByList);
|
||||
stmt.setPartitioning(partitionByList);
|
||||
continue;
|
||||
@@ -329,19 +329,6 @@ public class OracleCreateTableParser extends SQLCreateTableParser {
|
||||
stmt.setOrganization(organization);
|
||||
}
|
||||
|
||||
protected SQLPartitionByList partitionByList() {
|
||||
acceptIdentifier("LIST");
|
||||
SQLPartitionByList partitionByList = new SQLPartitionByList();
|
||||
|
||||
accept(Token.LPAREN);
|
||||
partitionByList.addColumn(this.exprParser.expr());
|
||||
accept(Token.RPAREN);
|
||||
|
||||
this.getExprParser().parsePartitionByRest(partitionByList);
|
||||
|
||||
return partitionByList;
|
||||
}
|
||||
|
||||
protected void parseCreateTableSupplementalLogingProps(SQLCreateTableStatement stmt) {
|
||||
acceptIdentifier("SUPPLEMENTAL");
|
||||
acceptIdentifier("LOG");
|
||||
|
||||
@@ -1632,6 +1632,57 @@ public class OracleExprParser extends SQLExprParser {
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLPartitionBy parsePartitionBy() {
|
||||
lexer.nextToken();
|
||||
|
||||
accept(Token.BY);
|
||||
|
||||
SQLPartitionBy partitionBy;
|
||||
|
||||
if (lexer.identifierEquals("RANGE")) {
|
||||
return this.partitionByRange();
|
||||
} else if (lexer.identifierEquals("HASH")) {
|
||||
SQLPartitionByHash partitionByHash = this.partitionByHash();
|
||||
this.partitionClauseRest(partitionByHash);
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
for (;;) {
|
||||
SQLPartition partition = this.parsePartition();
|
||||
partitionByHash.addPartition(partition);
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
continue;
|
||||
} else if (lexer.token() == Token.RPAREN) {
|
||||
lexer.nextToken();
|
||||
break;
|
||||
}
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
}
|
||||
return partitionByHash;
|
||||
} else if (lexer.identifierEquals("LIST")) {
|
||||
SQLPartitionByList partitionByList = partitionByList();
|
||||
this.partitionClauseRest(partitionByList);
|
||||
return partitionByList;
|
||||
} else {
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
}
|
||||
|
||||
protected SQLPartitionByList partitionByList() {
|
||||
acceptIdentifier("LIST");
|
||||
SQLPartitionByList partitionByList = new SQLPartitionByList();
|
||||
|
||||
accept(Token.LPAREN);
|
||||
partitionByList.addColumn(this.expr());
|
||||
accept(Token.RPAREN);
|
||||
|
||||
this.parsePartitionByRest(partitionByList);
|
||||
|
||||
return partitionByList;
|
||||
}
|
||||
|
||||
protected SQLPartitionByRange partitionByRange() {
|
||||
acceptIdentifier("RANGE");
|
||||
accept(Token.LPAREN);
|
||||
|
||||
@@ -606,6 +606,15 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.MATERIALIZED)) {
|
||||
lexer.reset(savePoint);
|
||||
|
||||
SQLStatement stmt = parseDropMaterializedView();
|
||||
stmt.setParent(parent);
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
throw new ParserException("TODO : " + lexer.info());
|
||||
}
|
||||
|
||||
@@ -711,6 +720,21 @@ public class OracleStatementParser extends SQLStatementParser {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseDropMaterializedView() {
|
||||
if (lexer.token() == Token.DROP) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
SQLDropMaterializedViewStatement stmt = new SQLDropMaterializedViewStatement();
|
||||
stmt.setDbType(dbType);
|
||||
|
||||
acceptIdentifier("MATERIALIZED");
|
||||
|
||||
accept(Token.VIEW);
|
||||
|
||||
stmt.setName(this.exprParser.name());
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseDropSynonym() {
|
||||
if (lexer.token() == Token.DROP) {
|
||||
lexer.nextToken();
|
||||
|
||||
Reference in New Issue
Block a user