anchor.diff:  
   %% PortalSuspended
   on_message({$s, <<>>}, State) ->
  -    #state{queue = Q} = State,
  -    notify(State, suspended),
  -    {noreply, State#state{queue = queue:drop(Q)}};
  +    {noreply, reply(State, {partial, lists:reverse(State#state.rows)})};
   
   %% CommandComplete
   on_message({$C, Bin}, State) ->
  -    #state{queue = Q} = State,
  -    Complete = pgsql_wire:decode_complete(Bin),
  -    notify(State, {complete, Complete}),
  -    State2 = case request_tag(State) of
  -                 C when C == execute ->
  -                     State#state{queue = queue:drop(Q)};
  -                 _ ->
  -                     State
  +    Result = case pgsql_wire:decode_complete(Bin) of
  +                 {_Type, Count} ->
  +                     case State#state.rows of
  +                         [] -> {ok, Count};
  +                         _ -> {ok, Count, State#state.columns,
  +                               lists:reverse(State#state.rows)}
  +                     end;
  +                 _Type ->
  +                     {ok, State#state.columns, lists:reverse(State#state.rows)}
  +             end,
  +    State2 = case command_tag(State) of
  +                 execute ->
  +                     reply(State, Result);
  +                 C when C == squery; C == equery ->
  +                     State#state{results = [Result | State#state.results]}
                end,
       {noreply, State2};
   
   %% EmptyQueryResponse
   on_message({$I, _Bin}, State) ->
  -    notify(State, {complete, empty}),
  -    {noreply, State};
  +    %% TODO check expected result format
  +    State2 = case command_tag(State) of
  +                 execute ->
  +                     reply(State, empty);
  +                 C when C == squery; C == equery ->
  +                     State#state{results = [empty | State#state.results]}
  +             end,
  +    {noreply, State2};
   
   %% ReadyForQuery
   on_message({$Z, <<_Status:8>>}, State) ->
  -    #state{queue = Q} = State,
  -    notify(State, done),
  -    {noreply, State#state{queue = queue:drop(Q)}};
  +    State2 = case command_tag(State) of
  +                 squery ->
  +                     case State#state.results of
  +                         [Result] ->
  +                             reply(State, Result);
  +                         Results ->
  +                             reply(State, lists:reverse(Results))
  +                     end;
  +                 equery ->
  +                     [Result] = State#state.results,
  +                     reply(State, Result);
  +                 sync ->
  +                     reply(State, ok)
  +             end,
  +    {noreply, State2};
   
   on_message(Error = {error, _}, State) ->
  -    #state{queue = Q} = State,
  -    notify(State, Error),
  -    State2 = case request_tag(State) of
  +    State2 = case command_tag(State) of
                    C when C == squery; C == equery ->
  -                     State;
  +                     State#state{results = [Error | State#state.results]};
                    _ ->
  -                     sync_required(State#state{queue = queue:drop(Q)})
  +                     sync_required(reply(State, Error))
                end,
       {noreply, State2};
   
  
positive.code: send(#state{mod = Mod, sock = Sock}, Type, Data) ->
      Mod:send(Sock, pgsql_wire:encode(Type, Data)).
  
  notify(#state{queue = Q}, Message) ->
      {{From, Ref}, _} = queue:get(Q),
      From ! {Ref, Message}.
  
  notify_async(#state{async = Pid}, Msg) ->
      case is_pid(Pid) of
  
negative.code:     #state{queue = Q} = State,
      Types = [pgsql_types:oid2type(Oid) || <<Oid:?int32>> <= Bin],
      Name = case queue:get(Q) of
                 {_, {parse, N, _, _}} -> N;
                 {_, {describe_statement, N}} -> N
             end,
      {noreply, State#state{statement = #statement{name = Name,
                                                   types = Types}}};
  
  %% RowDescription
  on_message({$T, <<Count:?int16, Bin/binary>>}, State) ->
      Columns = pgsql_wire:decode_columns(Count, Bin),
      State2 = case command_tag(State) of
                   C when C == squery ->
                       State#state{columns = Columns};
                   C when C == parse; C == describe_statement ->
                       reply(State,
                             {ok, State#state.statement#statement{
                                                columns = Columns}});
                   C when C == describe_portal ->
                       reply(State, {ok, Columns})
               end,
      {noreply, State2};
  
  %% NoData
  on_message({$n, <<>>}, State) ->
      State2 = case command_tag(State) of
                   C when C == parse; C == describe_statement ->
                       reply(State,
                             {ok, State#state.statement#statement{columns= []}});
                   describe_portal ->
                       reply(State, {ok, []})
               end,
      {noreply, State2};
  
  %% BindComplete
  on_message({$2, <<>>}, State) ->
      State2 = case command_tag(State) of
                   equery ->
                       State;
                   bind ->
                       reply(State, ok)
               end,
      {noreply, State2};
  
  %% CloseComplete
  on_message({$3, <<>>}, State) ->
      State2 = case command_tag(State) of
                   close ->
                       reply(State, ok);
                   equery ->
                       State
               end,
      {noreply, State2};
  