Commit f794138c authored by gwenn's avatar gwenn

Introduces time.Duration

parent e74a43c4
...@@ -68,7 +68,7 @@ func TestBusyTimeout(t *testing.T) { ...@@ -68,7 +68,7 @@ func TestBusyTimeout(t *testing.T) {
checkNoError(t, db1.BeginTransaction(Exclusive), "couldn't begin transaction: %s") checkNoError(t, db1.BeginTransaction(Exclusive), "couldn't begin transaction: %s")
//join := make(chan bool) //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() { go func() {
time.Sleep(time.Millisecond) time.Sleep(time.Millisecond)
db1.Rollback() db1.Rollback()
......
...@@ -11,6 +11,7 @@ import ( ...@@ -11,6 +11,7 @@ import (
"io" "io"
"log" "log"
"os" "os"
"time"
) )
func init() { func init() {
...@@ -49,7 +50,7 @@ func (d *Driver) Open(name string) (driver.Conn, error) { ...@@ -49,7 +50,7 @@ func (d *Driver) Open(name string) (driver.Conn, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
c.BusyTimeout(10000) c.BusyTimeout(time.Duration(10) * time.Second)
return &connImpl{c}, nil return &connImpl{c}, nil
} }
......
...@@ -23,6 +23,7 @@ import ( ...@@ -23,6 +23,7 @@ import (
"fmt" "fmt"
"io" "io"
"reflect" "reflect"
"time"
"unsafe" "unsafe"
) )
...@@ -242,8 +243,9 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error) ...@@ -242,8 +243,9 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error)
// BusyTimeout sets a busy timeout. // BusyTimeout sets a busy timeout.
// (See http://sqlite.org/c3ref/busy_timeout.html) // (See http://sqlite.org/c3ref/busy_timeout.html)
func (c *Conn) BusyTimeout(ms int) error { // TODO time.Duration ? func (c *Conn) BusyTimeout(d time.Duration) error {
return c.error(C.sqlite3_busy_timeout(c.db, C.int(ms)), "Conn.BusyTimeout") 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. // 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