Summary
Loading the sqlite-vec extension into a libsql database works, and a vec0 virtual table can be created, inserted into, and counted — but the KNN search query (... WHERE embedding MATCH ? ORDER BY distance) panics the native driver with called Option::unwrap() on a None value, aborting the process. This is the one operation that makes a vector extension useful, so sqlite-vec is effectively unusable via libsql.
Reproduced on both the latest stable libsql@0.5.29 and the latest prerelease libsql@0.6.0-pre.41.
Environment
libsql: 0.5.29 (and 0.6.0-pre.41)
sqlite-vec: 0.1.9
- Node.js:
v25.8.0
- OS: macOS, arm64
Minimal reproduction
const Database = require('libsql');
const sqliteVec = require('sqlite-vec');
const db = new Database(':memory:');
sqliteVec.load(db);
console.log(db.prepare('select vec_version() v').get()); // ✓ works
db.exec('CREATE VIRTUAL TABLE t USING vec0(embedding float[4])'); // ✓ works
const f = a => Buffer.from(new Float32Array(a).buffer);
db.prepare('INSERT INTO t(rowid, embedding) VALUES (?, ?)').run(1n, f([1, 0, 0, 0])); // ✓ works
console.log(db.prepare('SELECT count(*) c FROM t').get()); // ✓ works -> { c: 1 }
// ✗ PANICS:
db.prepare('SELECT rowid, distance FROM t WHERE embedding MATCH ? ORDER BY distance LIMIT 1')
.all(f([1, 0, 0, 0]));
Expected
The KNN query returns the nearest rows with their distance values (as it does under better-sqlite3 with the same extension).
Actual
thread '<unnamed>' panicked at src/statement.rs:396:62:
called `Option::unwrap()` on a `None` value
On 0.6.0-pre.41 the same query panics at src/lib.rs:1354:58 (fatal runtime error: failed to initiate panic, error 5, aborting).
Notes
load / CREATE VIRTUAL TABLE vec0 / INSERT / SELECT count(*) all succeed — only the vec0 KNN result (which surfaces the hidden distance column via the MATCH constraint) fails. The panic looks like the driver assuming column metadata that a vec0 virtual-table result doesn't provide.
- The identical extension + query works under
better-sqlite3.
- A
panic::catch_unwind (or graceful SqliteError) instead of an unwrap() would at least keep it recoverable, but the underlying goal is to read vec0 KNN results.
Summary
Loading the
sqlite-vecextension into alibsqldatabase works, and avec0virtual table can be created, inserted into, and counted — but the KNN search query (... WHERE embedding MATCH ? ORDER BY distance) panics the native driver withcalled Option::unwrap() on a None value, aborting the process. This is the one operation that makes a vector extension useful, sosqlite-vecis effectively unusable vialibsql.Reproduced on both the latest stable
libsql@0.5.29and the latest prereleaselibsql@0.6.0-pre.41.Environment
libsql:0.5.29(and0.6.0-pre.41)sqlite-vec:0.1.9v25.8.0Minimal reproduction
Expected
The KNN query returns the nearest rows with their
distancevalues (as it does underbetter-sqlite3with the same extension).Actual
On
0.6.0-pre.41the same query panics atsrc/lib.rs:1354:58(fatal runtime error: failed to initiate panic, error 5, aborting).Notes
load/CREATE VIRTUAL TABLE vec0/INSERT/SELECT count(*)all succeed — only thevec0KNN result (which surfaces the hiddendistancecolumn via theMATCHconstraint) fails. The panic looks like the driver assuming column metadata that avec0virtual-table result doesn't provide.better-sqlite3.panic::catch_unwind(or gracefulSqliteError) instead of anunwrap()would at least keep it recoverable, but the underlying goal is to readvec0KNN results.