forked from MTSR/mapserver
be38c83fd8
* db cleanup * dev * pg setup * postgres uuid migration * cleanup * fk * sqlite migration * cleanup * wal * max open conns = 1 * fix panic --------- Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
25 lines
477 B
Go
25 lines
477 B
Go
package sqlite
|
|
|
|
import (
|
|
"database/sql"
|
|
"errors"
|
|
)
|
|
|
|
func EnableWAL(db *sql.DB) error {
|
|
result := db.QueryRow("pragma journal_mode;")
|
|
var mode string
|
|
err := result.Scan(&mode)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if mode != "wal" {
|
|
_, err = db.Exec("pragma journal_mode = wal;")
|
|
if err != nil {
|
|
return errors.New("couldn't switch the db-journal to wal-mode, please stop the minetest-engine to allow doing this or do it manually: " + err.Error())
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|