Browse Source

incomplete parse

Anton Lebedevich 13 years ago
parent
commit
b1c9eaaee8
1 changed files with 11 additions and 1 deletions
  1. 11 1
      src/pgsql_sock.erl

+ 11 - 1
src/pgsql_sock.erl

@@ -116,7 +116,17 @@ handle_call({connect, Host, Username, Password, Opts},
 
 handle_call(stop, From, #state{queue = Queue} = State) ->
     %% TODO flush queue
-    {stop, normal, ok, State}.
+    {stop, normal, ok, State};
+
+handle_call({parse, Name, Sql, Types}, From, State) ->
+    #state{timeout = Timeout, queue = Queue} = State,
+    Bin = pgsql_wire:encode_types(Types),
+    send(State, $P, [Name, 0, Sql, 0, Bin]),
+    send(State, $D, [$S, Name, 0]),
+    send(State, $H, []),
+    S = #statement{name = Name},
+    State2 = State#state{queue = queue:in(From, Queue)},
+    {noreply, State2, Timeout}.
 
 handle_cast(cancel, State = #state{backend = {Pid, Key}}) ->
     {ok, {Addr, Port}} = inet:peername(State#state.sock),