anchor.diff:  %% << sql/sql_acl.cc (< 5.7)         : send_server_handshake_packet/3
   %%    sql/auth/sql_authentication.cc : send_server_handshake_packet/3
   %% -----------------------------------------------------------------------------
  +recv_handshake(MaxLength, Handle) ->
  +    recv_handshake(#handshake{
  +                      maxlength = MaxLength
  +                     }, myer_handle:caps(Handle), Handle).
  +
   recv_handshake(#handshake{version=undefined}=R, Caps, Handle) ->
  -    {ok, B, H} = recv_text(<<0>>, Caps, Handle),
  +    {ok, B, H} = recv_text(<<0>>, Handle),
       recv_handshake(R#handshake{version = binary_to_version(B)}, Caps, H);
   recv_handshake(#handshake{tid=undefined}=R, Caps, Handle) ->
  -    {ok, U, H} = recv_unsigned(4, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(4, Handle),
       recv_handshake(R#handshake{tid = U}, Caps, H);
   recv_handshake(#handshake{seed1=undefined}=R, Caps, Handle) ->
  -    {ok, B, H} = recv_text(<<0>>, Caps, Handle),
  +    {ok, B, H} = recv_text(<<0>>, Handle),
       recv_handshake(R#handshake{seed1 = B}, Caps, H);
   recv_handshake(#handshake{caps1=undefined}=R, Caps, Handle) ->
  -    {ok, U, H} = recv_unsigned(2, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(2, Handle),
       recv_handshake(R#handshake{caps1 = U}, Caps, H);
   recv_handshake(#handshake{charset=undefined}=R, Caps, Handle) ->
  -    {ok, U, H} = recv_unsigned(1, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(1, Handle),
       recv_handshake(R#handshake{charset = U}, Caps, H);
   recv_handshake(#handshake{status=undefined}=R, Caps, Handle) ->
  -    {ok, U, H} = recv_unsigned(2, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(2, Handle),
       recv_handshake(R#handshake{status = U}, Caps, H);
   recv_handshake(#handshake{version=V,caps1=C,caps2=undefined}=R, Caps, Handle)
     when V >= [4,1,1]; ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
  -    {ok, U, H} = recv_unsigned(2, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(2, Handle),
       recv_handshake(R#handshake{caps2 = U}, Caps, H);
   recv_handshake(#handshake{caps2=undefined}=R, Caps, Handle) ->
       recv_handshake(R#handshake{caps2 = 0}, Caps, Handle);
   recv_handshake(#handshake{version=V,caps1=C,length=undefined}=R, Caps, Handle)
     when V >= [4,1,1]; ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
  -    {ok, U, H} = recv_unsigned(1, Caps, Handle),
  +    {ok, U, H} = recv_unsigned(1, Handle),
       recv_handshake(R#handshake{length = U}, Caps, H);
   recv_handshake(#handshake{length=undefined}=R, Caps, Handle) ->
       recv_handshake(R#handshake{length = 8}, Caps, Handle);   % 8?, TODO
   recv_handshake(#handshake{version=V,caps1=C,reserved=undefined}=R, Caps, Handle)
     when V >= [4,1,1]; ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
  -    {ok, B, H} = recv_binary(10, Caps, Handle),
  +    {ok, B, H} = recv_binary(10, Handle),
       recv_handshake(R#handshake{reserved = B}, Caps, H); % "always 0"
   recv_handshake(#handshake{reserved=undefined}=R, Caps, Handle) ->
  -    {ok, B, H} = recv_binary(13, Caps, Handle),
  +    {ok, B, H} = recv_binary(13, Handle),
       recv_handshake(R#handshake{reserved = B}, Caps, H); % "always 0"?
   recv_handshake(#handshake{version=V,caps1=C,seed2=undefined}=R, Caps, Handle)
     when V >= [4,1,1]; ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
  -    {ok, B, H} = recv_text(<<0>>, Caps, Handle),
  +    {ok, B, H} = recv_text(<<0>>, Handle),
       recv_handshake(R#handshake{seed2 = B}, Caps, H);
   recv_handshake(#handshake{seed2=undefined}=R, Caps, Handle) ->
       recv_handshake(R#handshake{seed2 = <<>>}, Caps, Handle);
   recv_handshake(#handshake{version=V,caps1=C,plugin=undefined}=R, Caps, Handle)
     when V >= [4,1,1]; ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
  -    {ok, B, H} = recv_text(<<0>>, Caps, Handle),
  +    {ok, B, H} = recv_text(<<0>>, Handle),
       recv_handshake(R#handshake{plugin = B}, Caps, H);
   recv_handshake(#handshake{plugin=undefined}=R, Caps, Handle) ->
       recv_handshake(R#handshake{plugin = <<"mysql_native_password">>}, Caps, Handle);
  
positive.code:     Scrambled = myer_auth:scramble(Password, S, P),
      {ok, [<<Scrambled/binary,0>>,H]}.
  
  auth_alt_post(#handle{caps=C}=H) ->
      case recv_binary(1, C, H) of
          {ok, <<0>>, Handle} ->
              recv_result(#result{}, C, Handle);
          {ok, <<255>>, Handle} ->
              recv_reason(#reason{}, C, Handle)
      end.
  
  %% -- internal: ping --
  
negative.code: %% -----------------------------------------------------------------------------
  %% << sql/sql_prepare.cc : send_prep_stmt/2
  %% -----------------------------------------------------------------------------
  recv_prepare(Handle) ->
      recv_prepare(#prepare{
                      flags = ?CURSOR_TYPE_NO_CURSOR,
                      prefetch_rows = 1,
                      execute = 0
                     },
                   myer_handle:caps(Handle), Handle).
  
  recv_prepare(#prepare{stmt_id=undefined}=P, Caps, Handle) ->
      {ok, U, H} = recv_unsigned(4, Handle),
      recv_prepare(P#prepare{stmt_id=U}, Caps, H);
  recv_prepare(#prepare{field_count=undefined}=P, Caps, Handle) ->
      {ok, U, H} = recv_unsigned(2, Handle),
      recv_prepare(P#prepare{field_count=U}, Caps, H);
  recv_prepare(#prepare{param_count=undefined}=P, Caps, Handle) ->
      {ok, U, H} = recv_unsigned(2, Handle),
      recv_prepare(P#prepare{param_count=U}, Caps, H);
  recv_prepare(#prepare{reserved=undefined}=P, Caps, Handle) ->
      {ok, B, H} = recv_binary(1, Handle), % <<0>>
      recv_prepare(P#prepare{reserved=B}, Caps, H);
  recv_prepare(#prepare{warning_count=undefined}=P, Caps, Handle) -> % < 5.0, undefined?
      {ok, U, H} = recv_unsigned(2, Handle),
      recv_prepare(P#prepare{warning_count=U}, Caps, H);
  recv_prepare(#prepare{}=P, _Caps, Handle) ->
      {ok, [P,Handle]}.
  