mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +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) {
|
if (sqlite3_mutex_enter) {
|
||||||
sqlite3_mutex_enter(sqlite3_db_mutex(p->db));
|
sqlite3_mutex_enter(sqlite3_db_mutex(p->db));
|
||||||
entered = 1;
|
entered = 1;
|
||||||
|
|
@ -3640,7 +3640,7 @@ cleanup:
|
||||||
sqlite3_clear_bindings(p->stmtRowidsInsertRowid);
|
sqlite3_clear_bindings(p->stmtRowidsInsertRowid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
if (sqlite3_mutex_leave && entered) {
|
if (sqlite3_mutex_leave && entered) {
|
||||||
sqlite3_mutex_leave(sqlite3_db_mutex(p->db));
|
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) {
|
if (sqlite3_mutex_enter) {
|
||||||
sqlite3_mutex_enter(sqlite3_db_mutex(p->db));
|
sqlite3_mutex_enter(sqlite3_db_mutex(p->db));
|
||||||
entered = 1;
|
entered = 1;
|
||||||
|
|
@ -3707,7 +3707,7 @@ complete:
|
||||||
sqlite3_clear_bindings(p->stmtRowidsInsertId);
|
sqlite3_clear_bindings(p->stmtRowidsInsertId);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
if (sqlite3_mutex_leave && entered) {
|
if (sqlite3_mutex_leave && entered) {
|
||||||
sqlite3_mutex_leave(sqlite3_db_mutex(p->db));
|
sqlite3_mutex_leave(sqlite3_db_mutex(p->db));
|
||||||
}
|
}
|
||||||
|
|
@ -3795,7 +3795,7 @@ int vec0_new_chunk(vec0_vtab *p, i64 *chunk_rowid) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SQLITE_THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
if (sqlite3_mutex_enter) {
|
if (sqlite3_mutex_enter) {
|
||||||
sqlite3_mutex_enter(sqlite3_db_mutex(p->db));
|
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);
|
rc = sqlite3_step(stmt);
|
||||||
int failed = rc != SQLITE_DONE;
|
int failed = rc != SQLITE_DONE;
|
||||||
rowid = sqlite3_last_insert_rowid(p->db);
|
rowid = sqlite3_last_insert_rowid(p->db);
|
||||||
#ifdef SQLITE_THREADSAFE
|
#if SQLITE_THREADSAFE
|
||||||
if (sqlite3_mutex_leave) {
|
if (sqlite3_mutex_leave) {
|
||||||
sqlite3_mutex_leave(sqlite3_db_mutex(p->db));
|
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
|
dist/.stammp:
|
||||||
#unzip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip
|
|
||||||
|
|
||||||
dist/:
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
dist/sqlite-amalgamation-3310100: dist/
|
dist/sqlite-amalgamation-3310100/.stamp: dist/.stammp
|
||||||
rm -rf sqlite-amalgamation-3310100/ || true
|
rm -rf dist/sqlite-amalgamation-3310100/ || true
|
||||||
curl -q -o sqlite-amalgamation-3310100.zip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip
|
curl -q -o sqlite-amalgamation-3310100.zip https://www.sqlite.org/2020/sqlite-amalgamation-3310100.zip
|
||||||
unzip -d dist/ sqlite-amalgamation-3310100.zip
|
unzip -d dist/ sqlite-amalgamation-3310100.zip
|
||||||
rm sqlite-amalgamation-3310100.zip
|
rm sqlite-amalgamation-3310100.zip
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
dist/t3310100: demo.c dist/sqlite-amalgamation-3310100
|
dist/t3310100: demo.c dist/sqlite-amalgamation-3310100/.stamp ../../sqlite-vec.c
|
||||||
gcc \
|
gcc \
|
||||||
-lm \
|
-lm \
|
||||||
-DSQLITE_CORE \
|
-DSQLITE_CORE -DSQLITE_ENABLE_JSON1 \
|
||||||
-I dist/sqlite-amalgamation-3310100 \
|
-I dist/sqlite-amalgamation-3310100 \
|
||||||
-I ../../ \
|
-I ../../ \
|
||||||
$< dist/sqlite-amalgamation-3310100/sqlite3.c \
|
$< dist/sqlite-amalgamation-3310100/sqlite3.c \
|
||||||
../../sqlite-vec.c \
|
../../sqlite-vec.c \
|
||||||
-o $@
|
-o $@
|
||||||
|
|
||||||
test:
|
dist/t3310100-threadsafe: demo.c dist/sqlite-amalgamation-3310100/.stamp ../../sqlite-vec.c
|
||||||
make dist/t3310100
|
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
|
||||||
|
./dist/t3310100-threadsafe
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf dist/
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,18 @@ int main(int argc, char *argv[]) {
|
||||||
sqlite3 *db;
|
sqlite3 *db;
|
||||||
sqlite3_stmt *stmt;
|
sqlite3_stmt *stmt;
|
||||||
|
|
||||||
rc = sqlite3_auto_extension((void (*)())sqlite3_vec_init);
|
|
||||||
assert(rc == SQLITE_OK);
|
|
||||||
|
|
||||||
rc = sqlite3_open(":memory:", &db);
|
rc = sqlite3_open(":memory:", &db);
|
||||||
assert(rc == SQLITE_OK);
|
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);
|
assert(rc == SQLITE_OK);
|
||||||
|
|
||||||
rc = sqlite3_step(stmt);
|
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_finalize(stmt);
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue