strange error with multiple active transactions
db opened via test.db?cache=shared&mode=memory
fmt.Printf("main tx\n")
tx, err := wdb.BeginTx(ctx, nil)
if err != nil {
t.Fatal(err)
}
fmt.Printf("schema create\n")
if _, err := tx.ExecContext(wrapper.QueryName(ctx, "schema create"), schema); err != nil {
t.Fatal(err)
}
fmt.Printf("schema commit\n")
if err := tx.Commit(); err != nil {
t.Fatal(err)
}
fmt.Printf("begintx1\n")
tx1, err := wdb.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted})
if err != nil {
t.Fatal(err)
}
fmt.Printf("begintx2\n")
tx2, err := wdb.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted})
if err != nil {
t.Fatal(err)
}
fmt.Printf("exec1\n")
if _, err := tx1.ExecContext(wrapper.QueryName(ctx, "insert one"), "INSERT INTO person (first_name, last_name, email) VALUES ($1, $2, $3)", "Fist1", "Last1", "Email1"); e
rr != nil {
t.Fatal(err)
}
fmt.Printf("exec none\n")
if _, err := wdb.ExecContext(wrapper.QueryName(ctx, "double schema"), schema); err != nil {
t.Fatal(err)
}
fmt.Printf("exec2\n")
if _, err := tx2.ExecContext(wrapper.QueryName(ctx, "insert two"), "INSERT INTO person (first_name, last_name, email) VALUES ($1, $2, $3)", "Fist2", "Last2", "Email2"); e
rr != nil {
t.Fatal(err)
}
fmt.Printf("commit1\n")
if err := tx1.Commit(); err != nil {
t.Fatal(err)
}
fmt.Printf("commit2\n")
if err := tx2.Commit(); err != nil {
t.Fatal(err)
}
i get error after exec2 printed
database is locked (5) (SQLITE_BUSY)
Edited by Vasiliy Tolstov