You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/06/08 02:44:17 UTC
(shardingsphere) branch master updated: Add infra-route-postgresql module (#35641)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 f6f98db2a1a Add infra-route-postgresql module (#35641)
f6f98db2a1a is described below
commit f6f98db2a1af2198f2225ecd2fdf44f892ddf46d
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Jun 8 10:44:10 2025 +0800
Add infra-route-postgresql module (#35641)
* Add infra-route-postgresql module
* Add infra-route-postgresql module
---
.../tableless/TablelessRouteEngineFactory.java | 39 +++++++++----------
.../tableless/TablelessRouteEngineFactoryTest.java | 14 ++++++-
infra/route/dialect/pom.xml | 1 +
.../route/dialect/postgresql}/pom.xml | 11 +++---
.../PostgreSQLTablelessBroadcastRouteDecider.java | 44 ++++++++++++++++++++++
...tableless.DialectTablelessBroadcastRouteDecider | 18 +++++++++
jdbc-dialect/mariadb/pom.xml | 6 +++
jdbc-dialect/opengauss/pom.xml | 6 +++
jdbc-dialect/postgresql/pom.xml | 6 +++
.../type/OpenGaussDALStatementVisitor.java | 8 ++--
.../type/PostgreSQLDALStatementVisitor.java | 8 ++--
.../postgresql/dal/PostgreSQLLoadStatement.java} | 7 ++--
.../dal/PostgreSQLResetParameterStatement.java} | 7 ++--
.../admin/PostgreSQLAdminExecutorCreator.java | 6 +--
.../PostgreSQLResetVariableAdminExecutor.java | 4 +-
.../admin/PostgreSQLAdminExecutorCreatorTest.java | 4 +-
.../PostgreSQLResetVariableAdminExecutorTest.java | 4 +-
proxy/dialect/mariadb/pom.xml | 6 +++
proxy/dialect/opengauss/pom.xml | 6 +++
proxy/dialect/postgresql/pom.xml | 6 +++
.../command/query/PostgreSQLCommand.java | 4 +-
.../command/query/PostgreSQLCommandTest.java | 4 +-
.../asserts/statement/dal/DALStatementAssert.java | 6 +--
.../dal/impl/ResetParameterStatementAssert.java | 4 +-
24 files changed, 171 insertions(+), 58 deletions(-)
diff --git a/infra/route/core/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactory.java b/infra/route/core/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactory.java
index cd85a1ea12d..4438d1ba023 100644
--- a/infra/route/core/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactory.java
+++ b/infra/route/core/src/main/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactory.java
@@ -33,8 +33,6 @@ import org.apache.shardingsphere.infra.route.engine.tableless.type.unicast.Table
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.LoadStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowDatabasesStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowTableStatusStatement;
@@ -69,6 +67,12 @@ public final class TablelessRouteEngineFactory {
*/
public static TablelessRouteEngine newInstance(final QueryContext queryContext, final ShardingSphereDatabase database) {
SQLStatement sqlStatement = queryContext.getSqlStatementContext().getSqlStatement();
+ if (sqlStatement instanceof DMLStatement) {
+ return getDMLRouteEngine(queryContext.getSqlStatementContext());
+ }
+ if (sqlStatement instanceof DDLStatement) {
+ return getDDLRouteEngine(queryContext.getSqlStatementContext(), database);
+ }
// TODO remove this logic when proxy and jdbc support all dal statement @duanzhengqiang
if (sqlStatement instanceof DALStatement) {
return getDALRouteEngine((DALStatement) sqlStatement, database, queryContext.getSqlStatementContext().getDatabaseType());
@@ -77,23 +81,12 @@ public final class TablelessRouteEngineFactory {
if (sqlStatement instanceof TCLStatement) {
return new TablelessDataSourceBroadcastRouteEngine();
}
- if (sqlStatement instanceof DDLStatement) {
- return getDDLRouteEngine(queryContext.getSqlStatementContext(), database);
- }
- if (sqlStatement instanceof DMLStatement) {
- return getDMLRouteEngine(queryContext.getSqlStatementContext());
- }
return new TablelessIgnoreRouteEngine();
}
- private static TablelessRouteEngine getDALRouteEngine(final DALStatement sqlStatement, final ShardingSphereDatabase database, final DatabaseType databaseType) {
- Optional<DialectTablelessBroadcastRouteDecider> dialectTablelessBroadcastRouteDecider = DatabaseTypedSPILoader.findService(DialectTablelessBroadcastRouteDecider.class, databaseType);
- if (sqlStatement instanceof ShowTablesStatement || sqlStatement instanceof ShowTableStatusStatement || sqlStatement instanceof SetStatement
- || sqlStatement instanceof ResetParameterStatement || sqlStatement instanceof ShowDatabasesStatement || sqlStatement instanceof LoadStatement) {
- return new TablelessDataSourceBroadcastRouteEngine();
- }
- if (dialectTablelessBroadcastRouteDecider.map(optional -> optional.isInstanceBroadcastRoute(sqlStatement)).orElse(false)) {
- return new TablelessInstanceBroadcastRouteEngine(database);
+ private static TablelessRouteEngine getDMLRouteEngine(final SQLStatementContext sqlStatementContext) {
+ if (sqlStatementContext instanceof SelectStatementContext) {
+ return new TablelessDataSourceUnicastRouteEngine();
}
return new TablelessIgnoreRouteEngine();
}
@@ -128,9 +121,17 @@ public final class TablelessRouteEngineFactory {
return new TablelessIgnoreRouteEngine();
}
- private static TablelessRouteEngine getDMLRouteEngine(final SQLStatementContext sqlStatementContext) {
- if (sqlStatementContext instanceof SelectStatementContext) {
- return new TablelessDataSourceUnicastRouteEngine();
+ private static TablelessRouteEngine getDALRouteEngine(final DALStatement sqlStatement, final ShardingSphereDatabase database, final DatabaseType databaseType) {
+ Optional<DialectTablelessBroadcastRouteDecider> dialectTablelessBroadcastRouteDecider = DatabaseTypedSPILoader.findService(DialectTablelessBroadcastRouteDecider.class, databaseType);
+ if (sqlStatement instanceof ShowTablesStatement || sqlStatement instanceof ShowTableStatusStatement || sqlStatement instanceof ShowDatabasesStatement
+ || sqlStatement instanceof SetStatement) {
+ return new TablelessDataSourceBroadcastRouteEngine();
+ }
+ if (dialectTablelessBroadcastRouteDecider.map(optional -> optional.isDataSourceBroadcastRoute(sqlStatement)).orElse(false)) {
+ return new TablelessDataSourceBroadcastRouteEngine();
+ }
+ if (dialectTablelessBroadcastRouteDecider.map(optional -> optional.isInstanceBroadcastRoute(sqlStatement)).orElse(false)) {
+ return new TablelessInstanceBroadcastRouteEngine(database);
}
return new TablelessIgnoreRouteEngine();
}
diff --git a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
index bf703e07f45..f211d550f23 100644
--- a/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
+++ b/infra/route/core/src/test/java/org/apache/shardingsphere/infra/route/engine/tableless/TablelessRouteEngineFactoryTest.java
@@ -109,7 +109,7 @@ class TablelessRouteEngineFactoryTest {
}
@Test
- void assertNewInstanceForDALSetForMySQL() {
+ void assertNewInstanceForSetStatement() {
SetStatement setStatement = mock(SetStatement.class);
when(sqlStatementContext.getSqlStatement()).thenReturn(setStatement);
QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
@@ -117,6 +117,18 @@ class TablelessRouteEngineFactoryTest {
assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
}
+ @Test
+ void assertNewInstanceForDataSourceBroadcastRoute() {
+ DALStatement sqlStatement = mock(DALStatement.class);
+ DialectTablelessBroadcastRouteDecider dialectTablelessBroadcastRouteDecider = mock(DialectTablelessBroadcastRouteDecider.class);
+ when(dialectTablelessBroadcastRouteDecider.isDataSourceBroadcastRoute(sqlStatement)).thenReturn(true);
+ when(DatabaseTypedSPILoader.findService(DialectTablelessBroadcastRouteDecider.class, databaseType)).thenReturn(Optional.of(dialectTablelessBroadcastRouteDecider));
+ when(sqlStatementContext.getSqlStatement()).thenReturn(sqlStatement);
+ QueryContext queryContext = new QueryContext(sqlStatementContext, "", Collections.emptyList(), new HintValueContext(), mockConnectionContext(), mock(ShardingSphereMetaData.class));
+ TablelessRouteEngine actual = TablelessRouteEngineFactory.newInstance(queryContext, database);
+ assertThat(actual, instanceOf(TablelessDataSourceBroadcastRouteEngine.class));
+ }
+
@Test
void assertNewInstanceForInstanceBroadcastRoute() {
DALStatement sqlStatement = mock(DALStatement.class);
diff --git a/infra/route/dialect/pom.xml b/infra/route/dialect/pom.xml
index cc4bdeab811..1d1f063c1af 100644
--- a/infra/route/dialect/pom.xml
+++ b/infra/route/dialect/pom.xml
@@ -28,6 +28,7 @@
<name>${project.artifactId}</name>
<modules>
+ <module>postgresql</module>
<module>mysql</module>
</modules>
</project>
diff --git a/jdbc-dialect/opengauss/pom.xml b/infra/route/dialect/postgresql/pom.xml
similarity index 82%
copy from jdbc-dialect/opengauss/pom.xml
copy to infra/route/dialect/postgresql/pom.xml
index f0f177184f4..e8ad3b594ff 100644
--- a/jdbc-dialect/opengauss/pom.xml
+++ b/infra/route/dialect/postgresql/pom.xml
@@ -20,24 +20,23 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-dialect</artifactId>
+ <artifactId>shardingsphere-infra-route-dialect</artifactId>
<version>5.5.3-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-jdbc-dialect-opengauss</artifactId>
+ <artifactId>shardingsphere-infra-route-postgresql</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-parser-sql-opengauss</artifactId>
+ <artifactId>shardingsphere-infra-route-core</artifactId>
<version>${project.version}</version>
- <scope>runtime</scope>
</dependency>
+
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-infra-binder-opengauss</artifactId>
+ <artifactId>shardingsphere-parser-sql-statement-postgresql</artifactId>
<version>${project.version}</version>
- <scope>runtime</scope>
</dependency>
</dependencies>
</project>
diff --git a/infra/route/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/route/postgresql/PostgreSQLTablelessBroadcastRouteDecider.java b/infra/route/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/route/postgresql/PostgreSQLTablelessBroadcastRouteDecider.java
new file mode 100644
index 00000000000..f7d52a96b08
--- /dev/null
+++ b/infra/route/dialect/postgresql/src/main/java/org/apache/shardingsphere/infra/route/postgresql/PostgreSQLTablelessBroadcastRouteDecider.java
@@ -0,0 +1,44 @@
+/*
+ * 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.infra.route.postgresql;
+
+import org.apache.shardingsphere.infra.route.engine.tableless.DialectTablelessBroadcastRouteDecider;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLLoadStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
+
+/**
+ * Dialect tableless broadcast route decider for PostgreSQL.
+ */
+public final class PostgreSQLTablelessBroadcastRouteDecider implements DialectTablelessBroadcastRouteDecider {
+
+ @Override
+ public boolean isDataSourceBroadcastRoute(final DALStatement sqlStatement) {
+ return sqlStatement instanceof PostgreSQLResetParameterStatement || sqlStatement instanceof PostgreSQLLoadStatement;
+ }
+
+ @Override
+ public boolean isInstanceBroadcastRoute(final DALStatement sqlStatement) {
+ return false;
+ }
+
+ @Override
+ public String getDatabaseType() {
+ return "PostgreSQL";
+ }
+}
diff --git a/infra/route/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.route.engine.tableless.DialectTablelessBroadcastRouteDecider b/infra/route/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.route.engine.tableless.DialectTablelessBroadcastRouteDecider
new file mode 100644
index 00000000000..4e8428cf3eb
--- /dev/null
+++ b/infra/route/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.route.engine.tableless.DialectTablelessBroadcastRouteDecider
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.infra.route.postgresql.PostgreSQLTablelessBroadcastRouteDecider
diff --git a/jdbc-dialect/mariadb/pom.xml b/jdbc-dialect/mariadb/pom.xml
index 6976ebce638..958d09934c4 100644
--- a/jdbc-dialect/mariadb/pom.xml
+++ b/jdbc-dialect/mariadb/pom.xml
@@ -45,5 +45,11 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-mysql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/jdbc-dialect/opengauss/pom.xml b/jdbc-dialect/opengauss/pom.xml
index f0f177184f4..79b0a10087f 100644
--- a/jdbc-dialect/opengauss/pom.xml
+++ b/jdbc-dialect/opengauss/pom.xml
@@ -39,5 +39,11 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-postgresql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/jdbc-dialect/postgresql/pom.xml b/jdbc-dialect/postgresql/pom.xml
index 9f14436a961..5816dd6c897 100644
--- a/jdbc-dialect/postgresql/pom.xml
+++ b/jdbc-dialect/postgresql/pom.xml
@@ -39,5 +39,11 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-postgresql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDALStatementVisitor.java b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDALStatementVisitor.java
index c37b61ea7e3..b529c7c8dbe 100644
--- a/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDALStatementVisitor.java
+++ b/parser/sql/dialect/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/opengauss/visitor/statement/type/OpenGaussDALStatementVisitor.java
@@ -42,8 +42,8 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatemen
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.AnalyzeTableStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.EmptyStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ExplainStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.LoadStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLLoadStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowStatement;
import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
@@ -108,7 +108,7 @@ public final class OpenGaussDALStatementVisitor extends OpenGaussStatementVisito
@Override
public ASTNode visitResetParameter(final ResetParameterContext ctx) {
- return new ResetParameterStatement(null != ctx.ALL() ? "ALL" : ctx.identifier().getText());
+ return new PostgreSQLResetParameterStatement(null != ctx.ALL() ? "ALL" : ctx.identifier().getText());
}
@SuppressWarnings("unchecked")
@@ -130,7 +130,7 @@ public final class OpenGaussDALStatementVisitor extends OpenGaussStatementVisito
@Override
public ASTNode visitLoad(final LoadContext ctx) {
- return new LoadStatement();
+ return new PostgreSQLLoadStatement();
}
@Override
diff --git a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDALStatementVisitor.java b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDALStatementVisitor.java
index 5876c2d8052..809ae064a38 100644
--- a/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDALStatementVisitor.java
+++ b/parser/sql/dialect/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/type/PostgreSQLDALStatementVisitor.java
@@ -42,8 +42,8 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatemen
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.AnalyzeTableStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.EmptyStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ExplainStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.LoadStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLLoadStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowStatement;
import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
@@ -113,7 +113,7 @@ public final class PostgreSQLDALStatementVisitor extends PostgreSQLStatementVisi
@Override
public ASTNode visitResetParameter(final ResetParameterContext ctx) {
- return new ResetParameterStatement(null != ctx.ALL() ? "ALL" : ctx.identifier().getText());
+ return new PostgreSQLResetParameterStatement(null != ctx.ALL() ? "ALL" : ctx.identifier().getText());
}
@SuppressWarnings("unchecked")
@@ -135,7 +135,7 @@ public final class PostgreSQLDALStatementVisitor extends PostgreSQLStatementVisi
@Override
public ASTNode visitLoad(final LoadContext ctx) {
- return new LoadStatement();
+ return new PostgreSQLLoadStatement();
}
@Override
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/LoadStatement.java b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLLoadStatement.java
similarity index 75%
rename from parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/LoadStatement.java
rename to parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLLoadStatement.java
index 3bce30754c9..c8e31498450 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/LoadStatement.java
+++ b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLLoadStatement.java
@@ -15,12 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.statement.core.statement.dal;
+package org.apache.shardingsphere.sql.parser.statement.postgresql.dal;
import org.apache.shardingsphere.sql.parser.statement.core.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
/**
- * Load statement.
+ * Load statement for PostgreSQL.
*/
-public final class LoadStatement extends AbstractSQLStatement implements DALStatement {
+public final class PostgreSQLLoadStatement extends AbstractSQLStatement implements DALStatement {
}
diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ResetParameterStatement.java b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLResetParameterStatement.java
similarity index 77%
rename from parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ResetParameterStatement.java
rename to parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLResetParameterStatement.java
index eac5383a994..b430c78ec59 100644
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/statement/dal/ResetParameterStatement.java
+++ b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/dal/PostgreSQLResetParameterStatement.java
@@ -15,18 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sql.parser.statement.core.statement.dal;
+package org.apache.shardingsphere.sql.parser.statement.postgresql.dal;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.core.statement.AbstractSQLStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.DALStatement;
/**
- * Reset parameter statement.
+ * Reset parameter statement for PostgreSQL.
*/
@RequiredArgsConstructor
@Getter
-public final class ResetParameterStatement extends AbstractSQLStatement implements DALStatement {
+public final class PostgreSQLResetParameterStatement extends AbstractSQLStatement implements DALStatement {
private final String configurationParameter;
}
diff --git a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
index c9861945ae1..ea2fa22323d 100644
--- a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
+++ b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreator.java
@@ -37,7 +37,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SubqueryTableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableSegment;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.SelectStatement;
@@ -85,8 +85,8 @@ public final class PostgreSQLAdminExecutorCreator implements DatabaseAdminExecut
if (sqlStatement instanceof SetStatement) {
return Optional.of(new PostgreSQLSetVariableAdminExecutor((SetStatement) sqlStatement));
}
- if (sqlStatement instanceof ResetParameterStatement) {
- return Optional.of(new PostgreSQLResetVariableAdminExecutor((ResetParameterStatement) sqlStatement));
+ if (sqlStatement instanceof PostgreSQLResetParameterStatement) {
+ return Optional.of(new PostgreSQLResetVariableAdminExecutor((PostgreSQLResetParameterStatement) sqlStatement));
}
return Optional.empty();
}
diff --git a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutor.java b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutor.java
index 795e57c23e8..41616b61388 100644
--- a/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutor.java
+++ b/proxy/backend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutor.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAd
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.variable.charset.CharsetSetExecutor;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.variable.session.SessionVariableRecordExecutor;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
/**
* Reset variable admin executor for PostgreSQL.
@@ -36,7 +36,7 @@ public final class PostgreSQLResetVariableAdminExecutor implements DatabaseAdmin
private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
- private final ResetParameterStatement resetParameterStatement;
+ private final PostgreSQLResetParameterStatement resetParameterStatement;
@Override
public void execute(final ConnectionSession connectionSession) {
diff --git a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
index 813930854d3..5f0eee6eb5c 100644
--- a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
+++ b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/PostgreSQLAdminExecutorCreatorTest.java
@@ -30,7 +30,7 @@ import org.apache.shardingsphere.proxy.backend.postgresql.handler.admin.executor
import org.apache.shardingsphere.proxy.backend.postgresql.handler.admin.executor.PostgreSQLShowVariableExecutor;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ShowStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dml.DeleteStatement;
@@ -156,7 +156,7 @@ class PostgreSQLAdminExecutorCreatorTest {
@Test
void assertCreateWithResetStatement() {
Optional<DatabaseAdminExecutor> actual = new PostgreSQLAdminExecutorCreator()
- .create(new UnknownSQLStatementContext(databaseType, new ResetParameterStatement("client_encoding")), "RESET client_encoding", "", Collections.emptyList());
+ .create(new UnknownSQLStatementContext(databaseType, new PostgreSQLResetParameterStatement("client_encoding")), "RESET client_encoding", "", Collections.emptyList());
assertTrue(actual.isPresent());
assertThat(actual.get(), instanceOf(PostgreSQLResetVariableAdminExecutor.class));
}
diff --git a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutorTest.java b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutorTest.java
index d1b96e29092..3c84053a747 100644
--- a/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutorTest.java
+++ b/proxy/backend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/admin/executor/PostgreSQLResetVariableAdminExecutorTest.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.proxy.backend.handler.admin.executor.variable.c
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.variable.session.ReplayedSessionVariableProvider;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.proxy.backend.session.RequiredSessionVariableRecorder;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
@@ -42,7 +42,7 @@ class PostgreSQLResetVariableAdminExecutorTest {
@Test
void assertExecute() {
- PostgreSQLResetVariableAdminExecutor executor = new PostgreSQLResetVariableAdminExecutor(new ResetParameterStatement("key"));
+ PostgreSQLResetVariableAdminExecutor executor = new PostgreSQLResetVariableAdminExecutor(new PostgreSQLResetParameterStatement("key"));
ConnectionSession connectionSession = mock(ConnectionSession.class, RETURNS_DEEP_STUBS);
RequiredSessionVariableRecorder requiredSessionVariableRecorder = mock(RequiredSessionVariableRecorder.class);
when(connectionSession.getRequiredSessionVariableRecorder()).thenReturn(requiredSessionVariableRecorder);
diff --git a/proxy/dialect/mariadb/pom.xml b/proxy/dialect/mariadb/pom.xml
index 8637764d9c7..b6a8dffa6c2 100644
--- a/proxy/dialect/mariadb/pom.xml
+++ b/proxy/dialect/mariadb/pom.xml
@@ -45,6 +45,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-mysql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-mysql-protocol</artifactId>
diff --git a/proxy/dialect/opengauss/pom.xml b/proxy/dialect/opengauss/pom.xml
index f9c3ed23a45..76452378dc9 100644
--- a/proxy/dialect/opengauss/pom.xml
+++ b/proxy/dialect/opengauss/pom.xml
@@ -39,6 +39,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-postgresql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-opengauss-protocol</artifactId>
diff --git a/proxy/dialect/postgresql/pom.xml b/proxy/dialect/postgresql/pom.xml
index e329073ba24..d82b2e9fd90 100644
--- a/proxy/dialect/postgresql/pom.xml
+++ b/proxy/dialect/postgresql/pom.xml
@@ -39,6 +39,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-route-postgresql</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-postgresql-protocol</artifactId>
diff --git a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
index d3206dcd72d..e3fb2b4a1f2 100644
--- a/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
+++ b/proxy/frontend/type/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommand.java
@@ -22,7 +22,7 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.AnalyzeTableStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterFunctionStatement;
@@ -125,7 +125,7 @@ public enum PostgreSQLCommand {
ROLLBACK(RollbackStatement.class),
RELEASE(ReleaseSavepointStatement.class),
SET(SetStatement.class, SetTransactionStatement.class),
- RESET(ResetParameterStatement.class),
+ RESET(PostgreSQLResetParameterStatement.class),
DECLARE_CURSOR(CursorStatement.class, DeclareStatement.class),
MOVE(MoveStatement.class),
CLOSE_CURSOR(CloseStatement.class),
diff --git a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
index 1040ed62643..7de019cecd8 100644
--- a/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
+++ b/proxy/frontend/type/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/PostgreSQLCommandTest.java
@@ -22,7 +22,7 @@ import org.apache.shardingsphere.distsql.statement.rdl.resource.unit.type.Regist
import org.apache.shardingsphere.sharding.distsql.statement.CreateShardingTableRuleStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.AnalyzeTableStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.SetStatement;
import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLVacuumStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterFunctionStatement;
@@ -315,7 +315,7 @@ class PostgreSQLCommandTest {
@Test
void assertValueOfResetStatement() {
- assertThat(PostgreSQLCommand.valueOf(ResetParameterStatement.class).orElse(null), is(PostgreSQLCommand.RESET));
+ assertThat(PostgreSQLCommand.valueOf(PostgreSQLResetParameterStatement.class).orElse(null), is(PostgreSQLCommand.RESET));
assertThat(PostgreSQLCommand.RESET.getTag(), is("RESET"));
}
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
index 261cf48fd0b..b10abe6bd67 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/DALStatementAssert.java
@@ -38,7 +38,7 @@ import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.KillSta
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.index.MySQLLoadIndexInfoStatement;
import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.OptimizeTableStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.table.MySQLRepairTableStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLResetPersistStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLResetStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.dal.MySQLRestartStatement;
@@ -224,8 +224,8 @@ public final class DALStatementAssert {
ShowStatementAssert.assertIs(assertContext, (ShowStatement) actual, (ShowStatementTestCase) expected);
} else if (actual instanceof SetStatement) {
SetParameterStatementAssert.assertIs(assertContext, (SetStatement) actual, (SetParameterStatementTestCase) expected);
- } else if (actual instanceof ResetParameterStatement) {
- ResetParameterStatementAssert.assertIs(assertContext, (ResetParameterStatement) actual, (ResetParameterStatementTestCase) expected);
+ } else if (actual instanceof PostgreSQLResetParameterStatement) {
+ ResetParameterStatementAssert.assertIs(assertContext, (PostgreSQLResetParameterStatement) actual, (ResetParameterStatementTestCase) expected);
} else if (actual instanceof MySQLInstallComponentStatement) {
InstallComponentStatementAssert.assertIs(assertContext, (MySQLInstallComponentStatement) actual, (InstallComponentStatementTestCase) expected);
} else if (actual instanceof FlushStatement) {
diff --git a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ResetParameterStatementAssert.java b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ResetParameterStatementAssert.java
index 81c96c6b63b..cba1ff729d6 100644
--- a/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ResetParameterStatementAssert.java
+++ b/test/it/parser/src/main/java/org/apache/shardingsphere/test/it/sql/parser/internal/asserts/statement/dal/impl/ResetParameterStatementAssert.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.dal.ResetParameterStatement;
+import org.apache.shardingsphere.sql.parser.statement.postgresql.dal.PostgreSQLResetParameterStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.dal.ResetParameterStatementTestCase;
@@ -39,7 +39,7 @@ public final class ResetParameterStatementAssert {
* @param actual actual reset parameter statement
* @param expected expected reset parameter statement test case
*/
- public static void assertIs(final SQLCaseAssertContext assertContext, final ResetParameterStatement actual, final ResetParameterStatementTestCase expected) {
+ public static void assertIs(final SQLCaseAssertContext assertContext, final PostgreSQLResetParameterStatement actual, final ResetParameterStatementTestCase expected) {
assertThat(assertContext.getText("Configuration parameter assertion error: "), actual.getConfigurationParameter(), is(expected.getConfigurationParameter()));
}
}