From d89dbcf9a12e675d0ed8c9d4d5e82344ad450984 Mon Sep 17 00:00:00 2001 From: Aaron Paterson Date: Fri, 23 Oct 2026 01:50:15 -0500 Subject: [PATCH] fix(sqlite-vec.c): mark the init functions' pApi unused under SQLITE_CORE Compiled with -DSQLITE_CORE, as when sqlite-vec.c is built into SQLite or an application, sqlite3_vec_init(), sqlite3_vec_numpy_init() and sqlite3_vec_static_blobs_init() never read their pApi parameter, since SQLITE_EXTENSION_INIT2() is its only use and SQLITE_CORE leaves it out. With -Wall -Wextra each of them warns: gcc -Ivendor -Wall -Wextra -DSQLITE_CORE -DSQLITE_VEC_STATIC \ -c sqlite-vec.c -o vec.o sqlite-vec.c:12525:65: warning: unused parameter 'pApi' sqlite-vec.c:12610:71: warning: unused parameter 'pApi' sqlite-vec.c:12629:59: warning: unused parameter 'pApi' Each now marks it with UNUSED_PARAMETER() in that case, as two of them do for pzErrMsg. The command prints no warning with gcc 14.2 or clang 19.1, and the loadable extension, built without SQLITE_CORE, is unchanged. --- CHANGELOG.md | 1 + sqlite-vec.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da5f90d1..a5012afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixed +- Compiling `sqlite-vec.c` into SQLite or an application (`-DSQLITE_CORE`) with `-Wall -Wextra` builds without warnings; `sqlite3_vec_init()`, `sqlite3_vec_numpy_init()`, and `sqlite3_vec_static_blobs_init()` each warned that their `pApi` parameter was unused. - A KNN query that takes its query vector, `k`, or `mmr_lambda` from another table of a join now uses it. `select v.rowid from p join v on v.embedding match ? and v.k = p.k` failed with `A LIMIT or 'k = ?' constraint is required`; the same join with `v.k = 3 and v.mmr_lambda = p.lambda` returned no rows; and `select v.rowid from v join p on p.id = v.tag where v.embedding match p.vector and v.k = 2`, with `p.id` an integer primary key, could return no rows. These joins now run one KNN per row of the other table, so a filter on the `vec0` table whose value comes from that table applies before the k nearest rows are chosen. Ported in part from the unmerged [vlasky#14](https://github.com/vlasky/sqlite-vec/pull/14) ([asg017#331](https://github.com/asg017/sqlite-vec/pull/331)), which also applies filters whose value comes from a joined table before the k nearest rows are chosen; that part is not ported, and ARCHITECTURE.md's idxStr section says why. ## [2.1.1] - 2026-10-09 diff --git a/sqlite-vec.c b/sqlite-vec.c index 429b475d..15718fb1 100644 --- a/sqlite-vec.c +++ b/sqlite-vec.c @@ -12525,6 +12525,8 @@ SQLITE_VEC_API int sqlite3_vec_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) { #ifndef SQLITE_CORE SQLITE_EXTENSION_INIT2(pApi); +#else + UNUSED_PARAMETER(pApi); #endif int rc = SQLITE_OK; @@ -12611,6 +12613,8 @@ SQLITE_VEC_API int sqlite3_vec_numpy_init(sqlite3 *db, char **pzErrMsg, UNUSED_PARAMETER(pzErrMsg); #ifndef SQLITE_CORE SQLITE_EXTENSION_INIT2(pApi); +#else + UNUSED_PARAMETER(pApi); #endif int rc = SQLITE_OK; rc = sqlite3_create_function_v2(db, "vec_npy_file", 1, SQLITE_RESULT_SUBTYPE, @@ -12630,6 +12634,8 @@ sqlite3_vec_static_blobs_init(sqlite3 *db, char **pzErrMsg, UNUSED_PARAMETER(pzErrMsg); #ifndef SQLITE_CORE SQLITE_EXTENSION_INIT2(pApi); +#else + UNUSED_PARAMETER(pApi); #endif int rc = SQLITE_OK;