Browse Source

Ignore SERVER_STATUS_AUTOCOMMIT on handshake

Ignacio Martínez 6 years ago
parent
commit
f43adad8e0
1 changed files with 5 additions and 2 deletions
  1. 5 2
      src/mysql_protocol.erl

+ 5 - 2
src/mysql_protocol.erl

@@ -83,8 +83,11 @@ handshake_finish_or_switch_auth(Handshake = #handshake{status = Status}, Passwor
     {ok, ConfirmPacket, SeqNum1} = recv_packet(SockModule, Socket, SeqNum0),
     {ok, ConfirmPacket, SeqNum1} = recv_packet(SockModule, Socket, SeqNum0),
     case parse_handshake_confirm(ConfirmPacket) of
     case parse_handshake_confirm(ConfirmPacket) of
         #ok{status = OkStatus} ->
         #ok{status = OkStatus} ->
-            %% check status, ignoring bit 16#4000, SERVER_SESSION_STATE_CHANGED.
-            Status = OkStatus band bnot 16#4000,
+            %% check status, ignoring bit 16#4000, SERVER_SESSION_STATE_CHANGED
+            %% and bit 16#0002, SERVER_STATUS_AUTOCOMMIT.
+            BitMask = bnot (?SERVER_SESSION_STATE_CHANGED bor ?SERVER_STATUS_AUTOCOMMIT),
+            StatusMasked = Status band BitMask,
+            StatusMasked = OkStatus band BitMask,
             {ok, Handshake, SockModule, Socket};
             {ok, Handshake, SockModule, Socket};
         #auth_method_switch{auth_plugin_name = AuthPluginName,
         #auth_method_switch{auth_plugin_name = AuthPluginName,
                             auth_plugin_data = AuthPluginData} ->
                             auth_plugin_data = AuthPluginData} ->