Using version 23d646f
With the program below, the function that uses Pool leaves behind WAL files after the pool is closed. It is almost as if the Conn is not getting closed, but that doesn't make sense, because Pool definitely closes its Conns.
package main
import (
"fmt""os""crawshaw.io/sqlite""crawshaw.io/sqlite/sqlitex"
)
constdbSchema=`CREATE TABLE IF NOT EXISTS foobars (id INTEGER PRIMARY KEY AUTOINCREMENT);INSERT INTO foobars values (NULL);`funcmain() {
err:=initDBWithPool("pool.db")
iferr!=nil {
fmt.Fprintf(os.Stderr, "pool: %v\n", err)
os.Exit(1)
}
err=initDBWithConn("conn.db")
iferr!=nil {
fmt.Fprintf(os.Stderr, "conn: %v\n", err)
os.Exit(1)
}
}
funcinitDBWithConn(pathstring) (errerror) {
conn, err:=sqlite.OpenConn(path, sqlite.OpenFlagsDefault)
iferr!=nil {
returnerr
}
deferfunc() {
closeErr:=conn.Close()
iferr==nil {
err=closeErr
}
}()
returnsqlitex.ExecScript(conn, dbSchema)
}
funcinitDBWithPool(pathstring) (errerror) {
pool, err:=sqlitex.Open(path, sqlite.OpenFlagsDefault, 1)
iferr!=nil {
returnerr
}
deferfunc() {
closeErr:=pool.Close()
iferr==nil {
err=closeErr
}
}()
conn:=pool.Get(nil)
deferpool.Put(conn)
returnsqlitex.ExecScript(conn, dbSchema)
}$ ls -1
conn.db
pool.db
pool.db-shm
pool.db-wal
Using version 23d646f
With the program below, the function that uses Pool leaves behind WAL files after the pool is closed. It is almost as if the Conn is not getting closed, but that doesn't make sense, because Pool definitely closes its Conns.