Skip to content

Commit

Permalink
Fixing bug in prepared statement handling and cleanup. Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Gerakines committed Aug 30, 2009
1 parent e8f7f2a commit ce910aa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/mysql_conn.erl
Expand Up @@ -223,7 +223,15 @@ do_queries(Sock, RecvPid, Queries, Version, Timeout) ->
do_execute(State, Name, Params, _ExpectedVersion, Stmt, Timeout) ->
case State#state.last of
{Name, Stmt} -> {ok, do_execute1(State, Name, Params, Timeout), State};
_ -> prepare_and_execute(State, Name, Stmt, Params, Timeout)
{OldName, _} ->
OldNameBin = erlang:atom_to_binary(OldName, utf8),
case do_query(State#state.socket, State#state.recv_pid, <<"DEALLOCATE PREPARE ", OldNameBin/binary>>, State#state.mysql_version, 1000) of
{updated, _} -> prepare_and_execute(State, Name, Stmt, Params, Timeout);
{error, Err} -> {error, Err};
Other -> {error, {unexpected_result, Other}}
end;
undefined ->
prepare_and_execute(State, Name, Stmt, Params, Timeout)
end.

%% @private
Expand Down

0 comments on commit ce910aa

Please sign in to comment.