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

zhangyonglun 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 6196580  Update MySQLComQueryPacketExecutor (#7502)
6196580 is described below

commit 6196580689b345bf4a652f0e6b874eac9933544f
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Sep 18 01:06:52 2020 +0800

    Update MySQLComQueryPacketExecutor (#7502)
---
 .../text/query/MySQLComQueryPacketExecutor.java    | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
index be8452a..89a1ad4 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutor.java
@@ -69,12 +69,12 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
             throw new CircuitBreakException();
         }
         BackendResponse backendResponse = textProtocolBackendHandler.execute();
-        if (backendResponse instanceof QueryResponse) {
-            responseType = ResponseType.QUERY;
-            return createQueryPackets((QueryResponse) backendResponse);
-        }
-        responseType = ResponseType.UPDATE;
-        return Collections.singletonList(createUpdatePacket((UpdateResponse) 
backendResponse));
+        return backendResponse instanceof QueryResponse ? 
processQuery((QueryResponse) backendResponse) : processUpdate((UpdateResponse) 
backendResponse);
+    }
+    
+    private Collection<DatabasePacket<?>> processQuery(final QueryResponse 
backendResponse) {
+        responseType = ResponseType.QUERY;
+        return createQueryPackets(backendResponse);
     }
     
     private Collection<DatabasePacket<?>> createQueryPackets(final 
QueryResponse backendResponse) {
@@ -88,7 +88,7 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
         result.add(new MySQLEofPacket(++currentSequenceId));
         return result;
     }
-
+    
     private int getColumnFieldDetailFlag(final QueryHeader header) {
         int result = 0;
         if (header.isPrimaryKey()) {
@@ -106,8 +106,13 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
         return result;
     }
     
-    private MySQLOKPacket createUpdatePacket(final UpdateResponse 
updateResponse) {
-        return new MySQLOKPacket(1, updateResponse.getUpdateCount(), 
updateResponse.getLastInsertId());
+    private Collection<DatabasePacket<?>> processUpdate(final UpdateResponse 
backendResponse) {
+        responseType = ResponseType.UPDATE;
+        return createUpdatePackets(backendResponse);
+    }
+    
+    private Collection<DatabasePacket<?>> createUpdatePackets(final 
UpdateResponse updateResponse) {
+        return Collections.singletonList(new MySQLOKPacket(1, 
updateResponse.getUpdateCount(), updateResponse.getLastInsertId()));
     }
     
     @Override

Reply via email to