Commit f794138c authored by gwenn's avatar gwenn

Introduces time.Duration

parent e74a43c4
......@@ -68,7 +68,7 @@ func TestBusyTimeout(t *testing.T) {
checkNoError(t, db1.BeginTransaction(Exclusive), "couldn't begin transaction: %s")
//join := make(chan bool)
checkNoError(t, db2.BusyTimeout(500), "couldn't set busy timeout: %s")
checkNoError(t, db2.BusyTimeout(time.Duration(500)*time.Millisecond), "couldn't set busy timeout: %s")
go func() {
time.Sleep(time.Millisecond)
db1.Rollback()
......
......@@ -11,6 +11,7 @@ import (
"io"
"log"
"os"
"time"
)
func init() {
......@@ -49,7 +50,7 @@ func (d *Driver) Open(name string) (driver.Conn, error) {
if err != nil {
return nil, err
}
c.BusyTimeout(10000)
c.BusyTimeout(time.Duration(10) * time.Second)
return &connImpl{c}, nil
}
......
......@@ -23,6 +23,7 @@ import (
"fmt"
"io"
"reflect"
"time"
"unsafe"
)
......@@ -242,8 +243,9 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error)
// BusyTimeout sets a busy timeout.
// (See http://sqlite.org/c3ref/busy_timeout.html)
func (c *Conn) BusyTimeout(ms int) error { // TODO time.Duration ?
return c.error(C.sqlite3_busy_timeout(c.db, C.int(ms)), "Conn.BusyTimeout")
func (c *Conn) BusyTimeout(d time.Duration) error {
c.busyHandler = nil
return c.error(C.sqlite3_busy_timeout(c.db, C.int(d/time.Millisecond)), "Conn.BusyTimeout")
}
// EnableFKey enables or disables the enforcement of foreign key constraints.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment