Skip _vector_chunks rename for non-FLAT vec0 columns (#294)

vec0Rename emits an unconditional ALTER TABLE on `<name>_vector_chunks%02d`
for every vector column, but non-FLAT columns (rescore, IVF, DiskANN) don't
create that shadow table — so ALTER TABLE RENAME on a DiskANN-indexed (or
rescore/IVF) vec0 table fails with `no such table` and leaves any cached
prepared statements still referencing the old name.

Mirror the guard already used at create time in vec0_init around
VEC0_SHADOW_VECTOR_N_CREATE: only rename `_vector_chunks` when the column's
index_type is VEC0_INDEX_TYPE_FLAT.

Adds a regression test exercising rename on a DiskANN-indexed table.
This commit is contained in:
Rolf Rando 2026-05-17 22:56:52 -07:00 committed by GitHub
parent 5778fecfeb
commit 8105eee61e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 3 deletions

View file

@ -10435,9 +10435,13 @@ static int vec0Rename(sqlite3_vtab *pVtab, const char *zNew) {
// Per-vector-column shadow tables
for (int i = 0; i < p->numVectorColumns; i++) {
sqlite3_str_appendf(s,
"ALTER TABLE \"%w\".\"%w_vector_chunks%02d\" RENAME TO \"%w_vector_chunks%02d\";",
p->schemaName, p->tableName, i, zNew, i);
// Non-FLAT columns (rescore, IVF, DiskANN) don't create _vector_chunks
// (mirror the guard in vec0_init around VEC0_SHADOW_VECTOR_N_CREATE).
if (p->vector_columns[i].index_type == VEC0_INDEX_TYPE_FLAT) {
sqlite3_str_appendf(s,
"ALTER TABLE \"%w\".\"%w_vector_chunks%02d\" RENAME TO \"%w_vector_chunks%02d\";",
p->schemaName, p->tableName, i, zNew, i);
}
#if SQLITE_VEC_ENABLE_RESCORE
if (p->shadowRescoreChunksNames[i]) {