Changed order of parameters
This commit is contained in:
@@ -812,7 +812,7 @@ esqlite_open(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
|
|||||||
return enif_raise_exception(env, make_atom(env, "not_thread_safe"));
|
return enif_raise_exception(env, make_atom(env, "not_thread_safe"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int size = enif_get_string(env, argv[1], filename, MAX_PATHNAME, ERL_NIF_LATIN1);
|
int size = enif_get_string(env, argv[0], filename, MAX_PATHNAME, ERL_NIF_LATIN1);
|
||||||
if(size <= 0) {
|
if(size <= 0) {
|
||||||
return make_error_tuple(env, "invalid_filename");
|
return make_error_tuple(env, "invalid_filename");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
%% higher-level export
|
%% higher-level export
|
||||||
-export([
|
-export([
|
||||||
open/1, close/1
|
open/1, close/1,
|
||||||
|
prepare/2
|
||||||
|
|
||||||
% set_update_hook/2, set_update_hook/3,
|
% set_update_hook/2, set_update_hook/3,
|
||||||
% exec/2, exec/3, exec/4,
|
% exec/2, exec/3, exec/4,
|
||||||
@@ -27,7 +28,6 @@
|
|||||||
% insert/2, insert/3,
|
% insert/2, insert/3,
|
||||||
% last_insert_rowid/1,
|
% last_insert_rowid/1,
|
||||||
% get_autocommit/1, get_autocommit/2,
|
% get_autocommit/1, get_autocommit/2,
|
||||||
% prepare/2, prepare/3,
|
|
||||||
% step/1, step/2,
|
% step/1, step/2,
|
||||||
% reset/1,
|
% reset/1,
|
||||||
% bind/2, bind/3,
|
% bind/2, bind/3,
|
||||||
@@ -160,7 +160,8 @@ close(#esqlite3{db=Connection}) ->
|
|||||||
%%q(Sql, Args, Connection) ->
|
%%q(Sql, Args, Connection) ->
|
||||||
% q(Sql, Args, Connection, ?DEFAULT_TIMEOUT).
|
% q(Sql, Args, Connection, ?DEFAULT_TIMEOUT).
|
||||||
%
|
%
|
||||||
%%% @doc Execute statement, bind args and return a list with tuples as result restricted by timeout.
|
|
||||||
|
%% @doc Execute statement, bind args and return a list with tuples as result restricted by timeout.
|
||||||
%-spec q(sql(), list(), connection(), timeout()) -> list(row()) | {error, _}.
|
%-spec q(sql(), list(), connection(), timeout()) -> list(row()) | {error, _}.
|
||||||
%q(Sql, [], Connection, Timeout) ->
|
%q(Sql, [], Connection, Timeout) ->
|
||||||
% case prepare(Sql, Connection, Timeout) of
|
% case prepare(Sql, Connection, Timeout) of
|
||||||
@@ -376,18 +377,27 @@ close(#esqlite3{db=Connection}) ->
|
|||||||
% ok = esqlite3_nif:get_autocommit(RawConnection, Ref, self()),
|
% ok = esqlite3_nif:get_autocommit(RawConnection, Ref, self()),
|
||||||
% receive_answer(RawConnection, Ref, Timeout).
|
% receive_answer(RawConnection, Ref, Timeout).
|
||||||
%
|
%
|
||||||
|
|
||||||
%% @doc Compile a SQL statement. Returns a cached compiled statement which can be used in
|
%% @doc Compile a SQL statement. Returns a cached compiled statement which can be used in
|
||||||
%% queries.
|
%% queries.
|
||||||
%%
|
%%
|
||||||
%-spec prepare(sql(), connection()) -> {ok, statement()} | {error, _}.
|
-spec prepare(Connection, Sql) -> PrepareResult
|
||||||
%prepare(Sql, Connection) ->
|
when Connection :: esqlite3(),
|
||||||
% prepare(Sql, Connection, ?DEFAULT_TIMEOUT).
|
Sql :: sql(),
|
||||||
|
PrepareResult :: {ok, esqlite3_stmt()} | {error, _}.
|
||||||
|
prepare(#esqlite3{db=Connection}, Sql) ->
|
||||||
|
case esqlite3_nif:prepare(Connection, Sql) of
|
||||||
|
{ok, Stmt} ->
|
||||||
|
{ok, #esqlite3_stmt{db=Connection, stmt=Stmt}};
|
||||||
|
{error, _}=Error ->
|
||||||
|
Error
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
%% @doc Like prepare/2, but with an extra timeout value.
|
%% @doc Like prepare/2, but with an extra timeout value.
|
||||||
%-spec prepare(sql(), connection(), timeout()) -> {ok, statement()} | {error, _}.
|
%-spec prepare(sql(), connection(), timeout()) -> {ok, statement()} | {error, _}.
|
||||||
%prepare(Sql, #connection{raw_connection=RawConnection}, Timeout) ->
|
%prepare(Sql, #connection{raw_connection=RawConnection}, Timeout) ->
|
||||||
% Ref = make_ref(),
|
% Ref = make_ref(),
|
||||||
% ok = esqlite3_nif:prepare(RawConnection, Ref, self(), Sql),
|
|
||||||
% case receive_answer(RawConnection, Ref, Timeout) of
|
% case receive_answer(RawConnection, Ref, Timeout) of
|
||||||
% {ok, Stmt} when is_reference(Stmt) ->
|
% {ok, Stmt} when is_reference(Stmt) ->
|
||||||
% {ok, #statement{raw_statement=Stmt, raw_connection=RawConnection}};
|
% {ok, #statement{raw_statement=Stmt, raw_connection=RawConnection}};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user