anchor.diff:                {ok,fields(),rows(),result(),socket()}|
                 {error,_,socket()}.
   query(Args) ->
  -    loop(Args, [fun query_pre/3, fun send2/3, fun recv_status2/2,
  -                fun query_post/3, fun recv_fields/3, fun recv_rows/3]).
  +    loop(Args, [fun query_pre/3, fun send/3, fun query_post/2,
  +                fun recv_fields/3, fun recv_rows/3]).
   
   
   -spec stmt_prepare([term()]) -> {ok,prepare(),socket()}|{error,_,socket()}.
   stmt_prepare(Args) ->
  -    loop(Args, [fun stmt_prepare_pre/3, fun send2/3,
  -                fun recv_status2/2, fun stmt_prepare_post/3,
  +    loop(Args, [fun stmt_prepare_pre/3, fun send/3, fun stmt_prepare_post/2,
                   fun stmt_prepare_recv_params/3, fun stmt_prepare_recv_fields/3]).
   
   %% == internal ==
  
positive.code:     L = binary:split(<<Binary/binary,".0.0">>, [<<$.>>,<<$->>], [global]),
      lists:map(F, lists:sublist(L,3)).
  
  func_recv_field(#protocol{caps=C})
    when ?IS_SET(C,?CLIENT_PROTOCOL_41) ->
      fun myer_protocol_text:recv_field_41/2;
  func_recv_field(_Protocol) ->
      fun myer_protocol_text:recv_field/2.
  
  reset(#protocol{handle=H}=P) ->
      P#protocol{handle = myer_socket:reset(H)}.
  
  %% -- internal: loop,next_result --
  
  next_result_pre(#protocol{}=P) ->
      {ok, [reset(P)]}.
  
  %% -- internal: loop,stmt_close --
  
  stmt_close_pre(#prepare{stmt_id=S}=X, #protocol{}=P) ->
      {ok, [X,<<?COM_STMT_CLOSE,S:32/little>>,reset(P)]}.
  
  stmt_close_post(_Prepare, #protocol{}=P) ->
      {ok, [P]}.
  
  %% -- internal: loop,stmt_execute --
  
  stmt_execute_pre(Prepare, Args, #protocol{}=P) ->
      B = stmt_execute_to_binary(Prepare, Args),
      {ok, [Prepare,B,reset(P)]}.
  
  stmt_execute_post(<<0>>, #prepare{execute=E}=X, #protocol{}=P) ->
      case recv_result(P) of
          {ok, [Result,Protocol]} ->
              {ok, [X#prepare{result = Result, execute = E+1},Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end;
  stmt_execute_post(Byte, Prepare, #protocol{}=P) ->
      case recv_packed_integer(Byte, P) of
          {ok, N, Protocol} ->
              stmt_execute_recv_fields(Prepare, N, Protocol);
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  stmt_execute_recv_fields(#prepare{}=X, N, #protocol{}=P) -> % do CALL, 0=X.filed_count
      case recv_until_eof(func_recv_field(P), [], [], P) of
          {ok, [Result,Fields,Protocol]} when N == length(Fields) ->
              F = myer_protocol_binary:prepare_fields(Fields),
              stmt_execute_recv_rows(Result, X#prepare{field_count = N, fields = F}, Protocol);
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  stmt_execute_recv_rows(#result{status=S}=R, #prepare{execute=E}=X, #protocol{}=P)
    when ?IS_SET(S,?SERVER_STATUS_CURSOR_EXISTS) ->
      {ok, [X#prepare{result = R, execute = E+1},P]};
  stmt_execute_recv_rows(_Result, #prepare{fields=F,execute=E}=X, #protocol{}=P) ->
      case recv_until_eof(fun myer_protocol_binary:recv_row/3, [F], [], P) of
          {ok, [Result,Rows,Protocol]} ->
              {ok, [F,Rows,X#prepare{result = Result, execute = E+1},Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  %% -- internal: loop,stmt_fetch --
  
  stmt_fetch_pre(#prepare{stmt_id=S,prefetch_rows=R}=X, #protocol{}=P) ->
      B = <<?COM_STMT_FETCH, S:32/little, R:32/little>>,
      {ok, [X,B,reset(P)]}.
  
  stmt_fetch_post(#prepare{fields=F}=X, #protocol{}=P) ->
      case recv_until_eof(fun myer_protocol_binary:recv_row/3, [F], [], P) of
          {ok, [Result,Rows,Protocol]} ->
              {ok, [F,Rows,X#prepare{result = Result},Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  %% -- internal: loop,stmt_next_result --
  
  stmt_next_result_pre(#prepare{}=X, #protocol{}=P) ->
      {ok, [X,reset(P)]}.
  
  stmt_next_result_post(<<0>>, #prepare{execute=E}=X, #protocol{}=P) ->
      case recv_result(P) of
          {ok, [Result,Protocol]} ->
              {ok, [X#prepare{result = Result, execute = E+1},Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  %% -- internal: loop,stmt_reset --
  
  stmt_reset_pre(#prepare{stmt_id=S}=X, #protocol{}=P) ->
      {ok, [X,<<?COM_STMT_RESET,S:32/little>>,reset(P)]}.
  
  stmt_reset_post(<<0>>, #prepare{}=X, #protocol{}=P) ->
      case recv_result(P) of
          {ok, [Result,Protocol]} ->
              {ok, [X#prepare{result = Result},Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  %% -- internal: network --
  
  recv_eof(Term, #protocol{}=P) ->
      case recv(P, 0) of
          {ok, Binary, Protocol} ->
              {ok, [Binary,Term,Protocol]};
          {error, Reason, P} ->
              {error, Reason, P}
      end.
  
  recv_error(#protocol{}=P) ->
      case recv(P, 0) of
          {ok, Binary, Protocol} ->
              {error, Binary, Protocol};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  recv_result(#protocol{}=P) ->
      case recv(P, 0) of
          {ok, Binary, Protocol} ->
              {ok, [Binary,Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  recv_status(#protocol{}=P) ->
      case recv(P, 1) of
          {ok, <<255>>, Protocol} ->
              recv_error(Protocol);
          {ok, Byte, Protocol} ->
              {ok, [Byte,Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  recv_status(Term, #protocol{}=P) ->
      case recv(P, 1) of
          {ok, <<255>>, Protocol} ->
              recv_error(Protocol);
          {ok, Byte, Protocol} ->
              {ok, [Byte,Term,Protocol]};
          {error, Reason, P} ->
              {error, Reason, P}
      end.
  
  recv_unsigned(Length, #protocol{}=P) ->
      case recv(P, Length) of
  
negative.code:             {ok, [binary:decode_unsigned(Binary,little),Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  %% -----------------------------------------------------------------------------
  