From 21936b7804855c041b7833be36d79a4b2f3ee0af Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Sat, 23 Jan 2021 11:09:51 -0400 Subject: [PATCH] sqlite3.go: use PRAGMA to set busy_timeout The busy_timeout pragma was added in sqlite 3.7.15 as an alternative to calling sqlite3_busy_timeout directly: https://sqlite.org/pragma.html#pragma_busy_timeout While there's no functional change here, using the pragma does align setting busy_timeout with other settings and removes the special case for calling sqlite3_busy_timeout directly. --- sqlite3.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 552a2ab2..6b1399e4 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1409,12 +1409,6 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { return nil, errors.New("sqlite succeeded without returning a database") } - rv = C.sqlite3_busy_timeout(db, C.int(busyTimeout)) - if rv != C.SQLITE_OK { - C.sqlite3_close_v2(db) - return nil, Error{Code: ErrNo(rv)} - } - exec := func(s string) error { cs := C.CString(s) rv := C.sqlite3_exec(db, cs, nil, nil, nil) @@ -1425,6 +1419,12 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { return nil } + // Busy timeout + if err := exec(fmt.Sprintf("PRAGMA busy_timeout = %d;", busyTimeout)); err != nil { + C.sqlite3_close_v2(db) + return nil, err + } + // USER AUTHENTICATION // // User Authentication is always performed even when