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:         <<"28P01">> -> Why = invalid_password;
          Any         -> Why = Any
      end,
      {stop, normal, reply(State, {error, Why})};
  
  auth(Other, State) ->
      on_message(Other, State).
  
  %% BackendKeyData
  initializing({$K, <<Pid:?int32, Key:?int32>>}, State) ->
      {noreply, State#state{backend = {Pid, Key}}};
  
  %% ReadyForQuery
  initializing({$Z, <<Status:8>>}, State) ->
      #state{parameters = Parameters} = State,
      erase(username),
      erase(password),
      %% TODO decode dates to now() format
  