Commit 28bfee41 authored by gwenn's avatar gwenn

Clean up.

parent 23b5fbc2
......@@ -103,11 +103,11 @@ func (r *BlobReader) Read(v []byte) (int, error) {
if r.offset >= size {
return 0, io.EOF
}
if len(v) > (size - r.offset) {
v = v[0 : size-r.offset]
n := size - r.offset
if len(v) < n {
n = len(v)
}
p := &v[0]
n := len(v)
rv := C.sqlite3_blob_read(r.bl, unsafe.Pointer(p), C.int(n), C.int(r.offset))
if rv != C.SQLITE_OK {
return 0, r.c.error(rv, "BlobReader.Read")
......@@ -131,7 +131,7 @@ func (r *BlobReader) Seek(offset int64, whence int) (int64, error) {
}
r.offset = size + int(offset)
default:
return 0, r.c.specificError("Bad seekMode")
return 0, r.c.specificError("Bad seekMode: %d", whence)
}
return int64(r.offset), nil
}
......@@ -162,12 +162,13 @@ func (w *BlobReadWriter) Write(v []byte) (int, error) {
return 0, io.EOF
}
/* Write must return a non-nil error if it returns n < len(v) */
if len(v) > (size - w.offset) {
v = v[0 : size-w.offset]
n := size - w.offset
if len(v) <= n {
n = len(v)
} else {
err = io.EOF
}
p := &v[0]
n := len(v)
rv := C.sqlite3_blob_write(w.bl, unsafe.Pointer(p), C.int(n), C.int(w.offset))
if rv != C.SQLITE_OK {
return 0, w.c.error(rv, "BlobReadWiter.Write")
......
......@@ -70,7 +70,7 @@ func TestBusyTimeout(t *testing.T) {
checkNoError(t, db1.BeginTransaction(Exclusive), "couldn't begin transaction: %s")
//join := make(chan bool)
checkNoError(t, db2.BusyTimeout(time.Duration(500)*time.Millisecond), "couldn't set busy timeout: %s")
checkNoError(t, db2.BusyTimeout(500*time.Millisecond), "couldn't set busy timeout: %s")
go func() {
time.Sleep(time.Millisecond)
db1.Rollback()
......
......@@ -51,7 +51,7 @@ func (d *impl) Open(name string) (driver.Conn, error) {
if err != nil {
return nil, err
}
c.BusyTimeout(time.Duration(10) * time.Second)
c.BusyTimeout(10 * time.Second)
return &conn{c}, nil
}
......
......@@ -263,7 +263,7 @@ func (c *Conn) Indexes(dbName, table string) ([]Index, error) {
}
// IndexColumns returns one description for each column in the named index.
// Only Column.Cid and Column.Name are specified. All other fields are unspecifed.
// Only Column.Cid and Column.Name are specified. All other fields are unspecified.
// (See http://www.sqlite.org/pragma.html#pragma_index_info)
func (c *Conn) IndexColumns(dbName, index string) ([]Column, error) {
var pragma string
......
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