Browse Source

execute result has no columns in it

Anton Lebedevich 13 years ago
parent
commit
623eb2d225
1 changed files with 15 additions and 12 deletions
  1. 15 12
      src/pgsql_sock.erl

+ 15 - 12
src/pgsql_sock.erl

@@ -469,21 +469,24 @@ on_message({$s, <<>>}, State) ->
 
 %% CommandComplete
 on_message({$C, Bin}, State) ->
-    Result = case pgsql_wire:decode_complete(Bin) of
-                 {_Type, Count} ->
-                     case State#state.rows of
-                         [] -> {ok, Count};
-                         _ -> {ok, Count, get_columns(State),
-                               lists:reverse(State#state.rows)}
-                     end;
-                 _Type ->
-                     {ok, get_columns(State), lists:reverse(State#state.rows)}
-             end,
+    ResultHead = case pgsql_wire:decode_complete(Bin) of
+                     {_Type, Count} ->
+                         [ok, Count];
+                     _Type ->
+                         [ok]
+                 end,
     State2 = case command_tag(State) of
                  execute ->
-                     reply(State, Result);
+                     reply(State,
+                           list_to_tuple(
+                             ResultHead ++ [lists:reverse(State#state.rows)]));
                  C when C == squery; C == equery ->
-                     add_result(State, Result)
+                     Result = case State#state.rows of
+                                  [] -> ResultHead;
+                                  _ -> ResultHead ++ [get_columns(State)] ++
+                                           [lists:reverse(State#state.rows)]
+                              end,
+                     add_result(State, list_to_tuple(Result))
              end,
     {noreply, State2};