Skip to content

Commit 3bb6941

Browse files
authored
sqlite3.go: use PRAGMA to set busy_timeout (#910)
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.
1 parent ab65367 commit 3bb6941

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sqlite3.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,12 +1415,6 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
14151415
return nil, errors.New("sqlite succeeded without returning a database")
14161416
}
14171417

1418-
rv = C.sqlite3_busy_timeout(db, C.int(busyTimeout))
1419-
if rv != C.SQLITE_OK {
1420-
C.sqlite3_close_v2(db)
1421-
return nil, Error{Code: ErrNo(rv)}
1422-
}
1423-
14241418
exec := func(s string) error {
14251419
cs := C.CString(s)
14261420
rv := C.sqlite3_exec(db, cs, nil, nil, nil)
@@ -1431,6 +1425,12 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
14311425
return nil
14321426
}
14331427

1428+
// Busy timeout
1429+
if err := exec(fmt.Sprintf("PRAGMA busy_timeout = %d;", busyTimeout)); err != nil {
1430+
C.sqlite3_close_v2(db)
1431+
return nil, err
1432+
}
1433+
14341434
// USER AUTHENTICATION
14351435
//
14361436
// User Authentication is always performed even when

0 commit comments

Comments
 (0)