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 ec6fe56b6c9 Use 
DialectTransactionOption.isReturnRollbackStatementWhenCommitFailed instead of 
TransactionalErrorAllowedSQLStatementHandler (#36783)
ec6fe56b6c9 is described below

commit ec6fe56b6c9c95c57e3280a23d9ed0de7f19bf88
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Oct 5 01:06:58 2025 +0800

    Use DialectTransactionOption.isReturnRollbackStatementWhenCommitFailed 
instead of TransactionalErrorAllowedSQLStatementHandler (#36783)
    
    * Use DialectTransactionOption.isReturnRollbackStatementWhenCommitFailed 
instead of TransactionalErrorAllowedSQLStatementHandler
    
    * Use DialectTransactionOption.isReturnRollbackStatementWhenCommitFailed 
instead of TransactionalErrorAllowedSQLStatementHandler
    
    * Use DialectTransactionOption.isReturnRollbackStatementWhenCommitFailed 
instead of TransactionalErrorAllowedSQLStatementHandler
---
 .../database/metadata/DialectDatabaseMetaData.java |  2 +-
 .../transaction/DialectTransactionOption.java      |  2 +
 .../database/FirebirdDatabaseMetaData.java         |  2 +-
 .../metadata/database/MySQLDatabaseMetaData.java   |  2 +-
 .../database/OpenGaussDatabaseMetaData.java        |  2 +-
 .../database/PostgreSQLDatabaseMetaData.java       |  2 +-
 .../handler/ProxyBackendHandlerFactory.java        | 21 +++++----
 ...ansactionalErrorAllowedSQLStatementHandler.java | 39 ----------------
 ...ansactionalErrorAllowedSQLStatementHandler.java | 44 ------------------
 ...cl.TransactionalErrorAllowedSQLStatementHandler | 18 --------
 ...ctionalErrorAllowedSQLStatementHandlerTest.java | 54 ----------------------
 ...ansactionalErrorAllowedSQLStatementHandler.java | 44 ------------------
 ...cl.TransactionalErrorAllowedSQLStatementHandler | 18 --------
 ...ctionalErrorAllowedSQLStatementHandlerTest.java | 54 ----------------------
 ...ansactionalErrorAllowedSQLStatementHandler.java | 44 ------------------
 ...cl.TransactionalErrorAllowedSQLStatementHandler | 18 --------
 ...ctionalErrorAllowedSQLStatementHandlerTest.java | 54 ----------------------
 17 files changed, 19 insertions(+), 401 deletions(-)

diff --git 
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
index 4aa2dc87be9..7e369b19aa1 100644
--- 
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
+++ 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/DialectDatabaseMetaData.java
@@ -127,7 +127,7 @@ public interface DialectDatabaseMetaData extends 
DatabaseTypedSPI {
      * @return transaction option
      */
     default DialectTransactionOption getTransactionOption() {
-        return new DialectTransactionOption(false, false, false, false, true, 
Connection.TRANSACTION_READ_COMMITTED, false);
+        return new DialectTransactionOption(false, false, false, false, true, 
Connection.TRANSACTION_READ_COMMITTED, false, false);
     }
     
     /**
diff --git 
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
index b410e94fdcd..e9172d17aff 100644
--- 
a/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
+++ 
b/database/connector/core/src/main/java/org/apache/shardingsphere/database/connector/core/metadata/database/metadata/option/transaction/DialectTransactionOption.java
@@ -41,4 +41,6 @@ public final class DialectTransactionOption {
     private final int defaultIsolationLevel;
     
     private final boolean isReturnRollbackStatementWhenCommitFailed;
+    
+    private final boolean isAllowCommitAndRollbackOnlyWhenTransactionFailed;
 }
diff --git 
a/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
 
b/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
index 1fc038b07f8..463ecd8ead5 100644
--- 
a/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
+++ 
b/database/connector/dialect/firebird/src/main/java/org/apache/shardingsphere/database/connector/firebird/metadata/database/FirebirdDatabaseMetaData.java
@@ -54,7 +54,7 @@ public final class FirebirdDatabaseMetaData implements 
DialectDatabaseMetaData {
     
     @Override
     public DialectTransactionOption getTransactionOption() {
-        return new DialectTransactionOption(false, true, false, false, true, 
Connection.TRANSACTION_READ_COMMITTED, false);
+        return new DialectTransactionOption(false, true, false, false, true, 
Connection.TRANSACTION_READ_COMMITTED, false, true);
     }
     
     @Override
diff --git 
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
 
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
index 658bf2203b6..8e3ad7e9194 100644
--- 
a/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
+++ 
b/database/connector/dialect/mysql/src/main/java/org/apache/shardingsphere/database/connector/mysql/metadata/database/MySQLDatabaseMetaData.java
@@ -68,7 +68,7 @@ public final class MySQLDatabaseMetaData implements 
DialectDatabaseMetaData {
     
     @Override
     public DialectTransactionOption getTransactionOption() {
-        return new DialectTransactionOption(false, false, true, false, true, 
Connection.TRANSACTION_REPEATABLE_READ, false);
+        return new DialectTransactionOption(false, false, true, false, true, 
Connection.TRANSACTION_REPEATABLE_READ, false, false);
     }
     
     @Override
diff --git 
a/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
 
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
index 220f7e27a39..37a04f8449f 100644
--- 
a/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
+++ 
b/database/connector/dialect/opengauss/src/main/java/org/apache/shardingsphere/database/connector/opengauss/metadata/database/OpenGaussDatabaseMetaData.java
@@ -75,7 +75,7 @@ public final class OpenGaussDatabaseMetaData implements 
DialectDatabaseMetaData
     
     @Override
     public DialectTransactionOption getTransactionOption() {
-        return new DialectTransactionOption(true, false, false, true, false, 
Connection.TRANSACTION_READ_COMMITTED, true);
+        return new DialectTransactionOption(true, false, false, true, false, 
Connection.TRANSACTION_READ_COMMITTED, true, true);
     }
     
     @Override
diff --git 
a/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
 
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
index 704edb9c392..0ea515ffe4a 100644
--- 
a/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
+++ 
b/database/connector/dialect/postgresql/src/main/java/org/apache/shardingsphere/database/connector/postgresql/metadata/database/PostgreSQLDatabaseMetaData.java
@@ -67,7 +67,7 @@ public final class PostgreSQLDatabaseMetaData implements 
DialectDatabaseMetaData
     
     @Override
     public DialectTransactionOption getTransactionOption() {
-        return new DialectTransactionOption(false, false, false, true, false, 
Connection.TRANSACTION_READ_COMMITTED, true);
+        return new DialectTransactionOption(false, false, false, true, false, 
Connection.TRANSACTION_READ_COMMITTED, true, true);
     }
     
     @Override
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
index 8d6d8548f41..6787283bac6 100644
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
+++ 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/ProxyBackendHandlerFactory.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.proxy.backend.handler;
 
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.database.connector.core.metadata.database.metadata.DialectDatabaseMetaData;
 import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
 import org.apache.shardingsphere.distsql.statement.DistSQLStatement;
@@ -34,6 +35,7 @@ import org.apache.shardingsphere.infra.hint.HintValueContext;
 import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.user.Grantee;
+import 
org.apache.shardingsphere.infra.session.connection.transaction.TransactionConnectionContext;
 import org.apache.shardingsphere.infra.session.query.QueryContext;
 import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
@@ -46,7 +48,6 @@ import 
org.apache.shardingsphere.proxy.backend.handler.database.DatabaseOperateB
 import 
org.apache.shardingsphere.proxy.backend.handler.distsql.DistSQLBackendHandlerFactory;
 import org.apache.shardingsphere.proxy.backend.handler.skip.SkipBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TCLBackendHandlerFactory;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.backend.state.DialectProxyStateSupportedSQLProvider;
 import org.apache.shardingsphere.proxy.backend.state.ProxyClusterStateChecker;
@@ -57,10 +58,13 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dcl.DC
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.CreateDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.database.DropDatabaseStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.table.RenameTableStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
 import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.TCLStatement;
 import org.apache.shardingsphere.transaction.util.AutoCommitUtils;
 
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -113,7 +117,7 @@ public final class ProxyBackendHandlerFactory {
         connectionSession.setQueryContext(queryContext);
         SQLStatementContext sqlStatementContext = 
queryContext.getSqlStatementContext();
         SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
-        allowExecutingWhenTransactionalError(databaseType, connectionSession, 
sqlStatement);
+        checkAllowedSQLStatementWhenTransactionFailed(databaseType, 
connectionSession.getConnectionContext().getTransactionContext(), sqlStatement);
         checkSupportedSQLStatement(databaseType, sqlStatement);
         checkClusterState(sqlStatement, databaseType);
         if (sqlStatement instanceof EmptyStatement) {
@@ -152,13 +156,12 @@ public final class ProxyBackendHandlerFactory {
                 .orElseGet(() -> 
DatabaseBackendHandlerFactory.newInstance(queryContext, connectionSession, 
preferPreparedStatement));
     }
     
-    private static void allowExecutingWhenTransactionalError(final 
DatabaseType databaseType, final ConnectionSession connectionSession, final 
SQLStatement sqlStatement) throws SQLException {
-        if 
(!connectionSession.getConnectionContext().getTransactionContext().isExceptionOccur())
 {
-            return;
-        }
-        Optional<TransactionalErrorAllowedSQLStatementHandler> 
allowedSQLStatementHandler = 
DatabaseTypedSPILoader.findService(TransactionalErrorAllowedSQLStatementHandler.class,
 databaseType);
-        if (allowedSQLStatementHandler.isPresent()) {
-            
allowedSQLStatementHandler.get().judgeContinueToExecute(sqlStatement);
+    private static void checkAllowedSQLStatementWhenTransactionFailed(final 
DatabaseType databaseType,
+                                                                      final 
TransactionConnectionContext transactionContext, final SQLStatement 
sqlStatement) throws SQLException {
+        if (transactionContext.isExceptionOccur()
+                && 
DatabaseTypedSPILoader.getService(DialectDatabaseMetaData.class, 
databaseType).getTransactionOption().isAllowCommitAndRollbackOnlyWhenTransactionFailed())
 {
+            ShardingSpherePreconditions.checkState(sqlStatement instanceof 
CommitStatement || sqlStatement instanceof RollbackStatement,
+                    () -> new SQLFeatureNotSupportedException("Current 
transaction is aborted, commands ignored until end of transaction block."));
         }
     }
     
diff --git 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TransactionalErrorAllowedSQLStatementHandler.java
 
b/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TransactionalErrorAllowedSQLStatementHandler.java
deleted file mode 100644
index f8778befe29..00000000000
--- 
a/proxy/backend/core/src/main/java/org/apache/shardingsphere/proxy/backend/handler/tcl/TransactionalErrorAllowedSQLStatementHandler.java
+++ /dev/null
@@ -1,39 +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.proxy.backend.handler.tcl;
-
-import org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPI;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-
-import java.sql.SQLException;
-
-/**
- * Transactional error allowed SQL statement handler.
- */
-@SingletonSPI
-public interface TransactionalErrorAllowedSQLStatementHandler extends 
DatabaseTypedSPI {
-    
-    /**
-     * Judge SQL statement can be executed continuously if exceptions occur 
during transactional SQL executing.
-     *
-     * @param sqlStatement SQL statement to be judged
-     * @throws SQLException SQL exception
-     */
-    void judgeContinueToExecute(SQLStatement sqlStatement) throws SQLException;
-}
diff --git 
a/proxy/backend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandler.java
 
b/proxy/backend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandler.java
deleted file mode 100644
index 194665c5ed3..00000000000
--- 
a/proxy/backend/dialect/firebird/src/main/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandler.java
+++ /dev/null
@@ -1,44 +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.proxy.backend.firebird.handler.transaction;
-
-import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-
-/**
- * Transactional error allowed SQL statement handler of Firebird.
- */
-public final class FirebirdTransactionalErrorAllowedSQLStatementHandler 
implements TransactionalErrorAllowedSQLStatementHandler {
-    
-    @Override
-    public void judgeContinueToExecute(final SQLStatement statement) throws 
SQLException {
-        ShardingSpherePreconditions.checkState(statement instanceof 
CommitStatement || statement instanceof RollbackStatement,
-                () -> new SQLFeatureNotSupportedException("Current transaction 
is aborted, commands ignored until end of transaction block."));
-    }
-    
-    @Override
-    public String getDatabaseType() {
-        return "Firebird";
-    }
-}
diff --git 
a/proxy/backend/dialect/firebird/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
 
b/proxy/backend/dialect/firebird/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
deleted file mode 100644
index 1ddec6c6713..00000000000
--- 
a/proxy/backend/dialect/firebird/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
+++ /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.proxy.backend.firebird.handler.transaction.FirebirdTransactionalErrorAllowedSQLStatementHandler
diff --git 
a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandlerTest.java
 
b/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandlerTest.java
deleted file mode 100644
index ad1260edcf9..00000000000
--- 
a/proxy/backend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/backend/firebird/handler/transaction/FirebirdTransactionalErrorAllowedSQLStatementHandlerTest.java
+++ /dev/null
@@ -1,54 +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.proxy.backend.firebird.handler.transaction;
-
-import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.SelectStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-import org.junit.jupiter.api.Test;
-
-import java.sql.SQLFeatureNotSupportedException;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-
-class FirebirdTransactionalErrorAllowedSQLStatementHandlerTest {
-    
-    private final TransactionalErrorAllowedSQLStatementHandler 
allowedSQLStatementHandler = DatabaseTypedSPILoader.getService(
-            TransactionalErrorAllowedSQLStatementHandler.class, 
TypedSPILoader.getService(DatabaseType.class, "Firebird"));
-    
-    @Test
-    void assertJudgeContinueToExecuteWithCommitStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(CommitStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithRollbackStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(RollbackStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithNotAllowedStatement() {
-        assertThrows(SQLFeatureNotSupportedException.class, () -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(SelectStatement.class)));
-    }
-}
diff --git 
a/proxy/backend/dialect/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandler.java
 
b/proxy/backend/dialect/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandler.java
deleted file mode 100644
index 3101c2b4e4a..00000000000
--- 
a/proxy/backend/dialect/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandler.java
+++ /dev/null
@@ -1,44 +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.proxy.backend.opengauss.handler.transaction;
-
-import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-
-/**
- * Transactional error allowed SQL statement handler of openGauss.
- */
-public final class OpenGaussTransactionalErrorAllowedSQLStatementHandler 
implements TransactionalErrorAllowedSQLStatementHandler {
-    
-    @Override
-    public void judgeContinueToExecute(final SQLStatement sqlStatement) throws 
SQLException {
-        ShardingSpherePreconditions.checkState(sqlStatement instanceof 
CommitStatement || sqlStatement instanceof RollbackStatement,
-                () -> new SQLFeatureNotSupportedException("Current transaction 
is aborted, commands ignored until end of transaction block."));
-    }
-    
-    @Override
-    public String getDatabaseType() {
-        return "openGauss";
-    }
-}
diff --git 
a/proxy/backend/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
 
b/proxy/backend/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
deleted file mode 100644
index 98686a7abfe..00000000000
--- 
a/proxy/backend/dialect/opengauss/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
+++ /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.proxy.backend.opengauss.handler.transaction.OpenGaussTransactionalErrorAllowedSQLStatementHandler
diff --git 
a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandlerTest.java
 
b/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandlerTest.java
deleted file mode 100644
index 4af81584141..00000000000
--- 
a/proxy/backend/dialect/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/transaction/OpenGaussTransactionalErrorAllowedSQLStatementHandlerTest.java
+++ /dev/null
@@ -1,54 +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.proxy.backend.opengauss.handler.transaction;
-
-import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.SelectStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-import org.junit.jupiter.api.Test;
-
-import java.sql.SQLFeatureNotSupportedException;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-
-class OpenGaussTransactionalErrorAllowedSQLStatementHandlerTest {
-    
-    private final TransactionalErrorAllowedSQLStatementHandler 
allowedSQLStatementHandler = DatabaseTypedSPILoader.getService(
-            TransactionalErrorAllowedSQLStatementHandler.class, 
TypedSPILoader.getService(DatabaseType.class, "openGauss"));
-    
-    @Test
-    void assertJudgeContinueToExecuteWithCommitStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(CommitStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithRollbackStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(RollbackStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithNotAllowedStatement() {
-        assertThrows(SQLFeatureNotSupportedException.class, () -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(SelectStatement.class)));
-    }
-}
diff --git 
a/proxy/backend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandler.java
 
b/proxy/backend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandler.java
deleted file mode 100644
index ad47d582f8f..00000000000
--- 
a/proxy/backend/dialect/postgresql/src/main/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandler.java
+++ /dev/null
@@ -1,44 +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.proxy.backend.postgresql.handler.transaction;
-
-import org.apache.shardingsphere.infra.exception.ShardingSpherePreconditions;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-
-/**
- * Transactional error allowed SQL statement handler of PostgreSQL.
- */
-public final class PostgreSQLTransactionalErrorAllowedSQLStatementHandler 
implements TransactionalErrorAllowedSQLStatementHandler {
-    
-    @Override
-    public void judgeContinueToExecute(final SQLStatement sqlStatement) throws 
SQLException {
-        ShardingSpherePreconditions.checkState(sqlStatement instanceof 
CommitStatement || sqlStatement instanceof RollbackStatement,
-                () -> new SQLFeatureNotSupportedException("Current transaction 
is aborted, commands ignored until end of transaction block."));
-    }
-    
-    @Override
-    public String getDatabaseType() {
-        return "PostgreSQL";
-    }
-}
diff --git 
a/proxy/backend/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
 
b/proxy/backend/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
deleted file mode 100644
index 5b973f6c5b9..00000000000
--- 
a/proxy/backend/dialect/postgresql/src/main/resources/META-INF/services/org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler
+++ /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.proxy.backend.postgresql.handler.transaction.PostgreSQLTransactionalErrorAllowedSQLStatementHandler
diff --git 
a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandlerTest.java
 
b/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandlerTest.java
deleted file mode 100644
index 8e745a4b714..00000000000
--- 
a/proxy/backend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/backend/postgresql/handler/transaction/PostgreSQLTransactionalErrorAllowedSQLStatementHandlerTest.java
+++ /dev/null
@@ -1,54 +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.proxy.backend.postgresql.handler.transaction;
-
-import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
-import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
-import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
-import 
org.apache.shardingsphere.proxy.backend.handler.tcl.TransactionalErrorAllowedSQLStatementHandler;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.SelectStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.CommitStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.type.tcl.RollbackStatement;
-import org.junit.jupiter.api.Test;
-
-import java.sql.SQLFeatureNotSupportedException;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-
-class PostgreSQLTransactionalErrorAllowedSQLStatementHandlerTest {
-    
-    private final TransactionalErrorAllowedSQLStatementHandler 
allowedSQLStatementHandler = DatabaseTypedSPILoader.getService(
-            TransactionalErrorAllowedSQLStatementHandler.class, 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL"));
-    
-    @Test
-    void assertJudgeContinueToExecuteWithCommitStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(CommitStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithRollbackStatement() {
-        assertDoesNotThrow(() -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(RollbackStatement.class)));
-    }
-    
-    @Test
-    void assertJudgeContinueToExecuteWithNotAllowedStatement() {
-        assertThrows(SQLFeatureNotSupportedException.class, () -> 
allowedSQLStatementHandler.judgeContinueToExecute(mock(SelectStatement.class)));
-    }
-}


Reply via email to