threaded sqlite
This commit is contained in:
@@ -111,11 +111,11 @@ static int sql_exec(sqlite3_drv_t *drv, char *command, int command_size) {
|
|||||||
|
|
||||||
// fprintf(stderr, "Driver async: %d %p\n", SQLITE_VERSION_NUMBER, async_command->statement);
|
// fprintf(stderr, "Driver async: %d %p\n", SQLITE_VERSION_NUMBER, async_command->statement);
|
||||||
|
|
||||||
if (1) {
|
if (sqlite3_threadsafe()) {
|
||||||
|
drv->async_handle = driver_async(drv->port, &drv->key, sql_exec_async, async_command, sql_free_async);
|
||||||
|
} else {
|
||||||
sql_exec_async(async_command);
|
sql_exec_async(async_command);
|
||||||
ready_async((ErlDrvData)drv, (ErlDrvThreadData)async_command);
|
ready_async((ErlDrvData)drv, (ErlDrvThreadData)async_command);
|
||||||
} else {
|
|
||||||
drv->async_handle = driver_async(drv->port, &drv->key, sql_exec_async, async_command, sql_free_async);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
3
test.erl
3
test.erl
@@ -18,7 +18,8 @@ test() ->
|
|||||||
sqlite3:delete(ct, user, {name, "abby"}),
|
sqlite3:delete(ct, user, {name, "abby"}),
|
||||||
sqlite3:drop_table(ct, user),
|
sqlite3:drop_table(ct, user),
|
||||||
%sqlite3:delete_db(ct)
|
%sqlite3:delete_db(ct)
|
||||||
sqlite3:close(ct).
|
sqlite3:close(ct),
|
||||||
|
io:format("Tests passed~n").
|
||||||
|
|
||||||
main(_) ->
|
main(_) ->
|
||||||
try test() of
|
try test() of
|
||||||
|
|||||||
Reference in New Issue
Block a user