mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-24 16:26:37 +02:00
properly check SQLITE_THREADSAFE for static compilation
This commit is contained in:
parent
ad5510d2fa
commit
a6498d04b8
3 changed files with 32 additions and 21 deletions
12
sqlite-vec.c
12
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 @@ cleanup:
|
|||
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 @@ complete:
|
|||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_CORE -DSQLITE_ENABLE_JSON1 \
|
||||
-I dist/sqlite-amalgamation-3310100 \
|
||||
-I ../../ \
|
||||
$< dist/sqlite-amalgamation-3310100/sqlite3.c \
|
||||
../../sqlite-vec.c \
|
||||
-o $@
|
||||
|
||||
test:
|
||||
make dist/t3310100
|
||||
dist/t3310100-threadsafe: demo.c dist/sqlite-amalgamation-3310100/.stamp ../../sqlite-vec.c
|
||||
gcc \
|
||||
-lm \
|
||||
-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: dist/t3310100 dist/t3310100-threadsafe
|
||||
./dist/t3310100
|
||||
./dist/t3310100-threadsafe
|
||||
|
||||
clean:
|
||||
rm -rf dist/
|
||||
|
|
|
|||
|
|
@ -9,17 +9,18 @@ int main(int argc, char *argv[]) {
|
|||
sqlite3 *db;
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
rc = sqlite3_auto_extension((void (*)())sqlite3_vec_init);
|
||||
assert(rc == SQLITE_OK);
|
||||
|
||||
rc = sqlite3_open(":memory:", &db);
|
||||
assert(rc == SQLITE_OK);
|
||||
|
||||
rc = sqlite3_prepare_v2(db, "SELECT sqlite_version(), vec_version()", -1, &stmt, NULL);
|
||||
rc = sqlite3_vec_init(db, NULL, NULL);
|
||||
assert(rc == SQLITE_OK);
|
||||
|
||||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue