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
|
|
@ -191,6 +191,39 @@ def test_rename_diskann(db):
|
|||
assert _shadow_tables(db, "v") == []
|
||||
|
||||
|
||||
def test_rename_rescore(db):
|
||||
"""Rename should work on rescore-indexed tables (no _vector_chunks shadow)."""
|
||||
db.execute("""
|
||||
CREATE VIRTUAL TABLE v USING vec0(
|
||||
a float[8] indexed by rescore(quantizer=bit)
|
||||
)
|
||||
""")
|
||||
db.execute("insert into v(rowid, a) values (1, ?)", [_f32([0.1] * 8)])
|
||||
db.execute("insert into v(rowid, a) values (2, ?)", [_f32([0.9] * 8)])
|
||||
|
||||
# Rescore columns use _rescore_chunks / _rescore_vectors instead of
|
||||
# _vector_chunks; the rename must skip the missing _vector_chunks ALTER
|
||||
# and rename both rescore shadow tables.
|
||||
before = _shadow_tables(db, "v")
|
||||
assert "v_rescore_chunks00" in before
|
||||
assert "v_rescore_vectors00" in before
|
||||
assert "v_vector_chunks00" not in before
|
||||
|
||||
db.execute("ALTER TABLE v RENAME TO v2")
|
||||
|
||||
rows = db.execute(
|
||||
"select rowid from v2 where a match ? and k=10",
|
||||
[_f32([0.1] * 8)],
|
||||
).fetchall()
|
||||
assert rows[0][0] == 1
|
||||
|
||||
after = _shadow_tables(db, "v2")
|
||||
assert "v2_rescore_chunks00" in after
|
||||
assert "v2_rescore_vectors00" in after
|
||||
assert "v2_vector_chunks00" not in after
|
||||
assert _shadow_tables(db, "v") == []
|
||||
|
||||
|
||||
def test_rename_drop_after(db):
|
||||
"""DROP TABLE should work on a renamed table."""
|
||||
db.execute("create virtual table v using vec0(a float[2], chunk_size=8)")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue