Merge pull request #28 from project-fifo/master
rebar3 and SmartOS compatibility
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ priv
|
|||||||
*.o
|
*.o
|
||||||
*~
|
*~
|
||||||
_build
|
_build
|
||||||
|
c_src/*.d
|
||||||
|
|||||||
10
rebar.config
10
rebar.config
@@ -4,8 +4,18 @@
|
|||||||
{"darwin", "DRV_LDFLAGS",
|
{"darwin", "DRV_LDFLAGS",
|
||||||
"-flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
"-flat_namespace -undefined suppress $ERL_LDFLAGS"},
|
||||||
|
|
||||||
|
{"solaris", "CFLAGS",
|
||||||
|
"-std=c99"},
|
||||||
|
|
||||||
{"CFLAGS", "$CFLAGS -DSQLITE_THREADSAFE=1 -DSQLITE_USE_URI -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS"}
|
{"CFLAGS", "$CFLAGS -DSQLITE_THREADSAFE=1 -DSQLITE_USE_URI -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS"}
|
||||||
]}.
|
]}.
|
||||||
{port_specs, [
|
{port_specs, [
|
||||||
{"priv/esqlite3_nif.so", ["c_src/esqlite3_nif.c", "c_src/queue.c", "c_src/sqlite3.c"]}
|
{"priv/esqlite3_nif.so", ["c_src/esqlite3_nif.c", "c_src/queue.c", "c_src/sqlite3.c"]}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
{plugins, [pc]}.
|
||||||
|
|
||||||
|
{provider_hooks,
|
||||||
|
[{post,
|
||||||
|
[{compile, {pc, compile}},
|
||||||
|
{clean, {pc, clean}}]}]}.
|
||||||
|
|||||||
1
rebar.lock
Normal file
1
rebar.lock
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[].
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{application, esqlite,
|
{application, esqlite,
|
||||||
[
|
[
|
||||||
{description, "sqlite nif interface"},
|
{description, "sqlite nif interface"},
|
||||||
{vsn, "1"},
|
{vsn, "0.1.1"},
|
||||||
{modules, [esqlite3, esqlite3_nif]},
|
{modules, [esqlite3, esqlite3_nif]},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|||||||
@@ -172,18 +172,25 @@ fetchone(Statement) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
%%
|
%%
|
||||||
-spec fetchall(statement()) -> list(tuple()).
|
-spec fetchall(statement()) ->
|
||||||
|
list(tuple()) |
|
||||||
|
{error, term()}.
|
||||||
fetchall(Statement) ->
|
fetchall(Statement) ->
|
||||||
case try_step(Statement, 0) of
|
case try_step(Statement, 0) of
|
||||||
'$done' ->
|
'$done' ->
|
||||||
[];
|
[];
|
||||||
{error, _} = E -> E;
|
{error, _} = E -> E;
|
||||||
{row, Row} ->
|
{row, Row} ->
|
||||||
[Row | fetchall(Statement)]
|
case fetchall(Statement) of
|
||||||
|
{error, _} = E -> E;
|
||||||
|
Rest -> [Row | Rest]
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Try the step, when the database is busy,
|
%% Try the step, when the database is busy,
|
||||||
-spec try_step(statement(), non_neg_integer()) -> term().
|
-spec try_step(statement(), non_neg_integer()) ->
|
||||||
|
'$done' |
|
||||||
|
term().
|
||||||
try_step(_Statement, Tries) when Tries > 5 ->
|
try_step(_Statement, Tries) when Tries > 5 ->
|
||||||
throw(too_many_tries);
|
throw(too_many_tries);
|
||||||
try_step(Statement, Tries) ->
|
try_step(Statement, Tries) ->
|
||||||
@@ -267,6 +274,7 @@ step(Stmt) ->
|
|||||||
%% @doc
|
%% @doc
|
||||||
%%
|
%%
|
||||||
%% @spec step(prepared_statement(), timeout()) -> tuple()
|
%% @spec step(prepared_statement(), timeout()) -> tuple()
|
||||||
|
-spec step(term(), timeout()) -> tuple() | '$busy' | '$done'.
|
||||||
step(Stmt, Timeout) ->
|
step(Stmt, Timeout) ->
|
||||||
Ref = make_ref(),
|
Ref = make_ref(),
|
||||||
ok = esqlite3_nif:step(Stmt, Ref, self()),
|
ok = esqlite3_nif:step(Stmt, Ref, self()),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ init() ->
|
|||||||
%%
|
%%
|
||||||
%% @spec start() -> {ok, connection()} | {error, msg()}
|
%% @spec start() -> {ok, connection()} | {error, msg()}
|
||||||
start() ->
|
start() ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Open the specified sqlite3 database.
|
%% @doc Open the specified sqlite3 database.
|
||||||
%%
|
%%
|
||||||
@@ -58,8 +58,9 @@ start() ->
|
|||||||
%% ok immediately. When the database is opened
|
%% ok immediately. When the database is opened
|
||||||
%%
|
%%
|
||||||
%% @spec open(connection(), reference(), pid(), string()) -> ok | {error, message()}
|
%% @spec open(connection(), reference(), pid(), string()) -> ok | {error, message()}
|
||||||
|
|
||||||
open(_Db, _Ref, _Dest, _Filename) ->
|
open(_Db, _Ref, _Dest, _Filename) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Exec the query.
|
%% @doc Exec the query.
|
||||||
%%
|
%%
|
||||||
@@ -71,7 +72,7 @@ open(_Db, _Ref, _Dest, _Filename) ->
|
|||||||
%%
|
%%
|
||||||
%% @spec exec(connection(), Ref::reference(), Dest::pid(), string()) -> ok | {error, message()}
|
%% @spec exec(connection(), Ref::reference(), Dest::pid(), string()) -> ok | {error, message()}
|
||||||
exec(_Db, _Ref, _Dest, _Sql) ->
|
exec(_Db, _Ref, _Dest, _Sql) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Get the number of affected rows of last statement
|
%% @doc Get the number of affected rows of last statement
|
||||||
%%
|
%%
|
||||||
@@ -79,62 +80,59 @@ exec(_Db, _Ref, _Dest, _Sql) ->
|
|||||||
%% with answer() integer | {error, reason()}
|
%% with answer() integer | {error, reason()}
|
||||||
%%
|
%%
|
||||||
changes(_Db, _Ref, _Dest) ->
|
changes(_Db, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%%
|
%%
|
||||||
%% @spec prepare(connection(), reference(), pid(), string()) -> ok | {error, message()}
|
%% @spec prepare(connection(), reference(), pid(), string()) -> ok | {error, message()}
|
||||||
prepare(_Db, _Ref, _Dest, _Sql) ->
|
prepare(_Db, _Ref, _Dest, _Sql) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%%
|
%%
|
||||||
%% @spec step(statement(), reference(), pid()) -> ok | {error, message()}
|
%% @spec step(statement(), reference(), pid()) -> ok | {error, message()}
|
||||||
step(_Stmt, _Ref, _Dest) ->
|
step(_Stmt, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%%
|
%%
|
||||||
%% @spec reset(statement(), reference(), pid()) -> ok | {error, message()}
|
%% @spec reset(statement(), reference(), pid()) -> ok | {error, message()}
|
||||||
reset(_Stmt, _Ref, _Dest) ->
|
reset(_Stmt, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc
|
%% @doc
|
||||||
%%
|
%%
|
||||||
%%
|
%%
|
||||||
finalize(_Stmt, _Ref, _Dest) ->
|
finalize(_Stmt, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Bind parameters to a prepared statement.
|
%% @doc Bind parameters to a prepared statement.
|
||||||
%%
|
%%
|
||||||
%% @spec bind(statement(), reference(), pid(), []) -> ok | {error, message()}
|
%% @spec bind(statement(), reference(), pid(), []) -> ok | {error, message()}
|
||||||
bind(_Stmt, _Ref, _Dest, _Args) ->
|
bind(_Stmt, _Ref, _Dest, _Args) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Retrieve the column names of the prepared statement
|
%% @doc Retrieve the column names of the prepared statement
|
||||||
%%
|
%%
|
||||||
%% @spec column_names(statement(), reference(), pid()) -> {ok, tuple()} | {error, message()}
|
%% @spec column_names(statement(), reference(), pid()) -> {ok, tuple()} | {error, message()}
|
||||||
column_names(_Stmt, _Ref, _Dest) ->
|
column_names(_Stmt, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Retrieve the column types of the prepared statement
|
%% @doc Retrieve the column types of the prepared statement
|
||||||
%%
|
%%
|
||||||
%% @spec column_types(statement(), reference(), pid()) -> {ok, tuple()} | {error, message()}
|
%% @spec column_types(statement(), reference(), pid()) -> {ok, tuple()} | {error, message()}
|
||||||
column_types(_Stmt, _Ref, _Dest) ->
|
column_types(_Stmt, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
%% @doc Close the connection.
|
%% @doc Close the connection.
|
||||||
%%
|
%%
|
||||||
%% @spec close(connection(), reference(), pid()) -> ok | {error, message()}
|
%% @spec close(connection(), reference(), pid()) -> ok | {error, message()}
|
||||||
close(_Db, _Ref, _Dest) ->
|
close(_Db, _Ref, _Dest) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
|
|
||||||
%% @doc Insert record
|
%% @doc Insert record
|
||||||
%%
|
%%
|
||||||
%% @spec insert(connection(), Ref::reference(), Dest::pid(), string()) -> {ok, integer()} | {error, message()}
|
%% @spec insert(connection(), Ref::reference(), Dest::pid(), string()) -> {ok, integer()} | {error, message()}
|
||||||
insert(_Db, _Ref, _Dest, _Sql) ->
|
insert(_Db, _Ref, _Dest, _Sql) ->
|
||||||
exit(nif_library_not_loaded).
|
erlang:nif_error(nif_library_not_loaded).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user