anchor.diff:  
   %% == 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]).
  +%% -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 ==
  
positive.code:             {ok, [binary:decode_unsigned(Binary,little),Protocol]};
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  recv_until_eof(Func, Args, List, #protocol{}=P) ->
      case recv(P, 1) of
          {ok, <<255>>, Protocol} ->
              recv_error(Protocol);
          {ok, <<254>>, Protocol} ->
              recv_eof(lists:reverse(List), Protocol);
          {ok, Byte, Protocol} ->
              recv_until_eof(Func, Args, List, Byte, Protocol);
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  recv_until_eof(Func, Args, List, Byte, #protocol{}=P) ->
      case apply(Func, [P|[Byte|Args]]) of % TODO
          {ok, Term, Protocol} ->
              recv_until_eof(Func, Args, [Term|List], Protocol);
          {error, Reason, Protocol} ->
              {error, Reason, Protocol}
      end.
  
  send(Term, Binary, #protocol{handle=H,caps=C}=P) ->
      case myer_socket:send(H, Binary, ?IS_SET(C,?CLIENT_COMPRESS)) of
          {ok, Handle} ->
              {ok, [Term,P#protocol{handle = Handle}]};
          {error, Reason} ->
              {error, Reason, P}
      end.
  
  %% -----------------------------------------------------------------------------
  
negative.code:             {error, Reason}
      end.
  
  send(Term, Binary, Caps, S) ->
      case myer_socket:send(S, Binary, ?IS_SET(Caps,?CLIENT_COMPRESS)) of
          {ok, Socket} ->
              {ok, [Term,Caps,Socket]};
  