diff --git a/sqlite-vec.c b/sqlite-vec.c index c2dfee9..e2944ee 100644 --- a/sqlite-vec.c +++ b/sqlite-vec.c @@ -3608,7 +3608,7 @@ int vec0_rowids_insert_rowid(vec0_vtab *p, i64 rowid) { } } -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_enter) { sqlite3_mutex_enter(sqlite3_db_mutex(p->db)); entered = 1; @@ -3640,7 +3640,7 @@ int vec0_rowids_insert_rowid(vec0_vtab *p, i64 rowid) { sqlite3_clear_bindings(p->stmtRowidsInsertRowid); } -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_leave && entered) { sqlite3_mutex_leave(sqlite3_db_mutex(p->db)); } @@ -3670,7 +3670,7 @@ int vec0_rowids_insert_id(vec0_vtab *p, sqlite3_value *idValue, i64 *rowid) { } } -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_enter) { sqlite3_mutex_enter(sqlite3_db_mutex(p->db)); entered = 1; @@ -3707,7 +3707,7 @@ int vec0_rowids_insert_id(vec0_vtab *p, sqlite3_value *idValue, i64 *rowid) { sqlite3_clear_bindings(p->stmtRowidsInsertId); } -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_leave && entered) { sqlite3_mutex_leave(sqlite3_db_mutex(p->db)); } @@ -3795,7 +3795,7 @@ int vec0_new_chunk(vec0_vtab *p, i64 *chunk_rowid) { return rc; } -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_enter) { sqlite3_mutex_enter(sqlite3_db_mutex(p->db)); } @@ -3808,7 +3808,7 @@ int vec0_new_chunk(vec0_vtab *p, i64 *chunk_rowid) { rc = sqlite3_step(stmt); int failed = rc != SQLITE_DONE; rowid = sqlite3_last_insert_rowid(p->db); -#ifdef SQLITE_THREADSAFE +#if SQLITE_THREADSAFE if (sqlite3_mutex_leave) { sqlite3_mutex_leave(sqlite3_db_mutex(p->db)); } diff --git a/tests/minimum/Makefile b/tests/minimum/Makefile index 7c86851..76a6f1e 100644 --- a/tests/minimum/Makefile +++ b/tests/minimum/Makefile @@ -1,27 +1,37 @@ -#curl -q -o sqlite-amalgamation-3310100.zip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip -#unzip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip - -dist/: +dist/.stammp: mkdir -p dist touch $@ -dist/sqlite-amalgamation-3310100: dist/ - rm -rf sqlite-amalgamation-3310100/ || true +dist/sqlite-amalgamation-3310100/.stamp: dist/.stammp + rm -rf dist/sqlite-amalgamation-3310100/ || true curl -q -o sqlite-amalgamation-3310100.zip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip unzip -d dist/ sqlite-amalgamation-3310100.zip rm sqlite-amalgamation-3310100.zip touch $@ -dist/t3310100: demo.c dist/sqlite-amalgamation-3310100 +dist/t3310100: demo.c dist/sqlite-amalgamation-3310100/.stamp ../../sqlite-vec.c + gcc \ + -lm \ + -DSQLITE_CORE -DSQLITE_ENABLE_JSON1 \ + -I dist/sqlite-amalgamation-3310100 \ + -I ../../ \ + $< dist/sqlite-amalgamation-3310100/sqlite3.c \ + ../../sqlite-vec.c \ + -o $@ + +dist/t3310100-threadsafe: demo.c dist/sqlite-amalgamation-3310100/.stamp ../../sqlite-vec.c gcc \ -lm \ - -DSQLITE_CORE \ + -DSQLITE_CORE -DSQLITE_ENABLE_JSON1 -DSQLITE_THREADSAFE=0 \ -I dist/sqlite-amalgamation-3310100 \ -I ../../ \ $< dist/sqlite-amalgamation-3310100/sqlite3.c \ ../../sqlite-vec.c \ -o $@ -test: - make dist/t3310100 +test: dist/t3310100 dist/t3310100-threadsafe ./dist/t3310100 + ./dist/t3310100-threadsafe + +clean: + rm -rf dist/ diff --git a/tests/minimum/demo.c b/tests/minimum/demo.c index d67b10d..7faebfa 100644 --- a/tests/minimum/demo.c +++ b/tests/minimum/demo.c @@ -9,17 +9,18 @@ int main(int argc, char *argv[]) { sqlite3 *db; sqlite3_stmt *stmt; - rc = sqlite3_auto_extension((void (*)())sqlite3_vec_init); + rc = sqlite3_open(":memory:", &db); assert(rc == SQLITE_OK); - rc = sqlite3_open(":memory:", &db); + rc = sqlite3_vec_init(db, NULL, NULL); assert(rc == SQLITE_OK); - rc = sqlite3_prepare_v2(db, "SELECT sqlite_version(), vec_version()", -1, &stmt, NULL); + + rc = sqlite3_prepare_v2(db, "SELECT sqlite_version(), vec_version(), (select json_group_array(compile_options) from pragma_compile_options)", -1, &stmt, NULL); assert(rc == SQLITE_OK); rc = sqlite3_step(stmt); - printf("sqlite_version=%s, vec_version=%s\n", sqlite3_column_text(stmt, 0), sqlite3_column_text(stmt, 1)); + printf("sqlite_version=%s, vec_version=%s %s\n", sqlite3_column_text(stmt, 0), sqlite3_column_text(stmt, 1), sqlite3_column_text(stmt, 2)); sqlite3_finalize(stmt); sqlite3_close(db); return 0;