Browse Source

equery responses

Anton Lebedevich 13 years ago
parent
commit
9c1c8639e1
2 changed files with 31 additions and 0 deletions
  1. 29 0
      src/pgsql_sock.erl
  2. 2 0
      src/pgsql_wire.erl

+ 29 - 0
src/pgsql_sock.erl

@@ -325,6 +325,35 @@ on_message({$n, <<>>}, State) ->
     notify(State, no_data),
     {noreply, State#state{queue = queue:drop(Q)}};
 
+%% BindComplete
+on_message({$2, <<>>}, State) ->
+    {noreply, State};
+
+%% CloseComplete
+on_message({$3, <<>>}, State) ->
+    {noreply, State};
+
+%% DataRow
+on_message({$D, <<_Count:?int16, Bin/binary>>}, State) ->
+    #state{queue = Q} = State,
+    %% TODO wrong for squery
+    {_, {equery, #statement{columns = Columns}, _}} = queue:get(Q),
+    Data = pgsql_wire:decode_data(Columns, Bin),
+    notify(State, {data, Data}),
+    {noreply, State};
+
+%% CommandComplete
+on_message({$C, Bin}, State) ->
+    Complete = pgsql_wire:decode_complete(Bin),
+    notify(State, {complete, Complete}),
+    {noreply, State};
+
+%% ReadyForQuery
+on_message({$Z, <<_Status:8>>}, State) ->
+    #state{queue = Q} = State,
+    notify(State, done),
+    {noreply, State#state{queue = queue:drop(Q)}};
+
 on_message(Error = {error, _}, State) ->
     #state{queue = Q} = State,
     notify(State, Error),

+ 2 - 0
src/pgsql_wire.erl

@@ -6,6 +6,8 @@
          decode_columns/2,
          encode/1,
          encode/2,
+         decode_data/2,
+         decode_complete/1,
          encode_types/1,
          encode_formats/1,
          format/1,