close some queries when done
Ted Unangst tedu@tedunangst.com
Sun, 16 Jun 2019 21:21:56 -0400
M
honk.go
→
honk.go
@@ -391,6 +391,7 @@ if err != nil {
log.Printf("query err: %s", err) return } + defer rows.Close() for rows.Next() { var s string rows.Scan(&s)@@ -1123,13 +1124,13 @@ Wherefore string
} func zonkzone(w http.ResponseWriter, r *http.Request) { - db := opendatabase() userinfo := login.GetUserInfo(r) - rows, err := db.Query("select zonkerid, name, wherefore from zonkers where userid = ?", userinfo.UserID) + rows, err := stmtGetZonkers.Query(userinfo.UserID) if err != nil { log.Printf("err: %s", err) return } + defer rows.Close() var zonkers []Zonker for rows.Next() { var z Zonker@@ -1428,7 +1429,7 @@ var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt
var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt -var stmtRecentHonkers, stmtGetXonker, stmtSaveXonker *sql.Stmt +var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker *sql.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s)@@ -1474,6 +1475,7 @@ stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")
stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zurl' or wherefore = 'zword')") + stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ?") stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)") stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?") stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)")