Use sqlite3_close_v2, it automatically closes the db after the last statement finishes

This commit is contained in:
Maas-Maarten Zeeman
2014-06-16 16:42:25 +02:00
parent 2a5c521cda
commit d0fb9156a8

View File

@@ -225,7 +225,7 @@ destruct_esqlite_connection(ErlNifEnv *env, void *arg)
queue_destroy(db->commands); queue_destroy(db->commands);
if(db->db) if(db->db)
sqlite3_close(db->db); sqlite3_close_v2(db->db);
} }
static void static void
@@ -258,7 +258,7 @@ do_open(ErlNifEnv *env, esqlite_connection *db, const ERL_NIF_TERM arg)
rc = sqlite3_open(filename, &db->db); rc = sqlite3_open(filename, &db->db);
if(rc != SQLITE_OK) { if(rc != SQLITE_OK) {
error = make_sqlite3_error_tuple(env, rc, db->db); error = make_sqlite3_error_tuple(env, rc, db->db);
sqlite3_close(db->db); sqlite3_close_v2(db->db);
db->db = NULL; db->db = NULL;
return error; return error;
@@ -544,7 +544,7 @@ do_close(ErlNifEnv *env, esqlite_connection *conn, const ERL_NIF_TERM arg)
{ {
int rc; int rc;
rc = sqlite3_close(conn->db); rc = sqlite3_close_v2(conn->db);
if(rc != SQLITE_OK) if(rc != SQLITE_OK)
return make_sqlite3_error_tuple(env, rc, conn->db); return make_sqlite3_error_tuple(env, rc, conn->db);