This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 23944b2f06c Support Parsing DROP PUBLICATION in openGauss (#18172)
23944b2f06c is described below
commit 23944b2f06c466f37b6d2da92ab511a713a93b19
Author: Everly Precia Suresh <[email protected]>
AuthorDate: Sun Jun 5 08:18:08 2022 +0530
Support Parsing DROP PUBLICATION in openGauss (#18172)
---
.../main/antlr4/imports/opengauss/DDLStatement.g4 | 2 +-
.../sql/parser/autogen/OpenGaussStatement.g4 | 1 +
.../impl/OpenGaussDDLStatementSQLVisitor.java | 7 ++++++
.../ddl/OpenGaussDropPublicationStatement.java | 29 ++++++++++++++++++++++
.../sql/supported/ddl/drop-publication.xml | 4 +--
5 files changed, 40 insertions(+), 3 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
index 66b9bb86f1c..b8ae1647714 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/imports/opengauss/DDLStatement.g4
@@ -1709,7 +1709,7 @@ dropProcedure
;
dropPublication
- : DROP PUBLICATION existClause? anyNameList dropBehavior?
+ : DROP PUBLICATION existClause? name dropBehavior?
;
dropRoutine
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
index ce36dbbd3b6..0fe71793694 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/OpenGaussStatement.g4
@@ -134,5 +134,6 @@ execute
| checkpoint
| alterType
| createPublication
+ | dropPublication
) SEMI_? EOF
;
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
index 66daf2c4fd3..9efe2b72a6d 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/impl/OpenGaussDDLStatementSQLVisitor.java
@@ -92,6 +92,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.Dro
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropIndexContext;
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropLanguageContext;
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropProcedureContext;
+import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropPublicationContext;
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSchemaContext;
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSequenceContext;
import
org.apache.shardingsphere.sql.parser.autogen.OpenGaussStatementParser.DropSynonymContext;
@@ -205,6 +206,7 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropIndexStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropLanguageStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropProcedureStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropPublicationStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSchemaStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSequenceStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.ddl.OpenGaussDropSynonymStatement;
@@ -641,6 +643,11 @@ public final class OpenGaussDDLStatementSQLVisitor extends
OpenGaussStatementSQL
return new OpenGaussDropProcedureStatement();
}
+ @Override
+ public ASTNode visitDropPublication(final DropPublicationContext ctx) {
+ return new OpenGaussDropPublicationStatement();
+ }
+
@Override
public ASTNode visitDropCast(final DropCastContext ctx) {
return new OpenGaussDropCastStatement();
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropPublicationStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropPublicationStatement.java
new file mode 100644
index 00000000000..e6c8e61225e
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/opengauss/ddl/OpenGaussDropPublicationStatement.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.opengauss.ddl;
+
+import lombok.ToString;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropPublicationStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.OpenGaussStatement;
+
+/**
+ * OpenGauss drop publication statement.
+ */
+@ToString
+public final class OpenGaussDropPublicationStatement extends
DropPublicationStatement implements OpenGaussStatement {
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-publication.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-publication.xml
index fd615f4dfb1..dbb6496fb01 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-publication.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/drop-publication.xml
@@ -17,8 +17,8 @@
-->
<sql-cases>
- <sql-case id="drop_publication_if_exists" value="DROP PUBLICATION IF
EXISTS s10;" db-types="PostgreSQL" />
- <sql-case id="drop_publication" value="DROP PUBLICATION mypublication;"
db-types="PostgreSQL" />
+ <sql-case id="drop_publication_if_exists" value="DROP PUBLICATION IF
EXISTS s10;" db-types="PostgreSQL,openGauss" />
+ <sql-case id="drop_publication" value="DROP PUBLICATION mypublication;"
db-types="PostgreSQL,openGauss" />
<sql-case id="drop_publication_s11_and_s22" value="DROP PUBLICATION
s11,s22;" db-types="PostgreSQL" />
<sql-case id="drop_publication_cascade" value="DROP PUBLICATION s11,s22
CASCADE;" db-types="PostgreSQL" />
<sql-case id="drop_publication_restrict" value="DROP PUBLICATION s11,s22
RESTRICT;" db-types="PostgreSQL" />