MVCC memory VFS. (#309)

This commit is contained in:
Nuno Cruces
2025-08-21 18:44:40 +01:00
committed by GitHub
parent d84ca9d627
commit 0026bc91aa
12 changed files with 565 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ import (
"github.com/ncruces/go-sqlite3/vfs"
_ "github.com/ncruces/go-sqlite3/vfs/adiantum"
"github.com/ncruces/go-sqlite3/vfs/memdb"
"github.com/ncruces/go-sqlite3/vfs/mvcc"
_ "github.com/ncruces/go-sqlite3/vfs/xts"
)
@@ -98,6 +99,22 @@ func Test_memdb(t *testing.T) {
testIntegrity(t, name)
}
func Test_mvcc(t *testing.T) {
var iter int
if testing.Short() {
iter = 1000
} else {
iter = 5000
}
mvcc.Create("test.db", "")
name := "file:/test.db?vfs=mvcc" +
"&_pragma=busy_timeout(10000)"
createDB(t, name)
testParallel(t, name, iter)
testIntegrity(t, name)
}
func Test_adiantum(t *testing.T) {
if !vfs.SupportsFileLocking {
t.Skip("skipping without locks")
@@ -312,6 +329,16 @@ func Benchmark_memdb(b *testing.B) {
testParallel(b, name, b.N)
}
func Benchmark_mvcc(b *testing.B) {
mvcc.Create("test.db", "")
name := "file:/test.db?vfs=mvcc" +
"&_pragma=busy_timeout(10000)"
createDB(b, name)
b.ResetTimer()
testParallel(b, name, b.N)
}
func createDB(t testing.TB, name string) {
db, err := sqlite3.Open(name)
if err != nil {