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/05/29 17:40:14 UTC

(shardingsphere) branch master updated: Remove DialectSQLStatementCreator (#35559)

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 fe85ac5e8c5 Remove DialectSQLStatementCreator (#35559)
fe85ac5e8c5 is described below

commit fe85ac5e8c5af3d9dec2e8987aa87adfeeabc8f2
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Fri May 30 01:40:07 2025 +0800

    Remove DialectSQLStatementCreator (#35559)
    
    * Remove DialectSQLStatementCreator
    
    * Remove DialectSQLStatementCreator
---
 .../statement/core/DialectSQLStatementCreator.java | 36 ----------------------
 .../opengauss/OpenGaussStatementCreator.java       | 32 -------------------
 ...arser.statement.core.DialectSQLStatementCreator | 18 -----------
 .../postgresql/PostgreSQLStatementCreator.java     | 32 -------------------
 ...arser.statement.core.DialectSQLStatementCreator | 18 -----------
 .../backend/handler/tcl/TCLBackendHandler.java     | 13 ++------
 .../main/resources/case/plsql/create-procedure.xml |  8 ++---
 7 files changed, 7 insertions(+), 150 deletions(-)

diff --git a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/DialectSQLStatementCreator.java b/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/DialectSQLStatementCreator.java
deleted file mode 100644
index 75a9ceb1756..00000000000
--- a/parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/DialectSQLStatementCreator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.statement.core;
-
-import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPI;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.RollbackStatement;
-
-/**
- * Dialect SQL statement creator.
- */
-@SingletonSPI
-public interface DialectSQLStatementCreator extends DatabaseTypedSPI {
-    
-    /**
-     * Create rollback statement.
-     *
-     * @return created SQL statement
-     */
-    RollbackStatement createRollbackStatement();
-}
diff --git a/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/OpenGaussStatementCreator.java b/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/OpenGaussStatementCreator.java
deleted file mode 100644
index 2f458cb7740..00000000000
--- a/parser/sql/statement/type/opengauss/src/main/java/org/apache/shardingsphere/sql/parser/statement/opengauss/OpenGaussStatementCreator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.statement.opengauss;
-
-import org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.RollbackStatement;
-
-/**
- * Statement creator for openGauss.
- */
-public final class OpenGaussStatementCreator implements DialectSQLStatementCreator {
-    
-    @Override
-    public RollbackStatement createRollbackStatement() {
-        return new RollbackStatement();
-    }
-}
diff --git a/parser/sql/statement/type/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator b/parser/sql/statement/type/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator
deleted file mode 100644
index 7683cfc11a2..00000000000
--- a/parser/sql/statement/type/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.sql.parser.statement.opengauss.OpenGaussStatementCreator
diff --git a/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/PostgreSQLStatementCreator.java b/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/PostgreSQLStatementCreator.java
deleted file mode 100644
index f50415b4391..00000000000
--- a/parser/sql/statement/type/postgresql/src/main/java/org/apache/shardingsphere/sql/parser/statement/postgresql/PostgreSQLStatementCreator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.statement.postgresql;
-
-import org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.RollbackStatement;
-
-/**
- * Statement creator for PostgreSQL.
- */
-public final class PostgreSQLStatementCreator implements DialectSQLStatementCreator {
-    
-    @Override
-    public RollbackStatement createRollbackStatement() {
-        return new RollbackStatement();
-    }
-}
diff --git a/parser/sql/statement/type/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator b/parser/sql/statement/type/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator
deleted file mode 100644
index 3746c83f966..00000000000
--- a/parser/sql/statement/type/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.sql.parser.statement.postgresql.PostgreSQLStatementCreator
diff --git a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
index 918bb63551e..2ca001b4264 100644
--- a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
+++ b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TCLBackendHandler.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.proxy.backend.handler.tcl;
 
 import org.apache.shardingsphere.infra.database.core.metadata.database.metadata.DialectDatabaseMetaData;
-import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.exception.dialect.exception.transaction.InTransactionException;
@@ -28,7 +27,6 @@ import org.apache.shardingsphere.proxy.backend.handler.ProxyBackendHandler;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
 import org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.sql.parser.statement.core.DialectSQLStatementCreator;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.ReleaseSavepointStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.tcl.RollbackStatement;
@@ -39,7 +37,6 @@ import org.apache.shardingsphere.transaction.core.TransactionOperationType;
 
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
-import java.util.Optional;
 
 /**
  * TCL backend handler.
@@ -125,13 +122,9 @@ public final class TCLBackendHandler implements ProxyBackendHandler {
     }
     
     private SQLStatement getSQLStatementByCommit() {
-        if (connectionSession.getConnectionContext().getTransactionContext().isExceptionOccur() && dialectDatabaseMetaData.getTransactionOption().isReturnRollbackStatementWhenCommitFailed()) {
-            Optional<DialectSQLStatementCreator> statementCreator = DatabaseTypedSPILoader.findService(DialectSQLStatementCreator.class, connectionSession.getProtocolType());
-            if (statementCreator.isPresent()) {
-                return statementCreator.get().createRollbackStatement();
-            }
-        }
-        return tclStatement;
+        return connectionSession.getConnectionContext().getTransactionContext().isExceptionOccur() && dialectDatabaseMetaData.getTransactionOption().isReturnRollbackStatementWhenCommitFailed()
+                ? new RollbackStatement()
+                : tclStatement;
     }
     
     private void handleSetAutoCommit() throws SQLException {
diff --git a/test/it/parser/src/main/resources/case/plsql/create-procedure.xml b/test/it/parser/src/main/resources/case/plsql/create-procedure.xml
index ae25fb914ff..bd1461ed9af 100644
--- a/test/it/parser/src/main/resources/case/plsql/create-procedure.xml
+++ b/test/it/parser/src/main/resources/case/plsql/create-procedure.xml
@@ -23,8 +23,8 @@
             <sql-statement start-index="162" stop-index="187" statement-class-simple-name="OracleSavepointStatement" />
             <sql-statement start-index="205" stop-index="269" statement-class-simple-name="OracleSelectStatement" />
             <sql-statement start-index="1200" stop-index="1205" statement-class-simple-name="OracleCommitStatement" />
-            <sql-statement start-index="1246" stop-index="1288" statement-class-simple-name="OracleRollbackStatement" />
-            <sql-statement start-index="1403" stop-index="1445" statement-class-simple-name="OracleRollbackStatement" />
+            <sql-statement start-index="1246" stop-index="1288" statement-class-simple-name="RollbackStatement" />
+            <sql-statement start-index="1403" stop-index="1445" statement-class-simple-name="RollbackStatement" />
         </sql-statements>
         <procedure-calls>
             <procedure-call name="DBMS_OUTPUT.PUT_LINE" />
@@ -40,8 +40,8 @@
             <sql-statement start-index="162" stop-index="187" statement-class-simple-name="OracleSavepointStatement" />
             <sql-statement start-index="205" stop-index="269" statement-class-simple-name="OracleSelectStatement" />
             <sql-statement start-index="1200" stop-index="1205" statement-class-simple-name="OracleCommitStatement" />
-            <sql-statement start-index="1246" stop-index="1288" statement-class-simple-name="OracleRollbackStatement" />
-            <sql-statement start-index="1403" stop-index="1445" statement-class-simple-name="OracleRollbackStatement" />
+            <sql-statement start-index="1246" stop-index="1288" statement-class-simple-name="RollbackStatement" />
+            <sql-statement start-index="1403" stop-index="1445" statement-class-simple-name="RollbackStatement" />
         </sql-statements>
         <procedure-calls>
             <procedure-call name="DBMS_OUTPUT.PUT_LINE" />