You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by li...@apache.org on 2022/05/28 22:30:25 UTC
[shardingsphere] branch master updated: Support parsing ALTER FLASHBACK ARCHIVE in Oracle (#18036)
This is an automated email from the ASF dual-hosted git repository.
liangda 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 5dca0405b29 Support parsing ALTER FLASHBACK ARCHIVE in Oracle (#18036)
5dca0405b29 is described below
commit 5dca0405b291add91570445bdfb755e728944998
Author: JackieYan <13...@qq.com>
AuthorDate: Sun May 29 06:30:20 2022 +0800
Support parsing ALTER FLASHBACK ARCHIVE in Oracle (#18036)
---
.../src/main/antlr4/imports/oracle/DDLStatement.g4 | 19 ++++++++++++--
.../sql/parser/autogen/OracleStatement.g4 | 1 +
.../impl/OracleDDLStatementSQLVisitor.java | 7 ++++++
.../core/database/visitor/SQLVisitorRule.java | 2 ++
.../ddl/AlterFlashbackArchiveStatement.java | 28 +++++++++++++++++++++
.../ddl/OracleAlterFlashbackArchiveStatement.java | 29 ++++++++++++++++++++++
.../jaxb/cases/domain/SQLParserTestCases.java | 5 ++++
.../AlterFlashbackArchiveStatementTestCase.java | 26 +++++++++++++++++++
.../resources/case/ddl/alter-flashback-archive.xml | 26 +++++++++++++++++++
.../sql/supported/ddl/alter-flashback-archive.xml | 26 +++++++++++++++++++
10 files changed, 167 insertions(+), 2 deletions(-)
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 c0ad6a0055f..fb9eeaffb8b 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
@@ -2389,13 +2389,28 @@ characterSetClause
createFlashbackArchive
: CREATE FLASHBACK ARCHIVE DEFAULT? flashbackArchiveName tablespaceClause
- flashArchiveQuota? (NO? OPTIMIZE DATA)? flashbackArchiveRetention
+ flashbackArchiveQuota? (NO? OPTIMIZE DATA)? flashbackArchiveRetention
;
-flashArchiveQuota
+flashbackArchiveQuota
: QUOTA INTEGER_ quotaUnit
;
flashbackArchiveRetention
: RETENTION INTEGER_ (YEAR | MONTH | DAY)
;
+
+alterFlashbackArchive
+ : ALTER FLASHBACK ARCHIVE flashbackArchiveName
+ ( SET DEFAULT
+ | (ADD | MODIFY) TABLESPACE tablespaceName flashbackArchiveQuota?
+ | REMOVE TABLESPACE tablespaceName
+ | MODIFY RETENTION flashbackArchiveRetention
+ | PURGE purgeClause
+ | NO? OPTIMIZE DATA)
+ ;
+
+purgeClause
+ : ALL
+ | BEFORE (SCN expr | TIMESTAMP expr)
+ ;
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 0639b2f7fbd..08645652c82 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
@@ -93,5 +93,6 @@ execute
| createPFile
| createControlFile
| createFlashbackArchive
+ | alterFlashbackArchive
) 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 a8e11bbda0b..f217ab6813f 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
@@ -98,6 +98,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.Trunca
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TypeNameContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateControlFileContext;
import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateFlashbackArchiveContext;
+import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterFlashbackArchiveContext;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.AlterDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.CreateDefinitionSegment;
import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.column.ColumnDefinitionSegment;
@@ -137,6 +138,7 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.Ora
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateSPFileStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateControlFileStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleCreateFlashbackArchiveStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterFlashbackArchiveStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropEditionStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleDropOutlineStatement;
import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl.OracleAlterOutlineStatement;
@@ -769,4 +771,9 @@ public final class OracleDDLStatementSQLVisitor extends OracleStatementSQLVisito
public ASTNode visitCreateFlashbackArchive(final CreateFlashbackArchiveContext ctx) {
return new OracleCreateFlashbackArchiveStatement();
}
+
+ @Override
+ public ASTNode visitAlterFlashbackArchive(final AlterFlashbackArchiveContext ctx) {
+ return new OracleAlterFlashbackArchiveStatement();
+ }
}
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 976ee142ea3..916dbbab3f2 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
@@ -522,6 +522,8 @@ public enum SQLVisitorRule {
CREATE_FLASHBACK_ARCHIVE("CreateFlashbackArchive", SQLStatementType.DDL),
+ ALTER_FLASHBACK_ARCHIVE("AlterFlashbackArchive", SQLStatementType.DDL),
+
CURSOR("Cursor", SQLStatementType.DDL),
CLOSE("Close", SQLStatementType.DDL),
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterFlashbackArchiveStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterFlashbackArchiveStatement.java
new file mode 100644
index 00000000000..9344b642093
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterFlashbackArchiveStatement.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.common.statement.ddl;
+
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+
+/**
+ * Alter flashback archive statement.
+ */
+@ToString
+public class AlterFlashbackArchiveStatement extends AbstractSQLStatement implements DDLStatement {
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterFlashbackArchiveStatement.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterFlashbackArchiveStatement.java
new file mode 100644
index 00000000000..ad4b5193beb
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/oracle/ddl/OracleAlterFlashbackArchiveStatement.java
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.ddl;
+
+import lombok.ToString;
+import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterFlashbackArchiveStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
+
+/**
+ * Alter flashback archive statement.
+ */
+@ToString
+public class OracleAlterFlashbackArchiveStatement extends AlterFlashbackArchiveStatement implements 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 b584299ca8c..acc07a68b7e 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
@@ -216,6 +216,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.TruncateStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.CreateControlFileStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.CreateFlashbackArchiveStatementTestCase;
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl.AlterFlashbackArchiveStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.AddShardingHintDatabaseValueStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.AddShardingHintTableValueStatementTestCase;
import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.distsql.ral.AlterInstanceStatementTestCase;
@@ -1365,6 +1366,9 @@ public final class SQLParserTestCases {
@XmlElement(name = "create-flashback-archive")
private final List<CreateFlashbackArchiveStatementTestCase> createFlashbackArchiveTestCases = new LinkedList<>();
+ @XmlElement(name = "alter-flashback-archive")
+ private final List<AlterFlashbackArchiveStatementTestCase> alterFlashbackArchiveTestCases = new LinkedList<>();
+
@XmlElement(name = "cursor")
private final List<CursorStatementTestCase> cursorTestCases = new LinkedList<>();
@@ -1719,6 +1723,7 @@ public final class SQLParserTestCases {
putAll(createPFileTestCases, result);
putAll(createControlFileTestCases, result);
putAll(createFlashbackArchiveTestCases, result);
+ putAll(alterFlashbackArchiveTestCases, result);
putAll(cursorTestCases, result);
putAll(closeTestCases, result);
putAll(moveTestCases, result);
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterFlashbackArchiveStatementTestCase.java b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterFlashbackArchiveStatementTestCase.java
new file mode 100644
index 00000000000..8592470248e
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/java/org/apache/shardingsphere/test/sql/parser/parameterized/jaxb/cases/domain/statement/ddl/AlterFlashbackArchiveStatementTestCase.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.ddl;
+
+import org.apache.shardingsphere.test.sql.parser.parameterized.jaxb.cases.domain.statement.SQLParserTestCase;
+
+/**
+ * Alter flashback archive statement test case.
+ */
+public final class AlterFlashbackArchiveStatementTestCase extends SQLParserTestCase {
+}
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-flashback-archive.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-flashback-archive.xml
new file mode 100644
index 00000000000..4d1dbf5df67
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-flashback-archive.xml
@@ -0,0 +1,26 @@
+<?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>
+ <alter-flashback-archive sql-case-id="alter_flashback_archive" />
+ <alter-flashback-archive sql-case-id="alter_flashback_archive_add_tablespace" />
+ <alter-flashback-archive sql-case-id="alter_flashback_archive_modify_retention" />
+ <alter-flashback-archive sql-case-id="alter_flashback_archive_purge_all" />
+ <alter-flashback-archive sql-case-id="alter_flashback_archive_purge_before" />
+ <alter-flashback-archive sql-case-id="alter_flashback_archive_no_optimize_data" />
+</sql-parser-test-cases>
diff --git a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-flashback-archive.xml b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-flashback-archive.xml
new file mode 100644
index 00000000000..a9083121c4a
--- /dev/null
+++ b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-flashback-archive.xml
@@ -0,0 +1,26 @@
+<?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="alter_flashback_archive" value="ALTER FLASHBACK ARCHIVE test_archive SET DEFAULT;" db-types="Oracle" />
+ <sql-case id="alter_flashback_archive_add_tablespace" value="ALTER FLASHBACK ARCHIVE test_archive ADD TABLESPACE example QUOTA 1 M;" db-types="Oracle" />
+ <sql-case id="alter_flashback_archive_modify_retention" value="ALTER FLASHBACK ARCHIVE test_archive MODIFY RETENTION RETENTION 1 YEAR;" db-types="Oracle" />
+ <sql-case id="alter_flashback_archive_purge_all" value="ALTER FLASHBACK ARCHIVE test_archive PURGE ALL;" db-types="Oracle" />
+ <sql-case id="alter_flashback_archive_purge_before" value="ALTER FLASHBACK ARCHIVE test_archive PURGE BEFORE TIMESTAMP 2649009;" db-types="Oracle" />
+ <sql-case id="alter_flashback_archive_no_optimize_data" value="ALTER FLASHBACK ARCHIVE test_archive NO OPTIMIZE DATA;" db-types="Oracle" />
+</sql-cases>