|
@@ -295,6 +295,12 @@ reply(State = #state{queue = Q}, Message) ->
|
|
rows = [],
|
|
rows = [],
|
|
results = []}.
|
|
results = []}.
|
|
|
|
|
|
|
|
+add_result(State = #state{results = Results}, Result) ->
|
|
|
|
+ State#state{statement = undefined,
|
|
|
|
+ columns = [],
|
|
|
|
+ rows = [],
|
|
|
|
+ results = [Result | Results]}.
|
|
|
|
+
|
|
notify_async(#state{async = Pid}, Msg) ->
|
|
notify_async(#state{async = Pid}, Msg) ->
|
|
case is_pid(Pid) of
|
|
case is_pid(Pid) of
|
|
true -> Pid ! {pgsql, self(), Msg};
|
|
true -> Pid ! {pgsql, self(), Msg};
|
|
@@ -471,9 +477,7 @@ on_message({$C, Bin}, State) ->
|
|
execute ->
|
|
execute ->
|
|
reply(State, Result);
|
|
reply(State, Result);
|
|
C when C == squery; C == equery ->
|
|
C when C == squery; C == equery ->
|
|
- State#state{columns = [],
|
|
|
|
- rows = [],
|
|
|
|
- results = [Result | State#state.results]}
|
|
|
|
|
|
+ add_result(State, Result)
|
|
end,
|
|
end,
|
|
{noreply, State2};
|
|
{noreply, State2};
|
|
|
|
|
|
@@ -483,8 +487,7 @@ on_message({$I, _Bin}, State) ->
|
|
execute ->
|
|
execute ->
|
|
reply(State, {ok, [], []});
|
|
reply(State, {ok, [], []});
|
|
C when C == squery; C == equery ->
|
|
C when C == squery; C == equery ->
|
|
- State#state{
|
|
|
|
- results = [{ok, [], []} | State#state.results]}
|
|
|
|
|
|
+ add_result(State, {ok, [], []})
|
|
end,
|
|
end,
|
|
{noreply, State2};
|
|
{noreply, State2};
|
|
|
|
|
|
@@ -509,7 +512,7 @@ on_message({$Z, <<Status:8>>}, State) ->
|
|
on_message(Error = {error, _}, State) ->
|
|
on_message(Error = {error, _}, State) ->
|
|
State2 = case command_tag(State) of
|
|
State2 = case command_tag(State) of
|
|
C when C == squery; C == equery ->
|
|
C when C == squery; C == equery ->
|
|
- State#state{results = [Error | State#state.results]};
|
|
|
|
|
|
+ add_result(State, Error);
|
|
_ ->
|
|
_ ->
|
|
sync_required(reply(State, Error))
|
|
sync_required(reply(State, Error))
|
|
end,
|
|
end,
|