anchor.diff:  -include("internal.hrl").
   
   %% -- public --
  --export([stmt_close/2, stmt_execute/3, stmt_fetch/2, stmt_reset/2]).
  --export([next_result/1, stmt_next_result/2]).
  +%% -export([stmt_close/2, stmt_execute/3, stmt_fetch/2, stmt_reset/2]).
  +%% -export([next_result/1, stmt_next_result/2]).
   
   %% -- private --
   -export([binary_to_float/2]).
  
positive.code: 
  %% == public ==
  
  -spec stmt_close(protocol(),prepare()) -> {ok,undefined,protocol()}|{error,_,protocol()}.
  stmt_close(#protocol{handle=H}=P, #prepare{}=X)
    when undefined =/= H ->
      loop([X,P], [fun stmt_close_pre/2, fun send/3, fun stmt_close_post/2]).
  
  -spec stmt_execute(protocol(),prepare(),[term()])
                    -> {ok,prepare(),protocol()}|
                       {ok,{[field()],[term()],prepare()},protocol()}|{error,_,protocol()}.
  stmt_execute(#protocol{handle=H}=P, #prepare{param_count=N}=X, Args)
    when undefined =/= H, is_list(Args), N == length(Args) ->
      loop([X,Args,P], [fun stmt_execute_pre/3, fun send/3, fun recv_status/2, fun stmt_execute_post/3]).
  
  -spec stmt_fetch(protocol(),prepare())
                  -> {ok,prepare(),protocol()}|
                     {ok,{[field()],[term()],prepare()},protocol()}|{error,_,protocol()}.
  stmt_fetch(#protocol{handle=H}=P, #prepare{result=R}=X)
    when undefined =/= H ->
      case R#result.status of
          S when ?IS_SET(S,?SERVER_STATUS_CURSOR_EXISTS) ->
              loop([X,P], [fun stmt_fetch_pre/2, fun send/3, fun stmt_fetch_post/2]);
          _ ->
              {ok, X, P}
      end.
  
  -spec stmt_reset(protocol(),prepare()) -> {ok,prepare(),protocol()}|{error,_,protocol()}.
  stmt_reset(#protocol{handle=H}=P, #prepare{}=X)
    when undefined =/= H ->
      loop([X,P], [fun stmt_reset_pre/2, fun send/3, fun recv_status/2, fun stmt_reset_post/3]).
  
  -spec next_result(protocol())
                   -> {ok,result(),protocol()}|
                      {ok,{[field()],[term()],result()},protocol()}|{error,_,protocol()}.
  next_result(#protocol{handle=H}=P)
    when undefined =/= H ->
      loop([P], [fun next_result_pre/1, fun recv_status/1, fun query_post/3]).
  
  -spec stmt_next_result(protocol(),prepare())
                        -> {ok,prepare()}|{ok,[field()],[term()],prepare(),protocol()}|{error,_, protocol()}.
  stmt_next_result(#protocol{handle=H}=P, #prepare{}=X)
    when undefined =/= H ->
      loop([X,P], [fun stmt_next_result_pre/2, fun recv_status/2, fun stmt_next_result_post/3]).
  
  
  %% == private ==
  
negative.code: stmt_prepare_recv_fields(#prepare{field_count=0}=P, _Caps, Socket) ->
      {ok, [P,Socket]};
  stmt_prepare_recv_fields(#prepare{field_count=N}=P, Caps, S) ->
      case recv_until_eof(recv_fields_func(Caps), [], [], Caps, S) of
          {ok, [Result,Fields,Socket]} when N == length(Fields) ->
              {ok, [P#prepare{fields = Fields, result = Result},Socket]};
          {error, Reason, Socket} ->
  