Reject rowid-changing updates on virtual tables

This commit is contained in:
Yasuhiro Matsumoto
2026-07-29 13:14:19 +09:00
parent 1a1bc9e778
commit 726af39fbd
2 changed files with 21 additions and 2 deletions

View File

@@ -609,8 +609,14 @@ func goVUpdate(pVTab unsafe.Pointer, argc C.int, argv **C.sqlite3_value, pRowid
case argc > 1:
// Per the xUpdate contract argv[0] identifies the row being
// updated while argv[1] is its (possibly changed) new rowid.
err = v.Update(vals[0], vals[2:])
// updated while argv[1] is its new rowid. VTabUpdater has no
// way to convey a rowid change, so reject it instead of
// silently updating values under the old rowid.
if vals[0] != vals[1] {
err = fmt.Errorf("virtual %s table %sdoes not support changing the rowid", vt.module.name, tname)
} else {
err = v.Update(vals[0], vals[2:])
}
}
}