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

panjuan 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 9531b2222fa Correct server status flags returned by MySQL Proxy 
(#18512)
9531b2222fa is described below

commit 9531b2222fa3b32c00570c13d339dd2327121890
Author: 吴伟杰 <[email protected]>
AuthorDate: Wed Jun 22 16:22:40 2022 +0800

    Correct server status flags returned by MySQL Proxy (#18512)
    
    * Correct server status flags returned by MySQL Proxy
    
    * Add ServerStatusFlagCalculatorTest
    
    * Remove redundant spaces in MySQLAuthenticationEngine
    
    * Correct server status flags in reactive MySQL
    
    * Complete MySQLComStmtResetExecutorTest
---
 .../mysql/packet/generic/MySQLEofPacket.java       |  5 +-
 .../mysql/packet/generic/MySQLOKPacket.java        | 11 ++--
 .../mysql/packet/generic/MySQLEofPacketTest.java   |  4 +-
 .../mysql/packet/generic/MySQLOKPacketTest.java    |  6 +--
 .../mysql/ingest/client/MySQLClientTest.java       |  6 +--
 .../client/netty/MySQLNegotiateHandlerTest.java    |  2 +-
 .../authentication/MySQLAuthenticationEngine.java  |  5 +-
 .../mysql/command/MySQLCommandExecuteEngine.java   |  2 +-
 .../mysql/command/MySQLCommandExecutorFactory.java |  4 +-
 .../mysql/command/ServerStatusFlagCalculator.java  | 40 ++++++++++++++
 .../command/admin/MySQLComSetOptionExecutor.java   |  3 +-
 .../admin/initdb/MySQLComInitDbExecutor.java       |  3 +-
 .../command/admin/ping/MySQLComPingExecutor.java   |  8 ++-
 .../command/admin/quit/MySQLComQuitExecutor.java   |  2 +-
 .../execute/MySQLComStmtExecuteExecutor.java       |  5 +-
 .../prepare/MySQLComStmtPrepareExecutor.java       | 14 ++---
 .../binary/reset/MySQLComStmtResetExecutor.java    |  6 ++-
 .../query/builder/ResponsePacketBuilder.java       | 12 +++--
 .../fieldlist/MySQLComFieldListPacketExecutor.java |  6 ++-
 .../text/query/MySQLComQueryPacketExecutor.java    | 10 ++--
 .../command/ServerStatusFlagCalculatorTest.java    | 61 ++++++++++++++++++++++
 .../reset/MySQLComStmtResetExecutorTest.java       | 12 ++---
 .../query/builder/ResponsePacketBuilderTest.java   |  4 +-
 .../ReactiveMySQLComStmtExecuteExecutor.java       |  7 +--
 .../ReactiveMySQLComFieldListPacketExecutor.java   |  6 ++-
 .../query/ReactiveMySQLComQueryPacketExecutor.java | 10 ++--
 26 files changed, 192 insertions(+), 62 deletions(-)

diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacket.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacket.java
index 5384cc85209..8dbf2686966 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacket.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacket.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.db.protocol.mysql.packet.generic;
 import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
 import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
 import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
 
@@ -44,8 +43,8 @@ public final class MySQLEofPacket implements MySQLPacket {
     
     private final int statusFlags;
     
-    public MySQLEofPacket(final int sequenceId) {
-        this(sequenceId, 0, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue());
+    public MySQLEofPacket(final int sequenceId, final int statusFlags) {
+        this(sequenceId, 0, statusFlags);
     }
     
     public MySQLEofPacket(final MySQLPacketPayload payload) {
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacket.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacket.java
index 20c4117f8b5..cfadd643872 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacket.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacket.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.db.protocol.mysql.packet.generic;
 import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
 import org.apache.shardingsphere.db.protocol.mysql.packet.MySQLPacket;
 import org.apache.shardingsphere.db.protocol.mysql.payload.MySQLPacketPayload;
 
@@ -38,8 +37,6 @@ public final class MySQLOKPacket implements MySQLPacket {
      */
     public static final int HEADER = 0x00;
     
-    private static final int DEFAULT_STATUS_FLAG = 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue();
-    
     private final int sequenceId;
     
     private final long affectedRows;
@@ -52,12 +49,12 @@ public final class MySQLOKPacket implements MySQLPacket {
     
     private final String info;
     
-    public MySQLOKPacket(final int sequenceId) {
-        this(sequenceId, 0L, 0L, DEFAULT_STATUS_FLAG, 0, "");
+    public MySQLOKPacket(final int sequenceId, final int statusFlag) {
+        this(sequenceId, 0L, 0L, statusFlag, 0, "");
     }
     
-    public MySQLOKPacket(final int sequenceId, final long affectedRows, final 
long lastInsertId) {
-        this(sequenceId, affectedRows, lastInsertId, DEFAULT_STATUS_FLAG, 0, 
"");
+    public MySQLOKPacket(final int sequenceId, final long affectedRows, final 
long lastInsertId, final int statusFlag) {
+        this(sequenceId, affectedRows, lastInsertId, statusFlag, 0, "");
     }
     
     public MySQLOKPacket(final MySQLPacketPayload payload) {
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacketTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacketTest.java
index 740cb22ef98..f9f08943250 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacketTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLEofPacketTest.java
@@ -37,7 +37,7 @@ public final class MySQLEofPacketTest {
     
     @Test
     public void assertNewEofPacketWithSequenceId() {
-        MySQLEofPacket actual = new MySQLEofPacket(1);
+        MySQLEofPacket actual = new MySQLEofPacket(1, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue());
         assertThat(actual.getSequenceId(), is(1));
         assertThat(actual.getWarnings(), is(0));
         assertThat(actual.getStatusFlags(), 
is(MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue()));
@@ -55,7 +55,7 @@ public final class MySQLEofPacketTest {
     
     @Test
     public void assertWrite() {
-        new MySQLEofPacket(1).write(payload);
+        new MySQLEofPacket(1, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue()).write(payload);
         verify(payload).writeInt1(MySQLEofPacket.HEADER);
         verify(payload).writeInt2(0);
         
verify(payload).writeInt2(MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue());
diff --git 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacketTest.java
 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacketTest.java
index 7917a628568..5a8ff302a44 100644
--- 
a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacketTest.java
+++ 
b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/generic/MySQLOKPacketTest.java
@@ -37,7 +37,7 @@ public final class MySQLOKPacketTest {
     
     @Test
     public void assertNewOKPacketWithSequenceId() {
-        MySQLOKPacket actual = new MySQLOKPacket(1);
+        MySQLOKPacket actual = new MySQLOKPacket(1, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue());
         assertThat(actual.getSequenceId(), is(1));
         assertThat(actual.getAffectedRows(), is(0L));
         assertThat(actual.getLastInsertId(), is(0L));
@@ -48,7 +48,7 @@ public final class MySQLOKPacketTest {
     
     @Test
     public void assertNewOKPacketWithAffectedRowsAndLastInsertId() {
-        MySQLOKPacket actual = new MySQLOKPacket(1, 100L, 9999L);
+        MySQLOKPacket actual = new MySQLOKPacket(1, 100L, 9999L, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue());
         assertThat(actual.getSequenceId(), is(1));
         assertThat(actual.getAffectedRows(), is(100L));
         assertThat(actual.getLastInsertId(), is(9999L));
@@ -74,7 +74,7 @@ public final class MySQLOKPacketTest {
     
     @Test
     public void assertWrite() {
-        new MySQLOKPacket(1, 100L, 9999L).write(packetPayload);
+        new MySQLOKPacket(1, 100L, 9999L, 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue()).write(packetPayload);
         verify(packetPayload).writeInt1(MySQLOKPacket.HEADER);
         verify(packetPayload).writeIntLenenc(100L);
         verify(packetPayload).writeIntLenenc(9999L);
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java
index bb539df5da1..b0826f54910 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/MySQLClientTest.java
@@ -70,7 +70,7 @@ public final class MySQLClientTest {
     
     @Test
     public void assertExecute() throws NoSuchFieldException, 
IllegalAccessException {
-        mockChannelResponse(new MySQLOKPacket(0));
+        mockChannelResponse(new MySQLOKPacket(0, 0));
         ReflectionUtil.setFieldValue(mysqlClient, "channel", channel);
         ReflectionUtil.setFieldValue(mysqlClient, "eventLoopGroup", new 
NioEventLoopGroup(1));
         assertTrue(mysqlClient.execute(""));
@@ -79,7 +79,7 @@ public final class MySQLClientTest {
     
     @Test
     public void assertExecuteUpdate() throws NoSuchFieldException, 
IllegalAccessException {
-        MySQLOKPacket expected = new MySQLOKPacket(0, 10, 0);
+        MySQLOKPacket expected = new MySQLOKPacket(0, 10, 0, 0);
         ReflectionUtil.setFieldValue(expected, "affectedRows", 10);
         mockChannelResponse(expected);
         ReflectionUtil.setFieldValue(mysqlClient, "channel", channel);
@@ -105,7 +105,7 @@ public final class MySQLClientTest {
         ReflectionUtil.setFieldValue(mysqlClient, "serverInfo", serverInfo);
         ReflectionUtil.setFieldValue(mysqlClient, "channel", channel);
         ReflectionUtil.setFieldValue(mysqlClient, "eventLoopGroup", new 
NioEventLoopGroup(1));
-        mockChannelResponse(new MySQLOKPacket(0));
+        mockChannelResponse(new MySQLOKPacket(0, 0));
         mysqlClient.subscribe("", 4L);
         
verify(channel).writeAndFlush(ArgumentMatchers.any(MySQLComRegisterSlaveCommandPacket.class));
         
verify(channel).writeAndFlush(ArgumentMatchers.any(MySQLComBinlogDumpCommandPacket.class));
diff --git 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
index 16129866d06..c3b7f756ae6 100644
--- 
a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
+++ 
b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/test/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/client/netty/MySQLNegotiateHandlerTest.java
@@ -86,7 +86,7 @@ public final class MySQLNegotiateHandlerTest {
     
     @Test
     public void assertChannelReadOkPacket() throws NoSuchFieldException, 
IllegalAccessException {
-        MySQLOKPacket okPacket = new MySQLOKPacket(0);
+        MySQLOKPacket okPacket = new MySQLOKPacket(0, 0);
         ServerInfo serverInfo = new ServerInfo();
         ReflectionUtil.setFieldValue(mysqlNegotiateHandler, "serverInfo", 
serverInfo);
         mysqlNegotiateHandler.channelRead(channelHandlerContext, okPacket);
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
index 4b0a362893c..0ec0494b7d2 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationEngine.java
@@ -25,6 +25,7 @@ import 
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLCharacterSet;
 import 
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConnectionPhase;
 import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLConstants;
 import 
org.apache.shardingsphere.db.protocol.mysql.constant.MySQLServerErrorCode;
+import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.MySQLPreparedStatementRegistry;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLErrPacket;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
@@ -50,6 +51,8 @@ import java.util.Optional;
  */
 public final class MySQLAuthenticationEngine implements AuthenticationEngine {
     
+    private static final int DEFAULT_STATUS_FLAG = 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue();
+    
     private final MySQLAuthenticationHandler authenticationHandler = new 
MySQLAuthenticationHandler();
     
     private MySQLConnectionPhase connectionPhase = 
MySQLConnectionPhase.INITIAL_HANDSHAKE;
@@ -80,7 +83,7 @@ public final class MySQLAuthenticationEngine implements 
AuthenticationEngine {
             authenticationMethodMismatch((MySQLPacketPayload) payload);
         }
         Optional<MySQLServerErrorCode> errorCode = 
authenticationHandler.login(currentAuthResult.getUsername(), 
getHostAddress(context), authResponse, currentAuthResult.getDatabase());
-        context.writeAndFlush(errorCode.isPresent() ? 
createErrorPacket(errorCode.get(), context) : new MySQLOKPacket(++sequenceId));
+        context.writeAndFlush(errorCode.isPresent() ? 
createErrorPacket(errorCode.get(), context) : new MySQLOKPacket(++sequenceId, 
DEFAULT_STATUS_FLAG));
         return 
AuthenticationResultBuilder.finished(currentAuthResult.getUsername(), 
getHostAddress(context), currentAuthResult.getDatabase());
     }
     
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
index ee3ceb7cf5c..5721171c8a5 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecuteEngine.java
@@ -94,6 +94,6 @@ public final class MySQLCommandExecuteEngine implements 
CommandExecuteEngine {
             }
             currentSequenceId++;
         }
-        context.write(new MySQLEofPacket(++currentSequenceId + 
headerPackagesCount));
+        context.write(new MySQLEofPacket(++currentSequenceId + 
headerPackagesCount, 
ServerStatusFlagCalculator.calculateFor(backendConnection.getConnectionSession())));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
index 856a4a31afa..70e296d8a0c 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/MySQLCommandExecutorFactory.java
@@ -74,13 +74,13 @@ public final class MySQLCommandExecutorFactory {
             case COM_QUERY:
                 return new MySQLComQueryPacketExecutor((MySQLComQueryPacket) 
commandPacket, connectionSession);
             case COM_PING:
-                return new MySQLComPingExecutor();
+                return new MySQLComPingExecutor(connectionSession);
             case COM_STMT_PREPARE:
                 return new 
MySQLComStmtPrepareExecutor((MySQLComStmtPreparePacket) commandPacket, 
connectionSession);
             case COM_STMT_EXECUTE:
                 return new 
MySQLComStmtExecuteExecutor((MySQLComStmtExecutePacket) commandPacket, 
connectionSession);
             case COM_STMT_RESET:
-                return new MySQLComStmtResetExecutor((MySQLComStmtResetPacket) 
commandPacket);
+                return new MySQLComStmtResetExecutor((MySQLComStmtResetPacket) 
commandPacket, connectionSession);
             case COM_STMT_CLOSE:
                 return new MySQLComStmtCloseExecutor((MySQLComStmtClosePacket) 
commandPacket, connectionSession.getConnectionId());
             case COM_SET_OPTION:
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculator.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculator.java
new file mode 100644
index 00000000000..45b6eba9ae6
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculator.java
@@ -0,0 +1,40 @@
+/*
+ * 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.frontend.mysql.command;
+
+import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+
+/**
+ * MySQL server status flag calculator.
+ */
+public final class ServerStatusFlagCalculator {
+    
+    /**
+     * Calculate server status flag for specified connection.
+     *
+     * @param connectionSession connection session
+     * @return server status flag
+     */
+    public static int calculateFor(final ConnectionSession connectionSession) {
+        int result = 0;
+        result |= connectionSession.isAutoCommit() ? 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue() : 0;
+        result |= connectionSession.getTransactionStatus().isInTransaction() ? 
MySQLStatusFlag.SERVER_STATUS_IN_TRANS.getValue() : 0;
+        return result;
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutor.java
index 2220f92c12d..5fe8cf9404b 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/MySQLComSetOptionExecutor.java
@@ -24,6 +24,7 @@ import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 
 import java.sql.SQLException;
 import java.util.Collection;
@@ -42,6 +43,6 @@ public final class MySQLComSetOptionExecutor implements 
CommandExecutor {
     @Override
     public Collection<DatabasePacket<?>> execute() throws SQLException {
         
connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_OPTION_MULTI_STATEMENTS).set(packet.getValue());
-        return Collections.singletonList(new MySQLOKPacket(1));
+        return Collections.singletonList(new MySQLOKPacket(1, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
index 0e15245d072..71b0e0e1dd1 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/initdb/MySQLComInitDbExecutor.java
@@ -27,6 +27,7 @@ import 
org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import 
org.apache.shardingsphere.proxy.backend.exception.UnknownDatabaseException;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtil;
 
 import java.util.Collection;
@@ -48,7 +49,7 @@ public final class MySQLComInitDbExecutor implements 
CommandExecutor {
         String databaseName = SQLUtil.getExactlyValue(packet.getSchema());
         if (ProxyContext.getInstance().databaseExists(databaseName) && 
SQLCheckEngine.check(databaseName, getRules(databaseName), 
connectionSession.getGrantee())) {
             connectionSession.setCurrentDatabase(packet.getSchema());
-            return Collections.singletonList(new MySQLOKPacket(1));
+            return Collections.singletonList(new MySQLOKPacket(1, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
         }
         throw new UnknownDatabaseException(packet.getSchema());
     }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/ping/MySQLComPingExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/ping/MySQLComPingExecutor.java
index 181607e602f..94733519681 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/ping/MySQLComPingExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/ping/MySQLComPingExecutor.java
@@ -17,9 +17,12 @@
 
 package org.apache.shardingsphere.proxy.frontend.mysql.command.admin.ping;
 
+import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -27,10 +30,13 @@ import java.util.Collections;
 /**
  * COM_PING executor for MySQL.
  */
+@RequiredArgsConstructor
 public final class MySQLComPingExecutor implements CommandExecutor {
     
+    private final ConnectionSession connectionSession;
+    
     @Override
     public Collection<DatabasePacket<?>> execute() {
-        return Collections.singletonList(new MySQLOKPacket(1));
+        return Collections.singletonList(new MySQLOKPacket(1, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/quit/MySQLComQuitExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/quit/MySQLComQuitExecutor.java
index b7d5db2e4db..838c84fb0ec 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/quit/MySQLComQuitExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/admin/quit/MySQLComQuitExecutor.java
@@ -31,6 +31,6 @@ public final class MySQLComQuitExecutor implements 
CommandExecutor {
     
     @Override
     public Collection<DatabasePacket<?>> execute() {
-        return Collections.singletonList(new MySQLOKPacket(1));
+        return Collections.singletonList(new MySQLOKPacket(1, 0));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
index 1646b743c95..bd867db3ebe 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/execute/MySQLComStmtExecuteExecutor.java
@@ -52,6 +52,7 @@ import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
 import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
@@ -131,14 +132,14 @@ public final class MySQLComStmtExecuteExecutor implements 
QueryCommandExecutor {
     
     private Collection<DatabasePacket<?>> processQuery(final 
QueryResponseHeader queryResponseHeader, final int characterSet) {
         responseType = ResponseType.QUERY;
-        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet);
+        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
         currentSequenceId = result.size();
         return result;
     }
     
     private Collection<DatabasePacket<?>> processUpdate(final 
UpdateResponseHeader updateResponseHeader) {
         responseType = ResponseType.UPDATE;
-        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader);
+        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 
ServerStatusFlagCalculator.calculateFor(connectionSession));
     }
     
     @Override
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
index d13f325eda1..15cf078b362 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutor.java
@@ -37,6 +37,7 @@ import 
org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
 import 
org.apache.shardingsphere.proxy.frontend.exception.UnsupportedPreparedStatementException;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
 
@@ -96,30 +97,31 @@ public final class MySQLComStmtPrepareExecutor implements 
CommandExecutor {
         Collection<DatabasePacket<?>> result = new LinkedList<>();
         result.add(new MySQLComStmtPrepareOKPacket(++currentSequenceId, 
statementId, projectionCount, parameterCount, 0));
         int characterSet = 
connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
+        int statusFlags = 
ServerStatusFlagCalculator.calculateFor(connectionSession);
         if (parameterCount > 0) {
-            
result.addAll(createParameterColumnDefinition41Packets(parameterCount, 
characterSet));
+            
result.addAll(createParameterColumnDefinition41Packets(parameterCount, 
characterSet, statusFlags));
         }
         if (projectionCount > 0) {
-            
result.addAll(createProjectionColumnDefinition41Packets(projectionCount, 
characterSet));
+            
result.addAll(createProjectionColumnDefinition41Packets(projectionCount, 
characterSet, statusFlags));
         }
         return result;
     }
     
-    private Collection<DatabasePacket<?>> 
createParameterColumnDefinition41Packets(final int parameterCount, final int 
characterSet) {
+    private Collection<DatabasePacket<?>> 
createParameterColumnDefinition41Packets(final int parameterCount, final int 
characterSet, final int statusFlags) {
         Collection<DatabasePacket<?>> result = new LinkedList<>();
         for (int i = 0; i < parameterCount; i++) {
             result.add(new MySQLColumnDefinition41Packet(++currentSequenceId, 
characterSet, "", "", "", "?", "", 0, 
MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING, 0, false));
         }
-        result.add(new MySQLEofPacket(++currentSequenceId));
+        result.add(new MySQLEofPacket(++currentSequenceId, statusFlags));
         return result;
     }
     
-    private Collection<DatabasePacket<?>> 
createProjectionColumnDefinition41Packets(final int projectionCount, final int 
characterSet) {
+    private Collection<DatabasePacket<?>> 
createProjectionColumnDefinition41Packets(final int projectionCount, final int 
characterSet, final int statusFlags) {
         Collection<DatabasePacket<?>> result = new LinkedList<>();
         for (int i = 0; i < projectionCount; i++) {
             result.add(new MySQLColumnDefinition41Packet(++currentSequenceId, 
characterSet, "", "", "", "", "", 0, 
MySQLBinaryColumnType.MYSQL_TYPE_VAR_STRING, 0, false));
         }
-        result.add(new MySQLEofPacket(++currentSequenceId));
+        result.add(new MySQLEofPacket(++currentSequenceId, statusFlags));
         return result;
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutor.java
index c2256904239..17e74c05acc 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutor.java
@@ -21,7 +21,9 @@ import lombok.RequiredArgsConstructor;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.reset.MySQLComStmtResetPacket;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -34,9 +36,11 @@ public final class MySQLComStmtResetExecutor implements 
CommandExecutor {
     
     private final MySQLComStmtResetPacket packet;
     
+    private final ConnectionSession connectionSession;
+    
     @Override
     public Collection<DatabasePacket<?>> execute() {
         // TODO we should implement the stmt reset after supporting 
COM_STMT_SEND_LONG_DATA
-        return Collections.singleton(new MySQLOKPacket(1));
+        return Collections.singleton(new MySQLOKPacket(1, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
index 87105703444..b79efe08239 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilder.java
@@ -46,9 +46,10 @@ public final class ResponsePacketBuilder {
      * 
      * @param queryResponseHeader query response header
      * @param characterSet MySQL character set id
+     * @param statusFlags server status flags
      * @return query response packets
      */
-    public static Collection<DatabasePacket<?>> 
buildQueryResponsePackets(final QueryResponseHeader queryResponseHeader, final 
int characterSet) {
+    public static Collection<DatabasePacket<?>> 
buildQueryResponsePackets(final QueryResponseHeader queryResponseHeader, final 
int characterSet, final int statusFlags) {
         Collection<DatabasePacket<?>> result = new LinkedList<>();
         int sequenceId = 0;
         List<QueryHeader> queryHeaders = queryResponseHeader.getQueryHeaders();
@@ -57,7 +58,7 @@ public final class ResponsePacketBuilder {
             result.add(new MySQLColumnDefinition41Packet(++sequenceId, 
characterSet, getColumnFieldDetailFlag(each), each.getSchema(), 
each.getTable(), each.getTable(),
                     each.getColumnLabel(), each.getColumnName(), 
each.getColumnLength(), 
MySQLBinaryColumnType.valueOfJDBCType(each.getColumnType()), 
each.getDecimals(), false));
         }
-        result.add(new MySQLEofPacket(++sequenceId));
+        result.add(new MySQLEofPacket(++sequenceId, statusFlags));
         return result;
     }
     
@@ -80,11 +81,12 @@ public final class ResponsePacketBuilder {
     
     /**
      * Build update response packets.
-     * 
+     *
      * @param updateResponseHeader update response header
+     * @param serverStatusFlag server status flag
      * @return update response packets
      */
-    public static Collection<DatabasePacket<?>> 
buildUpdateResponsePackets(final UpdateResponseHeader updateResponseHeader) {
-        return Collections.singletonList(new MySQLOKPacket(1, 
updateResponseHeader.getUpdateCount(), updateResponseHeader.getLastInsertId()));
+    public static Collection<DatabasePacket<?>> 
buildUpdateResponsePackets(final UpdateResponseHeader updateResponseHeader, 
final int serverStatusFlag) {
+        return Collections.singletonList(new MySQLOKPacket(1, 
updateResponseHeader.getUpdateCount(), updateResponseHeader.getLastInsertId(), 
serverStatusFlag));
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
index 18f86743f4c..e232dedd8ba 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/fieldlist/MySQLComFieldListPacketExecutor.java
@@ -34,6 +34,7 @@ import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.JDB
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.CommandExecutor;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 import java.sql.SQLException;
@@ -49,6 +50,8 @@ public final class MySQLComFieldListPacketExecutor implements 
CommandExecutor {
     
     private final MySQLComFieldListPacket packet;
     
+    private final ConnectionSession connectionSession;
+    
     private final String databaseName;
     
     private final JDBCDatabaseCommunicationEngine databaseCommunicationEngine;
@@ -59,6 +62,7 @@ public final class MySQLComFieldListPacketExecutor implements 
CommandExecutor {
     
     public MySQLComFieldListPacketExecutor(final MySQLComFieldListPacket 
packet, final ConnectionSession connectionSession) {
         this.packet = packet;
+        this.connectionSession = connectionSession;
         databaseName = connectionSession.getDefaultDatabaseName();
         String sql = String.format(SQL, packet.getTable(), databaseName);
         MetaDataContexts metaDataContexts = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts();
@@ -84,7 +88,7 @@ public final class MySQLComFieldListPacketExecutor implements 
CommandExecutor {
             result.add(new MySQLColumnDefinition41Packet(
                     ++currentSequenceId, characterSet, databaseName, 
packet.getTable(), packet.getTable(), columnName, columnName, 100, 
MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR, 0, true));
         }
-        result.add(new MySQLEofPacket(++currentSequenceId));
+        result.add(new MySQLEofPacket(++currentSequenceId, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
         return result;
     }
     
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 b07c15905e2..23507c3a6bc 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
@@ -41,6 +41,7 @@ import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.frontend.command.executor.QueryCommandExecutor;
 import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
@@ -57,6 +58,8 @@ import java.util.Optional;
  */
 public final class MySQLComQueryPacketExecutor implements QueryCommandExecutor 
{
     
+    private final ConnectionSession connectionSession;
+    
     private final TextProtocolBackendHandler textProtocolBackendHandler;
     
     private final int characterSet;
@@ -67,6 +70,7 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
     private int currentSequenceId;
     
     public MySQLComQueryPacketExecutor(final MySQLComQueryPacket packet, final 
ConnectionSession connectionSession) throws SQLException {
+        this.connectionSession = connectionSession;
         DatabaseType databaseType = DatabaseTypeFactory.getInstance("MySQL");
         SQLStatement sqlStatement = parseSql(packet.getSql(), databaseType);
         textProtocolBackendHandler = areMultiStatements(connectionSession, 
sqlStatement, packet.getSql()) ? new 
MySQLMultiStatementsHandler(connectionSession, sqlStatement, packet.getSql())
@@ -102,19 +106,19 @@ public final class MySQLComQueryPacketExecutor implements 
QueryCommandExecutor {
     
     private Collection<DatabasePacket<?>> processQuery(final 
QueryResponseHeader queryResponseHeader) {
         responseType = ResponseType.QUERY;
-        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet);
+        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
         currentSequenceId = result.size();
         return result;
     }
     
     private Collection<DatabasePacket<?>> processUpdate(final 
UpdateResponseHeader updateResponseHeader) {
-        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader);
+        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 
ServerStatusFlagCalculator.calculateFor(connectionSession));
     }
     
     private Collection<DatabasePacket<?>> processClientEncoding(final 
ClientEncodingResponseHeader clientEncodingResponseHeader) {
         Optional<String> currentCharsetValue = 
clientEncodingResponseHeader.getCurrentCharsetValue();
         if (currentCharsetValue.isPresent()) {
-            return Collections.singletonList(new MySQLOKPacket(1, 0, 0));
+            return Collections.singletonList(new MySQLOKPacket(1, 0, 0, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
         }
         return Collections.singletonList(new MySQLErrPacket(1, 
MySQLServerErrorCode.ER_UNKNOWN_CHARACTER_SET, 
clientEncodingResponseHeader.getInputValue()));
     }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculatorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculatorTest.java
new file mode 100644
index 00000000000..9c1819b2585
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/ServerStatusFlagCalculatorTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.frontend.mysql.command;
+
+import org.apache.shardingsphere.db.protocol.mysql.constant.MySQLStatusFlag;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class ServerStatusFlagCalculatorTest {
+    
+    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+    private ConnectionSession connectionSession;
+    
+    @Test
+    public void assertAutoCommitNotInTransaction() {
+        when(connectionSession.isAutoCommit()).thenReturn(true);
+        assertThat(ServerStatusFlagCalculator.calculateFor(connectionSession), 
is(MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue()));
+    }
+    
+    @Test
+    public void assertAutoCommitInTransaction() {
+        when(connectionSession.isAutoCommit()).thenReturn(true);
+        
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true);
+        assertThat(ServerStatusFlagCalculator.calculateFor(connectionSession), 
is(MySQLStatusFlag.SERVER_STATUS_IN_TRANS.getValue() | 
MySQLStatusFlag.SERVER_STATUS_AUTOCOMMIT.getValue()));
+    }
+    
+    @Test
+    public void assertNotAutoCommitNotInTransaction() {
+        assertThat(ServerStatusFlagCalculator.calculateFor(connectionSession), 
is(0));
+    }
+    
+    @Test
+    public void assertNotAutoCommitInTransaction() {
+        
when(connectionSession.getTransactionStatus().isInTransaction()).thenReturn(true);
+        assertThat(ServerStatusFlagCalculator.calculateFor(connectionSession), 
is(MySQLStatusFlag.SERVER_STATUS_IN_TRANS.getValue()));
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
index 9b0c0b84928..fea92c17c96 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/reset/MySQLComStmtResetExecutorTest.java
@@ -20,26 +20,22 @@ package 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.binary.rese
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.command.query.binary.reset.MySQLComStmtResetPacket;
 import 
org.apache.shardingsphere.db.protocol.mysql.packet.generic.MySQLOKPacket;
 import org.apache.shardingsphere.db.protocol.packet.DatabasePacket;
+import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
 
 import java.util.Collection;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
 
-@RunWith(MockitoJUnitRunner.class)
 public final class MySQLComStmtResetExecutorTest {
     
-    @Mock
-    private MySQLComStmtResetPacket packet;
-    
     @Test
     public void assertExecute() {
-        MySQLComStmtResetExecutor mysqlComStmtResetExecutor = new 
MySQLComStmtResetExecutor(packet);
+        MySQLComStmtResetExecutor mysqlComStmtResetExecutor = new 
MySQLComStmtResetExecutor(mock(MySQLComStmtResetPacket.class), 
mock(ConnectionSession.class, RETURNS_DEEP_STUBS));
         Collection<DatabasePacket<?>> actual = 
mysqlComStmtResetExecutor.execute();
         assertThat(actual.size(), is(1));
         assertThat(actual.iterator().next(), instanceOf(MySQLOKPacket.class));
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
index 9d1fe7ea640..befcf9a9608 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/builder/ResponsePacketBuilderTest.java
@@ -47,7 +47,7 @@ public final class ResponsePacketBuilderTest {
         QueryHeader queryHeader2 = new QueryHeader("schema2", "table2", 
"columnLabel2", "columnName2", 8, "VARCHAR", 7, 9, false, true, true, true);
         List<QueryHeader> queryHeaders = Arrays.asList(queryHeader1, 
queryHeader2);
         QueryResponseHeader queryResponseHeader = new 
QueryResponseHeader(queryHeaders);
-        Collection<DatabasePacket<?>> actual = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 255);
+        Collection<DatabasePacket<?>> actual = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 255, 0);
         assertTrue(actual.stream().findAny().isPresent());
         assertThat(actual.stream().findAny().get(), 
anyOf(instanceOf(MySQLFieldCountPacket.class), 
instanceOf(MySQLColumnDefinition41Packet.class), 
instanceOf(MySQLEofPacket.class)));
     }
@@ -57,7 +57,7 @@ public final class ResponsePacketBuilderTest {
         UpdateResponseHeader updateResponseHeader = 
mock(UpdateResponseHeader.class);
         when(updateResponseHeader.getUpdateCount()).thenReturn(10L);
         when(updateResponseHeader.getLastInsertId()).thenReturn(100L);
-        Collection<DatabasePacket<?>> actual = 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader);
+        Collection<DatabasePacket<?>> actual = 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 0);
         assertTrue(actual.stream().findAny().isPresent());
         MySQLOKPacket actualItem = (MySQLOKPacket) 
actual.stream().findAny().get();
         assertThat(actualItem, instanceOf(MySQLOKPacket.class));
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
index dc56c0e77a4..3052f9847ee 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/binary/execute/ReactiveMySQLComStmtExecuteExecutor.java
@@ -53,6 +53,7 @@ import 
org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
 import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
 import 
org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -120,7 +121,7 @@ public final class ReactiveMySQLComStmtExecuteExecutor 
implements ReactiveComman
                 while (next()) {
                     result.add(getQueryRowPacket());
                 }
-                result.add(new MySQLEofPacket(++currentSequenceId));
+                result.add(new MySQLEofPacket(++currentSequenceId, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
                 return Future.succeededFuture(result);
             } catch (SQLException ex) {
                 return Future.failedFuture(ex);
@@ -145,14 +146,14 @@ public final class ReactiveMySQLComStmtExecuteExecutor 
implements ReactiveComman
     
     private Collection<DatabasePacket<?>> processQuery(final 
QueryResponseHeader queryResponseHeader, final int characterSet) {
         responseType = ResponseType.QUERY;
-        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet);
+        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
         currentSequenceId = result.size();
         return result;
     }
     
     private Collection<DatabasePacket<?>> processUpdate(final 
UpdateResponseHeader updateResponseHeader) {
         responseType = ResponseType.UPDATE;
-        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader);
+        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 
ServerStatusFlagCalculator.calculateFor(connectionSession));
     }
     
     private boolean next() throws SQLException {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
index 3ac548685a6..e13a77d33b6 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/fieldlist/ReactiveMySQLComFieldListPacketExecutor.java
@@ -33,6 +33,7 @@ import 
org.apache.shardingsphere.proxy.backend.communication.DatabaseCommunicati
 import 
org.apache.shardingsphere.proxy.backend.communication.vertx.VertxDatabaseCommunicationEngine;
 import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import 
org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
@@ -49,6 +50,8 @@ public final class ReactiveMySQLComFieldListPacketExecutor 
implements ReactiveCo
     
     private final MySQLComFieldListPacket packet;
     
+    private final ConnectionSession connectionSession;
+    
     private final String databaseName;
     
     private final VertxDatabaseCommunicationEngine databaseCommunicationEngine;
@@ -59,6 +62,7 @@ public final class ReactiveMySQLComFieldListPacketExecutor 
implements ReactiveCo
     
     public ReactiveMySQLComFieldListPacketExecutor(final 
MySQLComFieldListPacket packet, final ConnectionSession connectionSession) {
         this.packet = packet;
+        this.connectionSession = connectionSession;
         databaseName = connectionSession.getDefaultDatabaseName();
         String sql = String.format(SQL, packet.getTable(), databaseName);
         MetaDataContexts metaDataContexts = 
ProxyContext.getInstance().getContextManager().getMetaDataContexts();
@@ -88,7 +92,7 @@ public final class ReactiveMySQLComFieldListPacketExecutor 
implements ReactiveCo
             result.add(new MySQLColumnDefinition41Packet(
                     ++currentSequenceId, characterSet, databaseName, 
packet.getTable(), packet.getTable(), columnName, columnName, 100, 
MySQLBinaryColumnType.MYSQL_TYPE_VARCHAR, 0, true));
         }
-        result.add(new MySQLEofPacket(++currentSequenceId));
+        result.add(new MySQLEofPacket(++currentSequenceId, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
         return result;
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
index 227f808c9e5..2d401612396 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-reactive-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/reactive/mysql/command/query/text/query/ReactiveMySQLComQueryPacketExecutor.java
@@ -30,6 +30,7 @@ import 
org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandlerFactory;
 import org.apache.shardingsphere.proxy.frontend.command.executor.ResponseType;
+import 
org.apache.shardingsphere.proxy.frontend.mysql.command.ServerStatusFlagCalculator;
 import 
org.apache.shardingsphere.proxy.frontend.mysql.command.query.builder.ResponsePacketBuilder;
 import 
org.apache.shardingsphere.proxy.frontend.reactive.command.executor.ReactiveCommandExecutor;
 
@@ -44,6 +45,8 @@ import java.util.Optional;
  */
 public final class ReactiveMySQLComQueryPacketExecutor implements 
ReactiveCommandExecutor {
     
+    private final ConnectionSession connectionSession;
+    
     private final TextProtocolBackendHandler textProtocolBackendHandler;
     
     private final int characterSet;
@@ -53,6 +56,7 @@ public final class ReactiveMySQLComQueryPacketExecutor 
implements ReactiveComman
     private int currentSequenceId;
     
     public ReactiveMySQLComQueryPacketExecutor(final MySQLComQueryPacket 
packet, final ConnectionSession connectionSession) throws SQLException {
+        this.connectionSession = connectionSession;
         textProtocolBackendHandler = 
TextProtocolBackendHandlerFactory.newInstance(DatabaseTypeFactory.getInstance("MySQL"),
 packet.getSql(), Optional::empty, connectionSession);
         characterSet = 
connectionSession.getAttributeMap().attr(MySQLConstants.MYSQL_CHARACTER_SET_ATTRIBUTE_KEY).get().getId();
     }
@@ -67,7 +71,7 @@ public final class ReactiveMySQLComQueryPacketExecutor 
implements ReactiveComman
                     while (textProtocolBackendHandler.next()) {
                         result.add(new 
MySQLTextResultSetRowPacket(++currentSequenceId, 
textProtocolBackendHandler.getRowData()));
                     }
-                    result.add(new MySQLEofPacket(++currentSequenceId));
+                    result.add(new MySQLEofPacket(++currentSequenceId, 
ServerStatusFlagCalculator.calculateFor(connectionSession)));
                 }
                 return Future.succeededFuture(result);
             } catch (final SQLException ex) {
@@ -78,14 +82,14 @@ public final class ReactiveMySQLComQueryPacketExecutor 
implements ReactiveComman
     
     private Collection<DatabasePacket<?>> processQuery(final 
QueryResponseHeader queryResponseHeader) {
         responseType = ResponseType.QUERY;
-        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet);
+        Collection<DatabasePacket<?>> result = 
ResponsePacketBuilder.buildQueryResponsePackets(queryResponseHeader, 
characterSet, ServerStatusFlagCalculator.calculateFor(connectionSession));
         currentSequenceId = result.size();
         return result;
     }
     
     private Collection<DatabasePacket<?>> processUpdate(final 
UpdateResponseHeader updateResponseHeader) {
         responseType = ResponseType.UPDATE;
-        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader);
+        return 
ResponsePacketBuilder.buildUpdateResponsePackets(updateResponseHeader, 
ServerStatusFlagCalculator.calculateFor(connectionSession));
     }
     
     @Override

Reply via email to