This is an automated email from the ASF dual-hosted git repository.
wangguangyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c3757f3 Add Oracle SQL - FLASHBACK DATABASE (#11487)
c3757f3 is described below
commit c3757f3566c2a344ae77b74bb0df91a99e3fca03
Author: Liangda-w <[email protected]>
AuthorDate: Tue Jul 27 02:04:36 2021 +0200
Add Oracle SQL - FLASHBACK DATABASE (#11487)
* Add Oracle SQL - FLASHBACK DATABASE
* Add new line
* modifiy expr
---
.../src/main/antlr4/imports/oracle/BaseRule.g4 | 14 +++++-
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 18 ++++++--
.../main/antlr4/imports/oracle/OracleKeyword.g4 | 12 +++++
.../sql/parser/autogen/OracleStatement.g4 | 1 +
.../impl/OracleDDLStatementSQLVisitor.java | 7 +++
.../core/database/visitor/SQLVisitorRule.java | 2 +
.../ddl/OracleFlashbackDatabaseStatement.java} | 53 +++++-----------------
.../jaxb/cases/domain/SQLParserTestCases.java | 5 ++
.../ddl/FlashbackDatabaseStatementTestCase.java | 49 +++-----------------
.../main/resources/case/ddl/flashback-database.xml | 24 ++++++++++
.../sql/supported/ddl/flashback-database.xml | 24 ++++++++++
11 files changed, 120 insertions(+), 89 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
index 14e3d88..b3f4d89 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/BaseRule.g4
@@ -96,7 +96,7 @@ unreservedWord
| BECOME | CHANGE | NOTIFICATION | PRIVILEGE | PURGE | RESUMABLE
| SYSGUID | SYSBACKUP | SYSDBA | SYSDG | SYSKM | SYSOPER | DBA_RECYCLEBIN
|SCHEMA
| DO | DEFINER | CURRENT_USER | CASCADED | CLOSE | OPEN | NEXT | NAME |
NAMES
- | COLLATION | REAL | TYPE | FIRST | RANK
+ | COLLATION | REAL | TYPE | FIRST | RANK | SAMPLE
;
schemaName
@@ -815,3 +815,15 @@ seedValue
namespace
: identifier
;
+
+restorePoint
+ : identifier
+ ;
+
+scnValue
+ : literals
+ ;
+
+scnTimestampExpr
+ : scnValue | identifier
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
index 6c27202..2ab7723 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/DDLStatement.g4
@@ -1444,10 +1444,6 @@ startStandbyClause
: START LOGICAL STANDBY APPLY IMMEDIATE? NODELAY? (NEW PRIMARY dbLink |
INITIAL scnValue? | (SKIP_SYMBOL FAILED TRANSACTION | FINISH))?
;
-scnValue
- : literals
- ;
-
stopStandbyClause
: (STOP | ABORT) LOGICAL STANDBY APPLY
;
@@ -1893,3 +1889,17 @@ comment
| TABLE (tableName | viewName)
) IS STRING_
;
+
+flashbackDatabase
+ : FLASHBACK STANDBY? PLUGGABLE? DATABASE databaseName?
+ ( TO (scnTimestampClause | restorePointClause)
+ | TO BEFORE (scnTimestampClause | RESETLOGS))
+ ;
+
+scnTimestampClause
+ : (SCN | TIMESTAMP) scnTimestampExpr
+ ;
+
+restorePointClause
+ : RESTORE POINT restorePoint
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
index 43f7a9c..8cde546 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/imports/oracle/OracleKeyword.g4
@@ -2386,3 +2386,15 @@ SETS
DECODE
: D E C O D E
;
+
+RESTORE
+ : R E S T O R E
+ ;
+
+POINT
+ : P O I N T
+ ;
+
+BEFORE
+ : B E F O R E
+ ;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
index 1e45a5a..0e14013 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
@@ -57,5 +57,6 @@ execute
| audit
| noAudit
| comment
+ | flashbackDatabase
) SEMI_?
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
index 1719fc0..63fe451 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleDDLStatementSQLVisitor.java
@@ -46,6 +46,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropCo
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropConstraintClauseContext;
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropIndexContext;
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropTableContext;
+import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.FlashbackDatabaseContext;
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.IndexNameContext;
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.InlineConstraintContext;
import
org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ModifyColPropertiesContext;
@@ -89,6 +90,7 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.Ora
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDisassociateStatisticsStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropIndexStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropTableStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleFlashbackDatabaseStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleNoAuditStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleTruncateStatement;
@@ -461,4 +463,9 @@ public final class OracleDDLStatementSQLVisitor extends
OracleStatementSQLVisito
}
return result;
}
+
+ @Override
+ public ASTNode visitFlashbackDatabase(final FlashbackDatabaseContext ctx) {
+ return new OracleFlashbackDatabaseStatement();
+ }
}
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
index 838d76a..c5d0a55 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/database/visitor/SQLVisitorRule.java
@@ -139,6 +139,8 @@ public enum SQLVisitorRule {
NOAUDIT("NoAudit", SQLStatementType.DDL),
COMMENT("Comment", SQLStatementType.DDL),
+
+ FLASHBACK_DATABASE("FlashbackDatabase", SQLStatementType.DDL),
SET_CONSTRAINTS("SetConstraints", SQLStatementType.TCL),
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleFlashbackDatabaseStatement.java
similarity index 51%
copy from
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
copy to
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleFlashbackDatabaseStatement.java
index 1e45a5a..e247650 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleFlashbackDatabaseStatement.java
@@ -15,47 +15,16 @@
* limitations under the License.
*/
-grammar OracleStatement;
+package org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl;
-import Symbol, Comments, DMLStatement, DDLStatement, TCLStatement,
DCLStatement, StoreProcedure;
+import lombok.ToString;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DDLStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
-execute
- : (select
- | insert
- | update
- | delete
- | createTable
- | alterTable
- | dropTable
- | truncateTable
- | createIndex
- | dropIndex
- | alterIndex
- | commit
- | rollback
- | setTransaction
- | savepoint
- | grant
- | revoke
- | createUser
- | dropUser
- | alterUser
- | createRole
- | dropRole
- | alterRole
- | setRole
- | call
- | merge
- | alterSynonym
- | alterSession
- | alterDatabase
- | alterSystem
- | setConstraints
- | analyze
- | associateStatistics
- | disassociateStatistics
- | audit
- | noAudit
- | comment
- ) SEMI_?
- ;
+/**
+ * Oracle flashback database statement.
+ */
+@ToString
+public class OracleFlashbackDatabaseStatement extends AbstractSQLStatement
implements DDLStatement, OracleStatement {
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
index 4964916..593a62c 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/SQLParserTestCases.java
@@ -80,6 +80,7 @@ import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.DropTableStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.DropTriggerStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.DropViewStatementTestCase;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.FlashbackDatabaseStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.NoAuditStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.TruncateStatementTestCase;
import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.ShowScalingJobListStatementTestCase;
@@ -367,6 +368,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "comment")
private final List<CommentStatementTestCase> commentTestCase = new
LinkedList<>();
+
+ @XmlElement(name = "flashback-database")
+ private final List<FlashbackDatabaseStatementTestCase>
flashbackDatabaseTestCase = new LinkedList<>();
@XmlElement(name = "add-resource")
private final List<AddResourceStatementTestCase> addResourceTestCase = new
LinkedList<>();
@@ -535,6 +539,7 @@ public final class SQLParserTestCases {
putAll(auditTestCase, result);
putAll(noAuditTestCase, result);
putAll(commentTestCase, result);
+ putAll(flashbackDatabaseTestCase, result);
putAll(addResourceTestCase, result);
putAll(alterDataBaseDiscoveryRuleTestCase, result);
putAll(alterEncryptRuleTestCase, result);
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FlashbackDatabaseStatementTestCase.java
similarity index 51%
copy from
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
copy to
shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FlashbackDatabaseStatementTestCase.java
index 1e45a5a..09217ee 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OracleStatement.g4
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/FlashbackDatabaseStatementTestCase.java
@@ -15,47 +15,12 @@
* limitations under the License.
*/
-grammar OracleStatement;
+package
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl;
-import Symbol, Comments, DMLStatement, DDLStatement, TCLStatement,
DCLStatement, StoreProcedure;
+import
org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
-execute
- : (select
- | insert
- | update
- | delete
- | createTable
- | alterTable
- | dropTable
- | truncateTable
- | createIndex
- | dropIndex
- | alterIndex
- | commit
- | rollback
- | setTransaction
- | savepoint
- | grant
- | revoke
- | createUser
- | dropUser
- | alterUser
- | createRole
- | dropRole
- | alterRole
- | setRole
- | call
- | merge
- | alterSynonym
- | alterSession
- | alterDatabase
- | alterSystem
- | setConstraints
- | analyze
- | associateStatistics
- | disassociateStatistics
- | audit
- | noAudit
- | comment
- ) SEMI_?
- ;
+/**
+ * Flashback database statement test case.
+ */
+public final class FlashbackDatabaseStatementTestCase extends
SQLParserTestCase {
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/flashback-database.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/flashback-database.xml
new file mode 100644
index 0000000..89b8064
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/flashback-database.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<sql-parser-test-cases>
+ <flashback-database sql-case-id="flashback_database_to_scn" />
+ <flashback-database sql-case-id="flashback_database_to_timestamp" />
+ <flashback-database sql-case-id="flashback_database_to_restore_point" />
+ <flashback-database sql-case-id="flashback_database_to_before_resetlogs" />
+</sql-parser-test-cases>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/flashback-database.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/flashback-database.xml
new file mode 100644
index 0000000..fde5aea
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/flashback-database.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<sql-cases>
+ <sql-case id="flashback_database_to_scn" value="FLASHBACK STANDBY
PLUGGABLE DATABASE TO SCN 1500" db-types="Oracle" />
+ <sql-case id="flashback_database_to_timestamp" value="FLASHBACK DATABASE
TO TIMESTAMP SYSDATE-1" db-types="Oracle" />
+ <sql-case id="flashback_database_to_restore_point" value="FLASHBACK
DATABASE sample TO RESTORE POINT good_data" db-types="Oracle" />
+ <sql-case id="flashback_database_to_before_resetlogs" value="FLASHBACK
DATABASE TO BEFORE RESETLOGS" db-types="Oracle" />
+</sql-cases>