This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new a6449c22496 Remove JDBC not support operations across multiple logical 
databases in transaction (#28407)
a6449c22496 is described below

commit a6449c22496b1b8f918f84026e0db267e3b9b237
Author: ZhangCheng <[email protected]>
AuthorDate: Mon Sep 11 16:57:47 2023 +0800

    Remove JDBC not support operations across multiple logical databases in 
transaction (#28407)
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 -
 .../user-manual/error-code/sql-error-code.en.md    |  1 -
 .../core/statement/ShardingSphereStatement.java    | 18 ------------
 .../JDBCTransactionAcrossDatabasesException.java   | 33 ----------------------
 4 files changed, 53 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 7df4412ed7e..779f387141d 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -71,7 +71,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 25000     | 14000       | Switch transaction type failed, please terminate 
the current transaction.          |
 | 25000     | 14001       | Can not find transaction manager of \`%s\`.        
                                |
 | 25000     | 14002       | Transaction timeout should more than 0s.           
                                |
-| 25000     | 14100       | JDBC does not support operations across multiple 
logical databases in transaction. |
 | 25000     | 14200       | Can not start new XA transaction in a active 
transaction.                          |
 | 25000     | 14201       | Failed to create \`%s\` XA data source.            
                                |
 | 25000     | 14202       | Max length of xa unique resource name \`%s\` 
exceeded: should be less than 45.     |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 22aaf389820..bd7f6229a56 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -71,7 +71,6 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 25000     | 14000       | Switch transaction type failed, please terminate 
the current transaction.          |
 | 25000     | 14001       | Can not find transaction manager of \`%s\`.        
                                |
 | 25000     | 14002       | Transaction timeout should more than 0s.           
                                |
-| 25000     | 14100       | JDBC does not support operations across multiple 
logical databases in transaction. |
 | 25000     | 14200       | Can not start new XA transaction in a active 
transaction.                          |
 | 25000     | 14201       | Failed to create \`%s\` XA data source.            
                                |
 | 25000     | 14202       | Max length of xa unique resource name \`%s\` 
exceeded: should be less than 45.     |
diff --git 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
index 6fae3f4dcf6..69189f1b6ea 100644
--- 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
+++ 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java
@@ -31,13 +31,11 @@ import 
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConne
 import 
org.apache.shardingsphere.driver.jdbc.core.resultset.GeneratedKeysResultSet;
 import 
org.apache.shardingsphere.driver.jdbc.core.resultset.ShardingSphereResultSet;
 import 
org.apache.shardingsphere.driver.jdbc.exception.syntax.EmptySQLException;
-import 
org.apache.shardingsphere.driver.jdbc.exception.transaction.JDBCTransactionAcrossDatabasesException;
 import org.apache.shardingsphere.infra.binder.engine.SQLBindEngine;
 import 
org.apache.shardingsphere.infra.binder.context.segment.insert.keygen.GeneratedKeyContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
 import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
 import org.apache.shardingsphere.infra.connection.kernel.KernelProcessor;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
@@ -165,7 +163,6 @@ public final class ShardingSphereStatement extends 
AbstractStatementAdapter {
             QueryContext queryContext = createQueryContext(sql);
             databaseName = 
queryContext.getDatabaseNameFromSQLStatement().orElse(connection.getDatabaseName());
             
connection.getDatabaseConnectionManager().getConnectionContext().setCurrentDatabase(databaseName);
-            
checkSameDatabaseNameInTransaction(queryContext.getSqlStatementContext(), 
databaseName);
             trafficInstanceId = getInstanceIdAndSet(queryContext).orElse(null);
             if (null != trafficInstanceId) {
                 JDBCExecutionUnit executionUnit = 
createTrafficExecutionUnit(trafficInstanceId, queryContext);
@@ -315,7 +312,6 @@ public final class ShardingSphereStatement extends 
AbstractStatementAdapter {
         QueryContext queryContext = createQueryContext(sql);
         databaseName = 
queryContext.getDatabaseNameFromSQLStatement().orElse(connection.getDatabaseName());
         
connection.getDatabaseConnectionManager().getConnectionContext().setCurrentDatabase(databaseName);
-        
checkSameDatabaseNameInTransaction(queryContext.getSqlStatementContext(), 
databaseName);
         trafficInstanceId = getInstanceIdAndSet(queryContext).orElse(null);
         if (null != trafficInstanceId) {
             JDBCExecutionUnit executionUnit = 
createTrafficExecutionUnit(trafficInstanceId, queryContext);
@@ -434,7 +430,6 @@ public final class ShardingSphereStatement extends 
AbstractStatementAdapter {
             QueryContext queryContext = createQueryContext(sql);
             databaseName = 
queryContext.getDatabaseNameFromSQLStatement().orElse(connection.getDatabaseName());
             
connection.getDatabaseConnectionManager().getConnectionContext().setCurrentDatabase(databaseName);
-            
checkSameDatabaseNameInTransaction(queryContext.getSqlStatementContext(), 
databaseName);
             trafficInstanceId = getInstanceIdAndSet(queryContext).orElse(null);
             if (null != trafficInstanceId) {
                 JDBCExecutionUnit executionUnit = 
createTrafficExecutionUnit(trafficInstanceId, queryContext);
@@ -457,19 +452,6 @@ public final class ShardingSphereStatement extends 
AbstractStatementAdapter {
         }
     }
     
-    private void checkSameDatabaseNameInTransaction(final SQLStatementContext 
sqlStatementContext, final String connectionDatabaseName) {
-        if 
(!connection.getDatabaseConnectionManager().getConnectionContext().getTransactionContext().isInTransaction())
 {
-            return;
-        }
-        if (sqlStatementContext instanceof TableAvailable) {
-            ((TableAvailable) 
sqlStatementContext).getTablesContext().getDatabaseName().ifPresent(optional -> 
{
-                if (!optional.equals(connectionDatabaseName)) {
-                    throw new JDBCTransactionAcrossDatabasesException();
-                }
-            });
-        }
-    }
-    
     private JDBCExecutionUnit createTrafficExecutionUnit(final String 
trafficInstanceId, final QueryContext queryContext) throws SQLException {
         DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> 
prepareEngine = createDriverExecutionPrepareEngine();
         ExecutionUnit executionUnit = new ExecutionUnit(trafficInstanceId, new 
SQLUnit(queryContext.getSql(), queryContext.getParameters()));
diff --git 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
 
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
deleted file mode 100644
index 28138ac20a1..00000000000
--- 
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
+++ /dev/null
@@ -1,33 +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.driver.jdbc.exception.transaction;
-
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import 
org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.TransactionSQLException;
-
-/**
- * JDBC transaction across databases exception.
- */
-public final class JDBCTransactionAcrossDatabasesException extends 
TransactionSQLException {
-    
-    private static final long serialVersionUID = 3294968323117604702L;
-    
-    public JDBCTransactionAcrossDatabasesException() {
-        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 100, "JDBC does not 
support operations across multiple logical databases in transaction.");
-    }
-}

Reply via email to