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 bc11440  Fix PostgreSQL Proxy CommandCompletion may be duplicate 
(#10267)
bc11440 is described below

commit bc11440eb61a8a4c7a7bfb7fb46234015a3d30c1
Author: 吴伟杰 <wuwei...@apache.org>
AuthorDate: Fri May 7 16:39:30 2021 +0800

    Fix PostgreSQL Proxy CommandCompletion may be duplicate (#10267)
---
 .../frontend/postgresql/command/PostgreSQLCommandExecuteEngine.java   | 4 +++-
 .../command/query/binary/bind/PostgreSQLComBindExecutor.java          | 4 +---
 .../postgresql/command/query/text/PostgreSQLComQueryExecutor.java     | 4 +---
 3 files changed, 5 insertions(+), 7 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 53e89e6..d3661c7 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
@@ -104,7 +104,9 @@ public final class PostgreSQLCommandExecuteEngine 
implements CommandExecuteEngin
                 count = 0;
             }
         }
-        context.write(new PostgreSQLCommandCompletePacket());
+        if (ResponseType.QUERY == queryCommandExecutor.getResponseType()) {
+            context.write(new PostgreSQLCommandCompletePacket());
+        }
         if (queryCommandExecutor instanceof PostgreSQLComQueryExecutor) {
             context.write(new PostgreSQLReadyForQueryPacket(true));
         }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
index e47af2b..d12baa9 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/binary/bind/PostgreSQLComBindExecutor.java
@@ -98,12 +98,10 @@ public final class PostgreSQLComBindExecutor implements 
QueryCommandExecutor {
     
     private Optional<PostgreSQLRowDescriptionPacket> createQueryPacket(final 
QueryResponseHeader queryResponseHeader) {
         Collection<PostgreSQLColumnDescription> columnDescriptions = 
createColumnDescriptions(queryResponseHeader);
-        if (columnDescriptions.isEmpty()) {
-            responseType = ResponseType.QUERY;
-        }
         if (columnDescriptions.isEmpty() || packet.isBinaryRowData()) {
             return Optional.empty();
         }
+        responseType = ResponseType.QUERY;
         return Optional.of(new 
PostgreSQLRowDescriptionPacket(columnDescriptions.size(), columnDescriptions));
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/text/PostgreSQLComQueryExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/text/PostgreSQLComQueryExecutor.java
index d85e0b5..0381af1 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/text/PostgreSQLComQueryExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/text/PostgreSQLComQueryExecutor.java
@@ -72,11 +72,9 @@ public final class PostgreSQLComQueryExecutor implements 
QueryCommandExecutor {
     private Optional<PostgreSQLRowDescriptionPacket> createQueryPacket(final 
QueryResponseHeader queryResponseHeader) {
         Collection<PostgreSQLColumnDescription> columnDescriptions = 
createColumnDescriptions(queryResponseHeader);
         if (columnDescriptions.isEmpty()) {
-            responseType = ResponseType.QUERY;
-        }
-        if (columnDescriptions.isEmpty()) {
             return Optional.empty();
         }
+        responseType = ResponseType.QUERY;
         return Optional.of(new 
PostgreSQLRowDescriptionPacket(columnDescriptions.size(), columnDescriptions));
     }
     

Reply via email to