Last active
July 19, 2020 15:02
-
-
Save djoyner/0133a23000d3ebd3b5421f975c4c2fbb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"database/sql" | |
"log" | |
_ "github.com/mattn/go-sqlite3" | |
) | |
// Fails with: | |
// | |
// * github.com/mattn/go-sqlite3:master (aa77c03e2fcb7ed283920d09a0fb6b873488b5be) | |
// * github.com/mattn/go-sqlite3:v2.0.6 | |
// * github.com/mattn/go-sqlite3:v1.14.0 | |
// | |
// Works with: | |
// | |
// * github.com/mattn/go-sqlite3:3fa1c550ffa69b74dc4bfd5109b4e218f32c87cf | |
// * github.com/azavorotnii/go-sqlite3:ctx_cancel | |
// | |
func main() { | |
db, err := sql.Open("sqlite3", "file:test.sqlite?mode=rwc&cache=private&auto_vacuum=none") | |
if err != nil { | |
log.Fatal(err) | |
} | |
for i := 1; ; i++ { | |
ctx, cancelFunc := context.WithCancel(context.Background()) | |
go cancelFunc() | |
log.Printf("%d: BEGIN", i) | |
tx, err := db.BeginTx(ctx, nil) | |
if err != nil && err != context.Canceled { | |
log.Fatalf("%d: %s", i, err.Error()) | |
} else if tx != nil { | |
tx.Rollback() | |
} | |
log.Printf("%d: VACUUM", i) | |
if _, err = db.Exec("VACUUM"); err != nil { | |
log.Fatalf("%d: %s", i, err.Error()) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment