Skip to content

Commit

Permalink
Store statement as binary in prepared_statements ETS table
Browse files Browse the repository at this point in the history
So, we can more easily print it
Also, ets-lookup logic would run a bit faster for big iolists
  • Loading branch information
arcusfelis committed Dec 14, 2020
1 parent 7f01379 commit 031e841
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/rdbms/mongoose_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ prepare(Name, Table, [Field | _] = Fields, Statement) when is_atom(Field) ->
prepare(Name, Table, [atom_to_binary(F, utf8) || F <- Fields], Statement);
prepare(Name, Table, Fields, Statement) when is_atom(Name), is_binary(Table) ->
true = lists:all(fun is_binary/1, Fields),
case ets:insert_new(prepared_statements, {Name, Table, Fields, Statement}) of
Tuple = {Name, Table, Fields, iolist_to_binary(Statement)},
case ets:insert_new(prepared_statements, Tuple) of
true -> {ok, Name};
false -> {error, already_exists}
end.
Expand Down

0 comments on commit 031e841

Please sign in to comment.