Commit e8891f64 authored by gwenn's avatar gwenn

Fix error type.

parent ecae65ef
......@@ -19,7 +19,7 @@ import (
)
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit
func NewBackup(dst *Conn, dstTable string, src *Conn, srcTable string) (*Backup, os.Error) {
func NewBackup(dst *Conn, dstTable string, src *Conn, srcTable string) (*Backup, error) {
dname := C.CString(dstTable)
sname := C.CString(srcTable)
defer C.free(unsafe.Pointer(dname))
......@@ -38,7 +38,7 @@ type Backup struct {
}
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep
func (b *Backup) Step(npage int) os.Error {
func (b *Backup) Step(npage int) error {
rv := C.sqlite3_backup_step(b.sb, C.int(npage))
if rv == C.SQLITE_OK || Errno(rv) == ErrBusy || Errno(rv) == ErrLocked {
return nil
......@@ -57,8 +57,8 @@ func (b *Backup) Status() BackupStatus {
}
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep, sqlite3_backup_remaining and sqlite3_backup_pagecount
func (b *Backup) Run(npage int, sleepNs int64, c chan<- BackupStatus) os.Error {
var err os.Error
func (b *Backup) Run(npage int, sleepNs int64, c chan<- BackupStatus) error {
var err error
for {
err = b.Step(npage)
if err != nil {
......@@ -73,7 +73,7 @@ func (b *Backup) Run(npage int, sleepNs int64, c chan<- BackupStatus) os.Error {
}
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish
func (b *Backup) Close() os.Error {
func (b *Backup) Close() error {
if b.sb == nil {
return os.EINVAL
}
......
......@@ -13,7 +13,7 @@ package sqlite
import "C"
import (
"os"
"errors"
"unsafe"
)
......@@ -29,7 +29,7 @@ type BlobReadWriter struct {
type ZeroBlobLength int
// Calls http://sqlite.org/c3ref/blob_open.html
func (c *Conn) NewBlobReader(db, table, column string, row int64) (*BlobReader, os.Error) {
func (c *Conn) NewBlobReader(db, table, column string, row int64) (*BlobReader, error) {
bl, err := c.blob_open(db, table, column, row, false)
if err != nil {
return nil, err
......@@ -38,7 +38,7 @@ func (c *Conn) NewBlobReader(db, table, column string, row int64) (*BlobReader,
}
// Calls http://sqlite.org/c3ref/blob_open.html
func (c *Conn) NewBlobReadWriter(db, table, column string, row int64) (*BlobReadWriter, os.Error) {
func (c *Conn) NewBlobReadWriter(db, table, column string, row int64) (*BlobReadWriter, error) {
bl, err := c.blob_open(db, table, column, row, true)
if err != nil {
return nil, err
......@@ -46,7 +46,7 @@ func (c *Conn) NewBlobReadWriter(db, table, column string, row int64) (*BlobRead
return &BlobReadWriter{BlobReader{c, bl}}, nil
}
func (c *Conn) blob_open(db, table, column string, row int64, write bool) (*C.sqlite3_blob, os.Error) {
func (c *Conn) blob_open(db, table, column string, row int64, write bool) (*C.sqlite3_blob, error) {
zDb := C.CString(db)
defer C.free(unsafe.Pointer(zDb))
zTable := C.CString(table)
......@@ -62,13 +62,13 @@ func (c *Conn) blob_open(db, table, column string, row int64, write bool) (*C.sq
return nil, c.error(rv)
}
if bl == nil {
return nil, os.NewError("sqlite succeeded without returning a blob")
return nil, errors.New("sqlite succeeded without returning a blob")
}
return bl, nil
}
// Calls http://sqlite.org/c3ref/blob_close.html
func (r *BlobReader) Close() os.Error {
func (r *BlobReader) Close() error {
rv := C.sqlite3_blob_close(r.bl)
if rv != C.SQLITE_OK {
return r.c.error(rv)
......@@ -78,7 +78,7 @@ func (r *BlobReader) Close() os.Error {
}
// Calls http://sqlite.org/c3ref/blob_read.html
func (r *BlobReader) Read(v []byte) (int, os.Error) {
func (r *BlobReader) Read(v []byte) (int, error) {
var p *byte
if len(v) > 0 {
p = &v[0]
......@@ -91,13 +91,13 @@ func (r *BlobReader) Read(v []byte) (int, os.Error) {
}
// Calls http://sqlite.org/c3ref/blob_bytes.html
func (r *BlobReader) Size() (int, os.Error) {
func (r *BlobReader) Size() (int, error) {
s := C.sqlite3_blob_bytes(r.bl)
return int(s), nil
}
// Calls http://sqlite.org/c3ref/blob_write.html
func (w *BlobReadWriter) Write(v []byte) (int, os.Error) {
func (w *BlobReadWriter) Write(v []byte) (int, error) {
var p *byte
if len(v) > 0 {
p = &v[0]
......@@ -110,7 +110,7 @@ func (w *BlobReadWriter) Write(v []byte) (int, os.Error) {
}
// Calls http://sqlite.org/c3ref/blob_reopen.html
func (r *BlobReader) Reopen(rowid int64) os.Error {
func (r *BlobReader) Reopen(rowid int64) error {
rv := C.sqlite3_blob_reopen(r.bl, C.sqlite3_int64(rowid))
if rv != C.SQLITE_OK {
return r.c.error(rv)
......
......@@ -17,13 +17,10 @@ static char *my_mprintf(char *zFormat, char *arg) {
*/
import "C"
import (
"os"
"unsafe"
)
import "unsafe"
// Executes pragma 'database_list'
func (c *Conn) Databases() (map[string]string, os.Error) {
func (c *Conn) Databases() (map[string]string, error) {
s, err := c.Prepare("PRAGMA database_list")
if err != nil {
return nil, err
......@@ -46,7 +43,7 @@ func (c *Conn) Databases() (map[string]string, os.Error) {
}
// Selects tables (no view) from 'sqlite_master' and filters system tables out.
func (c *Conn) Tables() ([]string, os.Error) {
func (c *Conn) Tables() ([]string, error) {
s, err := c.Prepare("SELECT name FROM sqlite_master WHERE type IN ('table') AND name NOT LIKE 'sqlite_%'")
if err != nil {
return nil, err
......@@ -77,7 +74,7 @@ type Column struct {
// Executes pragma 'table_info'
// TODO How to specify a database-name?
// TODO sqlite3_table_column_metadata?
func (c *Conn) Columns(table string) ([]Column, os.Error) {
func (c *Conn) Columns(table string) ([]Column, error) {
s, err := c.Prepare(Mprintf("PRAGMA table_info(%Q)", table))
if err != nil {
return nil, err
......@@ -107,7 +104,7 @@ type ForeignKey struct {
// Executes pragma 'foreign_key_list'
// TODO How to specify a database-name?
func (c *Conn) ForeignKeys(table string) (map[int]*ForeignKey, os.Error) {
func (c *Conn) ForeignKeys(table string) (map[int]*ForeignKey, error) {
s, err := c.Prepare(Mprintf("PRAGMA foreign_key_list(%Q)", table))
if err != nil {
return nil, err
......@@ -144,7 +141,7 @@ type Index struct {
// Executes pragma 'index_list'
// TODO How to specify a database-name?
func (c *Conn) Indexes(table string) ([]Index, os.Error) {
func (c *Conn) Indexes(table string) ([]Index, error) {
s, err := c.Prepare(Mprintf("PRAGMA index_list(%Q)", table))
if err != nil {
return nil, err
......@@ -168,7 +165,7 @@ func (c *Conn) Indexes(table string) ([]Index, os.Error) {
// Executes pragma 'index_info'
// Only Column.Cid and Column.Name are specified. All other fields are unspecifed.
func (c *Conn) IndexColumns(index string) ([]Column, os.Error) {
func (c *Conn) IndexColumns(index string) ([]Column, error) {
s, err := c.Prepare(Mprintf("PRAGMA index_info(%Q)", index))
if err != nil {
return nil, err
......
This diff is collapsed.
......@@ -46,10 +46,7 @@ static void my_log(int iErrCode, char *msg) {
*/
import "C"
import (
"os"
"unsafe"
)
import "unsafe"
type Tracer func(udp interface{}, sql string)
......@@ -162,7 +159,7 @@ func goXAuth(udp unsafe.Pointer, action C.int, arg1, arg2, dbName, triggerName *
}
// Calls http://sqlite.org/c3ref/set_authorizer.html
func (c *Conn) SetAuthorizer(f Authorizer, udp interface{}) os.Error {
func (c *Conn) SetAuthorizer(f Authorizer, udp interface{}) error {
if f == nil {
c.authorizer = nil
return c.error(C.sqlite3_set_authorizer(c.db, nil, nil))
......@@ -188,7 +185,7 @@ func goXBusy(udp unsafe.Pointer, count C.int) C.int {
// TODO NOT TESTED
// Calls http://sqlite.org/c3ref/busy_handler.html
func (c *Conn) BusyHandler(f BusyHandler, udp interface{}) os.Error {
func (c *Conn) BusyHandler(f BusyHandler, udp interface{}) error {
if f == nil {
c.busyHandler = nil
return c.error(C.sqlite3_busy_handler(c.db, nil, nil))
......
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