anchor.diff:      execute(C, S, "", N).
   
   execute(C, S, PortalName, N) ->
  -    pgsql_sock:execute(C, S, PortalName, N),
  -    receive_extended_result(C).
  +    Ref = pgsql_sock:execute(C, S, PortalName, N),
  +    receive_extended_result(C, Ref).
   
   %% statement/portal functions
   
  -describe(C, #statement{name = Name}) ->
  -    pgsql_sock:describe(C, statement, Name).
  +describe(C, Statement = #statement{name = Name}) ->
  +    Ref = pgsql_sock:describe(C, statement, Name),
  +    receive_describe(C, Ref, Statement).
  +
  +describe(C, statement, Name) ->
  +    Ref = pgsql_sock:describe(C, statement, Name),
  +    receive_describe(C, Ref, #statement{name = Name});
   
   describe(C, Type, Name) ->
       pgsql_sock:describe(C, Type, Name).
  
positive.code: 
  %% -- internal functions --
  
  receive_result(C, Result) ->
      try receive_result(C, [], []) of
          done    -> Result;
          R       -> receive_result(C, R)
      catch
          throw:E -> E
      end.
  
  receive_results(C, Results) ->
      try receive_result(C, [], []) of
          done    -> lists:reverse(Results);
          R       -> receive_results(C, [R | Results])
      catch
          throw:E -> E
      end.
  
  receive_result(C, Cols, Rows) ->
      receive
          {pgsql, C, {columns, Cols2}} ->
              receive_result(C, Cols2, Rows);
          {pgsql, C, {data, Row}} ->
              receive_result(C, Cols, [Row | Rows]);
          {pgsql, C, {error, _E} = Error} ->
              Error;
          {pgsql, C, {complete, {_Type, Count}}} ->
              case Rows of
                  [] -> {ok, Count};
                  _L -> {ok, Count, Cols, lists:reverse(Rows)}
              end;
          {pgsql, C, {complete, _Type}} ->
              {ok, Cols, lists:reverse(Rows)};
          {pgsql, C, done} ->
              done;
          {pgsql, C, timeout} ->
              throw({error, timeout});
          {'EXIT', C, _Reason} ->
              throw({error, closed})
      end.
  
  receive_extended_result(C)->
      receive_extended_result(C, []).
  
  receive_extended_result(C, Rows) ->
      receive
          {pgsql, C, {data, Row}} ->
              receive_extended_result(C, [Row | Rows]);
          {pgsql, C, {error, _E} = Error} ->
              Error;
          {pgsql, C, suspended} ->
              {partial, lists:reverse(Rows)};
          {pgsql, C, {complete, {_Type, Count}}} ->
              case Rows of
                  [] -> {ok, Count};
                  _L -> {ok, Count, lists:reverse(Rows)}
              end;
          {pgsql, C, {complete, _Type}} ->
              {ok, lists:reverse(Rows)};
          {pgsql, C, timeout} ->
              {error, timeout};
          {'EXIT', C, _Reason} ->
              {error, closed}
      end.
  
negative.code:     parse(C, "", Sql, Types).
  
  parse(C, Name, Sql, Types) ->
      Ref = pgsql_sock:parse(C, Name, Sql, Types),
      receive_describe(C, Ref, #statement{name = Name}).
  
  %% bind
  
  