mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-05-18 13:55:18 +02:00
Rename all IVF shadow tables in vec0Rename
vec0Rename only emitted ALTER TABLE on `<name>_ivf_cells%02d`, so renaming an IVF-indexed vec0 table left `_ivf_centroids`, `_ivf_rowid_map`, and `_ivf_vectors` (when quantizer != none) with the old prefix. Subsequent queries against the renamed table broke, and DROP TABLE left those three shadows orphaned in the schema. Same shape as the DiskANN/rescore bug fixed in #294, just for the IVF branch. Mirror ivf_create_shadow_tables: emit ALTER for all four IVF shadows, gating `_ivf_vectors` on quantizer != VEC0_IVF_QUANTIZER_NONE. Adds test-ivf-rename.py (auto-skipped on default builds via conftest's test-ivf prefix rule) covering quantizer=none, quantizer=binary, and DROP-after-rename. Also adds a rescore rename regression test to test-rename.py to lock down the (already-correct) rescore path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8105eee61e
commit
8b81f40d1e
3 changed files with 144 additions and 0 deletions
13
sqlite-vec.c
13
sqlite-vec.c
|
|
@ -10472,9 +10472,22 @@ static int vec0Rename(sqlite3_vtab *pVtab, const char *zNew) {
|
|||
#if SQLITE_VEC_EXPERIMENTAL_IVF_ENABLE
|
||||
for (int i = 0; i < p->numVectorColumns; i++) {
|
||||
if (p->shadowIvfCellsNames[i]) {
|
||||
sqlite3_str_appendf(s,
|
||||
"ALTER TABLE \"%w\".\"%w_ivf_centroids%02d\" RENAME TO \"%w_ivf_centroids%02d\";",
|
||||
p->schemaName, p->tableName, i, zNew, i);
|
||||
sqlite3_str_appendf(s,
|
||||
"ALTER TABLE \"%w\".\"%w_ivf_cells%02d\" RENAME TO \"%w_ivf_cells%02d\";",
|
||||
p->schemaName, p->tableName, i, zNew, i);
|
||||
sqlite3_str_appendf(s,
|
||||
"ALTER TABLE \"%w\".\"%w_ivf_rowid_map%02d\" RENAME TO \"%w_ivf_rowid_map%02d\";",
|
||||
p->schemaName, p->tableName, i, zNew, i);
|
||||
// _ivf_vectors is only created when quantizer != none
|
||||
// (mirror ivf_create_shadow_tables in sqlite-vec-ivf.c).
|
||||
if (p->vector_columns[i].ivf.quantizer != VEC0_IVF_QUANTIZER_NONE) {
|
||||
sqlite3_str_appendf(s,
|
||||
"ALTER TABLE \"%w\".\"%w_ivf_vectors%02d\" RENAME TO \"%w_ivf_vectors%02d\";",
|
||||
p->schemaName, p->tableName, i, zNew, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue