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 dc2d739f196 Support parsing of ALTER SERVER in PostgreSQL (#19395)
dc2d739f196 is described below
commit dc2d739f19606ede19aeec926b6a25182bbcaae7
Author: Everly Precia Suresh <[email protected]>
AuthorDate: Thu Jul 21 06:18:47 2022 +0530
Support parsing of ALTER SERVER in PostgreSQL (#19395)
---
.../impl/PostgreSQLDDLStatementSQLVisitor.java | 7 ++++++
.../common/statement/ddl/AlterServerStatement.java | 28 +++++++++++++++++++++
.../ddl/PostgreSQLAlterServerStatement.java | 29 ++++++++++++++++++++++
.../src/main/resources/case/ddl/alter-server.xml | 4 +--
.../{case => sql/supported}/ddl/alter-server.xml | 8 +++---
.../main/resources/sql/unsupported/unsupported.xml | 16 ------------
6 files changed, 70 insertions(+), 22 deletions(-)
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
index 82ed8a49050..73dc4e686b2 100644
---
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDDLStatementSQLVisitor.java
@@ -47,6 +47,7 @@ import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.Al
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterRoutineContext;
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterRuleContext;
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterSchemaContext;
+import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterServerContext;
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterSequenceContext;
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterTableActionContext;
import
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AlterTableContext;
@@ -215,6 +216,7 @@ import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterRoutineStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterRuleStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterSchemaStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterServerStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterSequenceStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterTableStatement;
import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl.PostgreSQLAlterTablespaceStatement;
@@ -927,6 +929,11 @@ public final class PostgreSQLDDLStatementSQLVisitor
extends PostgreSQLStatementS
return new PostgreSQLAlterLanguageStatement();
}
+ @Override
+ public ASTNode visitAlterServer(final AlterServerContext ctx) {
+ return new PostgreSQLAlterServerStatement();
+ }
+
@Override
public ASTNode visitDropLanguage(final DropLanguageContext ctx) {
return new PostgreSQLDropLanguageStatement();
diff --git
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterServerStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterServerStatement.java
new file mode 100644
index 00000000000..a9112380495
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/ddl/AlterServerStatement.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 server statement.
+ */
+@ToString(callSuper = true)
+public abstract class AlterServerStatement 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/postgresql/ddl/PostgreSQLAlterServerStatement.java
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLAlterServerStatement.java
new file mode 100644
index 00000000000..156341e5fbe
--- /dev/null
+++
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/ddl/PostgreSQLAlterServerStatement.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.postgresql.ddl;
+
+import lombok.ToString;
+import
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterServerStatement;
+import
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
+
+/**
+ * PostgreSQL alter server statement.
+ */
+@ToString(callSuper = true)
+public final class PostgreSQLAlterServerStatement extends AlterServerStatement
implements PostgreSQLStatement {
+}
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
index 4756de34f44..2a17cbeec18 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
@@ -17,6 +17,6 @@
-->
<sql-parser-test-cases>
-<!-- <alter-server sql-case-id="alter_server_options" />-->
-<!-- <alter-server sql-case-id="alter_server_version" />-->
+ <alter-server sql-case-id="alter_server_options" />
+ <alter-server sql-case-id="alter_server_version" />
</sql-parser-test-cases>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-server.xml
similarity index 76%
copy from
shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
copy to
shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-server.xml
index 4756de34f44..213dcff18d1 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/case/ddl/alter-server.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/supported/ddl/alter-server.xml
@@ -16,7 +16,7 @@
~ limitations under the License.
-->
-<sql-parser-test-cases>
-<!-- <alter-server sql-case-id="alter_server_options" />-->
-<!-- <alter-server sql-case-id="alter_server_version" />-->
-</sql-parser-test-cases>
+<sql-cases>
+ <sql-case id="alter_server_options" value="ALTER SERVER foo OPTIONS (host
'foo', dbname 'foodb');" db-types="PostgreSQL" />
+ <sql-case id="alter_server_version" value="ALTER SERVER foo VERSION
'8.4';" db-types="PostgreSQL" />
+</sql-cases>
diff --git
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
index 51268e03f29..a8a57e5c821 100644
---
a/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
+++
b/shardingsphere-test/shardingsphere-parser-test/src/main/resources/sql/unsupported/unsupported.xml
@@ -3318,22 +3318,6 @@
<sql-case id="alter_by_postgresql_source_test_case214" value="ALTER
OPERATOR FAMILY alt_opf7 USING btree DROP OPERATOR 1 (int4, int2, int8);"
db-types="PostgreSQL" />
<sql-case id="alter_by_postgresql_source_test_case215" value="ALTER
OPERATOR FAMILY alt_opf8 USING btree ADD OPERATOR 1 < (int4, int4);"
db-types="PostgreSQL" />
<sql-case id="alter_by_postgresql_source_test_case216" value="ALTER
OPERATOR FAMILY alt_opf9 USING gist ADD OPERATOR 1 < (int4, int4) FOR ORDER
BY float_ops;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case296" value="ALTER SERVER
alt_fserv1 RENAME TO alt_fserv2;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case297" value="ALTER SERVER
alt_fserv1 RENAME TO alt_fserv3;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case298" value="ALTER SERVER
s0;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case299" value="ALTER SERVER
s1 OWNER TO regress_test_indirect;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case300" value="ALTER SERVER
s1 OWNER TO regress_test_indirect;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case301" value="ALTER SERVER
s1 OWNER TO regress_test_indirect;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case302" value="ALTER SERVER
s1 OWNER TO regress_test_role2;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case303" value="ALTER SERVER
s1 OWNER TO regress_test_role;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case304" value="ALTER SERVER
s1 OWNER TO regress_test_role;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case305" value="ALTER SERVER
s2 OWNER TO regress_test_role;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case306" value="ALTER SERVER
s4 OWNER TO regress_unprivileged_role;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case307" value="ALTER SERVER
s5 OWNER TO regress_test_role;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case308" value="ALTER SERVER
s6 OWNER TO regress_test_indirect;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case309" value="ALTER SERVER
s8 RENAME to s8new;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case310" value="ALTER SERVER
s8new RENAME to s8;" db-types="PostgreSQL" />
- <sql-case id="alter_by_postgresql_source_test_case311" value="ALTER SERVER
t1 OWNER TO regress_test_indirect;" db-types="PostgreSQL" />
<sql-case id="alter_by_postgresql_source_test_case312" value="ALTER
STATISTICS IF EXISTS ab1_a_b_stats SET STATISTICS 0;" db-types="PostgreSQL" />
<sql-case id="alter_by_postgresql_source_test_case313" value="ALTER
STATISTICS ab1_a_b_stats RENAME TO ab1_a_b_stats_new;" db-types="PostgreSQL" />
<sql-case id="alter_by_postgresql_source_test_case314" value="ALTER
STATISTICS ab1_a_b_stats SET STATISTICS -1;" db-types="PostgreSQL" />