Support OTP R13B.
Remove use of R13B04 features.
This commit is contained in:
@@ -318,7 +318,9 @@ static inline int decode_and_bind_param(
|
||||
result = sqlite3_bind_int64(statement, param_index, int64_val);
|
||||
break;
|
||||
case ERL_FLOAT_EXT:
|
||||
#ifdef NEW_FLOAT_EXT
|
||||
case NEW_FLOAT_EXT: // what's the difference?
|
||||
#endif
|
||||
ei_decode_double(buffer, p_index, &double_val);
|
||||
result = sqlite3_bind_double(statement, param_index, double_val);
|
||||
break;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
-ifdef(DEBUG).
|
||||
-include_lib("eunit/include/eunit.hrl"). %% for debugging macros
|
||||
-define(dbg(Message), ?debugMsg(Message)).
|
||||
-define(dbg(Format, Data), ?debugFmt(Format, Data)).
|
||||
-define(dbgF(Format, Data), ?debugFmt(Format, Data)).
|
||||
-define(dbgVal(Expr), ?debugVal(Expr)).
|
||||
-define(dbgTime(Text, Expr), ?debugTime(Text, Expr)).
|
||||
-else.
|
||||
-define(dbg(_Message), ok).
|
||||
-define(dbg(_Format, _Data), ok).
|
||||
-define(dbgF(_Format, _Data), ok).
|
||||
-define(dbgVal(Expr), Expr).
|
||||
-define(dbgTime(_Text, Expr), Expr).
|
||||
%% -ifdef(TEST).
|
||||
|
||||
@@ -1062,15 +1062,15 @@ do_handle_call_sql_exec(SQL, State) ->
|
||||
{reply, Reply, State}.
|
||||
|
||||
do_sql_exec(SQL, #state{port = Port}) ->
|
||||
?dbg("SQL: ~s~n", [SQL]),
|
||||
?dbgF("SQL: ~s~n", [SQL]),
|
||||
exec(Port, {sql_exec, SQL}).
|
||||
|
||||
do_sql_bind_and_exec(SQL, Params, #state{port = Port}) ->
|
||||
?dbg("SQL: ~s; Parameters: ~p~n", [SQL, Params]),
|
||||
?dbgF("SQL: ~s; Parameters: ~p~n", [SQL, Params]),
|
||||
exec(Port, {sql_bind_and_exec, SQL, Params}).
|
||||
|
||||
do_sql_exec_script(SQL, #state{port = Port}) ->
|
||||
?dbg("SQL: ~s~n", [SQL]),
|
||||
?dbgF("SQL: ~s~n", [SQL]),
|
||||
exec(Port, {sql_exec_script, SQL}).
|
||||
|
||||
exec(_Port, {create_function, _FunctionName, _Function}) ->
|
||||
|
||||
@@ -358,7 +358,7 @@ sql_number(NumberStr) ->
|
||||
sql_string(StringWithEscapedQuotes) ->
|
||||
Res1 = re:replace(StringWithEscapedQuotes, "''", "'",
|
||||
[global, {return, binary}]),
|
||||
binary_part(Res1, 0, byte_size(Res1) - 1).
|
||||
erlang:binary_part(Res1, 0, byte_size(Res1) - 1).
|
||||
|
||||
-spec sql_blob(string()) -> binary().
|
||||
sql_blob([$' | Tail]) -> hex_str_to_bin(Tail, <<>>).
|
||||
|
||||
@@ -120,10 +120,10 @@ parametrized() ->
|
||||
sqlite3:sql_exec(ct, "INSERT INTO user1 (id, name) VALUES (?, ?)", [{1, 1}, {2, "john"}]),
|
||||
sqlite3:sql_exec(ct, "INSERT INTO user1 (id, name) VALUES (?3, ?5)", [{3, 2}, {5, "joe"}]),
|
||||
sqlite3:sql_exec(ct, "INSERT INTO user1 (id, name) VALUES (:id, @name)", [{":id", 3}, {'@name', <<"jack">>}]),
|
||||
sqlite3:sql_exec(ct, "INSERT INTO user1 (id, name) VALUES (?, ?)", [4294967295, "james"]),
|
||||
sqlite3:sql_exec(ct, "INSERT INTO user1 (id, name) VALUES (?, ?)", [4, "james"]),
|
||||
?assertEqual(
|
||||
[{columns, ["id", "name"]},
|
||||
{rows, [{1, <<"john">>}, {2, <<"joe">>}, {3, <<"jack">>}, {4294967295, <<"james">>}]}],
|
||||
{rows, [{1, <<"john">>}, {2, <<"joe">>}, {3, <<"jack">>}, {4, <<"james">>}]}],
|
||||
sqlite3:read_all(ct, user1)),
|
||||
sqlite3:drop_table(ct, user1),
|
||||
sqlite3:create_table(ct, user1, [{i, integer}, {d, double}, {b, blob}]),
|
||||
|
||||
Reference in New Issue
Block a user