threaded sqlite

This commit is contained in:
Max Lapshin
2009-10-14 15:33:01 +04:00
parent 8ec1f1fdad
commit a33403b927
2 changed files with 5 additions and 4 deletions

View File

@@ -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;
} }

View File

@@ -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