all repos — honk @ 983340a0a025c7312eac4f4d6b937aa5d6c542d5

my fork of honk

switch database to wal mode
Ted Unangst tedu@tedunangst.com
Tue, 31 May 2022 03:06:09 -0400
commit

983340a0a025c7312eac4f4d6b937aa5d6c542d5

parent

a31965746a02c2171bd39e0db8de1a7227b1f4d7

5 files changed, 22 insertions(+), 4 deletions(-)

jump to
M READMEREADME

@@ -20,7 +20,7 @@

-- build It should be sufficient to type make after unpacking a release. -You'll need a go compiler version 1.13 or later. And libsqlite3. +You'll need a go compiler version 1.16 or later. And libsqlite3. Even on a fast machine, building from source can take several seconds.

@@ -42,7 +42,7 @@ ./honk

-- upgrade -cp honk.db backup.db +old-honk backup `date +backup-%F` ./honk upgrade ./honk
M database.godatabase.go

@@ -19,8 +19,8 @@ import (

"bytes" "crypto/sha512" "database/sql" - "encoding/json" _ "embed" + "encoding/json" "fmt" "html/template" "sort"
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

=== next ++ Switch database to WAL mode. + - go version 1.16 required. + Specify banner: image in profile.
M upgradedb.goupgradedb.go

@@ -22,7 +22,7 @@ "strings"

"time" ) -var myVersion = 40 +var myVersion = 41 type dbexecer interface { Exec(query string, args ...interface{}) (sql.Result, error)

@@ -200,6 +200,12 @@ }

doordie(db, "update config set value = 40 where key = 'dbversion'") fallthrough case 40: + doordie(db, "PRAGMA journal_mode=WAL") + blobdb := openblobdb() + doordie(blobdb, "PRAGMA journal_mode=WAL") + doordie(db, "update config set value = 41 where key = 'dbversion'") + fallthrough + case 41: default: elog.Fatalf("can't upgrade unknown version %d", dbversion)
M util.goutil.go

@@ -100,6 +100,11 @@ os.Remove(dbname)

os.Exit(1) }() + _, err = db.Exec("PRAGMA journal_mode=WAL") + if err != nil { + elog.Print(err) + return + } for _, line := range strings.Split(sqlSchema, ";") { _, err = db.Exec(line) if err != nil {

@@ -172,6 +177,11 @@ if err == nil {

elog.Fatalf("%s already exists", blobdbname) } blobdb, err := sql.Open("sqlite3", blobdbname) + if err != nil { + elog.Print(err) + return + } + _, err = blobdb.Exec("PRAGMA journal_mode=WAL") if err != nil { elog.Print(err) return