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

menghaoran 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 4f02c15  Force set in transaction for PG (#10170)
4f02c15 is described below

commit 4f02c1531d7ac7a24f6955e4284804793fa4f4cb
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Apr 24 15:56:58 2021 +0800

    Force set in transaction for PG (#10170)
---
 .../postgresql/command/PostgreSQLCommandExecuteEngine.java   | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
index 8fa1feb..354d319 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java
@@ -30,7 +30,6 @@ import 
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQ
 import 
org.apache.shardingsphere.db.protocol.postgresql.packet.generic.PostgreSQLReadyForQueryPacket;
 import 
org.apache.shardingsphere.db.protocol.postgresql.payload.PostgreSQLPacketPayload;
 import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.transaction.TransactionHolder;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.frontend.command.CommandExecuteEngine;
@@ -69,19 +68,22 @@ public final class PostgreSQLCommandExecuteEngine 
implements CommandExecuteEngin
     
     @Override
     public Optional<DatabasePacket<?>> getOtherPacket() {
-        return Optional.of(new 
PostgreSQLReadyForQueryPacket(TransactionHolder.isTransaction()));
+        // TODO judge is in transaction from context, not from 
TransactionHolder (because of thread local)
+        return Optional.of(new PostgreSQLReadyForQueryPacket(true));
     }
     
     @Override
     public void writeQueryData(final ChannelHandlerContext context,
                                final BackendConnection backendConnection, 
final QueryCommandExecutor queryCommandExecutor, final int headerPackagesCount) 
throws SQLException {
+        // TODO judge is in transaction from context, not from 
TransactionHolder (because of thread local)
+        boolean inTransaction = true;
         if (ResponseType.QUERY == queryCommandExecutor.getResponseType() && 
!context.channel().isActive()) {
             context.write(new PostgreSQLCommandCompletePacket());
-            context.write(new 
PostgreSQLReadyForQueryPacket(TransactionHolder.isTransaction()));
+            context.write(new PostgreSQLReadyForQueryPacket(inTransaction));
             return;
         }
         if (ResponseType.UPDATE == queryCommandExecutor.getResponseType()) {
-            context.write(new 
PostgreSQLReadyForQueryPacket(TransactionHolder.isTransaction()));
+            context.write(new PostgreSQLReadyForQueryPacket(inTransaction));
             return;
         }
         int count = 0;
@@ -100,6 +102,6 @@ public final class PostgreSQLCommandExecuteEngine 
implements CommandExecuteEngin
             }
         }
         context.write(new PostgreSQLCommandCompletePacket());
-        context.write(new 
PostgreSQLReadyForQueryPacket(TransactionHolder.isTransaction()));
+        context.write(new PostgreSQLReadyForQueryPacket(inTransaction));
     }
 }

Reply via email to