Commit 1febd6dc authored by gwenn's avatar gwenn

Golint comments and govet printf.

parent 7e0fdf5c
......@@ -36,7 +36,7 @@ func NewBackup(dst *Conn, dstDbName string, src *Conn, srcDbName string) (*Backu
return &Backup{sb, dst, src}, nil
}
// Online backup
// The Backup object records state information about an ongoing online backup operation.
// (See http://sqlite.org/c3ref/backup.html)
type Backup struct {
sb *C.sqlite3_backup
......@@ -56,7 +56,7 @@ func (b *Backup) Step(npage int) error {
return Errno(rv)
}
// Backup progression
// BackupStatus reports backup progression
type BackupStatus struct {
Remaining int
PageCount int
......
......@@ -31,7 +31,7 @@ type BlobReadWriter struct {
BlobReader
}
// Zeroblobs are used to reserve space for a BLOB that is later written.
// ZeroBlobLength is used to reserve space for a BLOB that is later written.
type ZeroBlobLength int
// NewBlobReader opens a BLOB for incremental I/O in read-only mode.
......
......@@ -41,6 +41,7 @@ func JulianDay(t time.Time) float64 {
// UnixTime is an alias used to persist time as int64 (max precision is 1s and timezone is lost) (default)
type UnixTime time.Time
// Scan implements the database/sql/Scanner interface.
func (t *UnixTime) Scan(src interface{}) error {
if src == nil {
//t = nil
......@@ -51,6 +52,8 @@ func (t *UnixTime) Scan(src interface{}) error {
}
return fmt.Errorf("Unsupported UnixTime src: %T", src)
}
// Value implements the database/sql/driver/Valuer interface
func (t UnixTime) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() {
return nil, nil
......@@ -61,6 +64,7 @@ func (t UnixTime) Value() (driver.Value, error) {
// JulianTime is an alias used to persist time as float64 (max precision is 1s and timezone is lost)
type JulianTime time.Time
// Scan implements the database/sql/Scanner interface.
func (t *JulianTime) Scan(src interface{}) error {
if src == nil {
//t = nil
......@@ -71,6 +75,8 @@ func (t *JulianTime) Scan(src interface{}) error {
}
return fmt.Errorf("Unsupported JulianTime src: %T", src)
}
// Value implements the database/sql/driver/Valuer interface
func (t JulianTime) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() {
return nil, nil
......@@ -81,6 +87,7 @@ func (t JulianTime) Value() (driver.Value, error) {
// TimeStamp is an alias used to persist time as '2006-01-02T15:04:05.999Z07:00' string
type TimeStamp time.Time
// Scan implements the database/sql/Scanner interface.
func (t *TimeStamp) Scan(src interface{}) error {
if src == nil {
//t = nil
......@@ -95,6 +102,8 @@ func (t *TimeStamp) Scan(src interface{}) error {
}
return fmt.Errorf("Unsupported TimeStamp src: %T", src)
}
// Value implements the database/sql/driver/Valuer interface
func (t TimeStamp) Value() (driver.Value, error) {
if (time.Time)(t).IsZero() {
return nil, nil
......
......@@ -76,14 +76,14 @@ type FunctionContext struct {
argv **C.sqlite3_value
}
// Context associated to scalar function
// ScalarContext is used to represent context associated to scalar function
type ScalarContext struct {
FunctionContext
ad map[int]interface{} // Function Auxiliary Data
udf *sqliteFunction
}
// Context associated to aggregate function
// AggregateContext is used to represent context associated to aggregate function
type AggregateContext struct {
FunctionContext
Aggregate interface{}
......@@ -320,9 +320,16 @@ func (c *FunctionContext) Value(i int) (value interface{}) {
return
}
// ScalarFunction is the expected signature of scalar function implemented in Go
type ScalarFunction func(ctx *ScalarContext, nArg int)
// StepFunction is the expected signature of step function implemented in Go
type StepFunction func(ctx *AggregateContext, nArg int)
// FinalFunction is the expected signature of final function implemented in Go
type FinalFunction func(ctx *AggregateContext)
// DestroyFunctionData is the expected signature of function used to finalize user data.
type DestroyFunctionData func(pApp interface{})
type sqliteFunction struct {
......@@ -413,7 +420,8 @@ func goXDestroy(pApp unsafe.Pointer) {
// CreateScalarFunction creates or redefines SQL scalar functions.
// TODO Make possible to specify the preferred encoding
// (See http://sqlite.org/c3ref/create_function.html)
func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interface{}, f ScalarFunction, d DestroyFunctionData) error {
func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interface{},
f ScalarFunction, d DestroyFunctionData) error {
fname := C.CString(functionName)
defer C.free(unsafe.Pointer(fname))
if f == nil {
......
......@@ -18,6 +18,7 @@ import (
"unsafe"
)
// CommitHook is the callback function signature.
// If the callback on a commit hook function returns true, then the commit is converted into a rollback.
type CommitHook func(udp interface{}) bool
......@@ -45,6 +46,7 @@ func (c *Conn) CommitHook(f CommitHook, udp interface{}) {
C.goSqlite3CommitHook(c.db, unsafe.Pointer(c.commitHook))
}
// RollbackHook is the callback function signature.
type RollbackHook func(udp interface{})
type sqliteRollbackHook struct {
......@@ -71,6 +73,7 @@ func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
C.goSqlite3RollbackHook(c.db, unsafe.Pointer(c.rollbackHook))
}
// UpdateHook is the callback function signature.
type UpdateHook func(udp interface{}, a Action, dbName, tableName string, rowId int64)
type sqliteUpdateHook struct {
......@@ -84,7 +87,8 @@ func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, ro
arg.f(arg.udp, Action(action), C.GoString(dbName), C.GoString(tableName), int64(rowId))
}
// UpdateHook registers a callback to be invoked each time a row is updated, inserted or deleted using this database connection.
// UpdateHook registers a callback to be invoked each time a row is updated,
// inserted or deleted using this database connection.
// (See http://sqlite.org/c3ref/update_hook.html)
func (c *Conn) UpdateHook(f UpdateHook, udp interface{}) {
if f == nil {
......
......@@ -89,6 +89,7 @@ func (c *Conn) Tables(dbName string) ([]string, error) {
return tables, nil
}
// Column is the description of one table's column
// See Conn.Columns/IndexColumns
type Column struct {
Cid int
......@@ -180,13 +181,15 @@ func (s *Stmt) ColumnOriginName(index int) string {
return C.GoString(C.sqlite3_column_origin_name(s.stmt, C.int(index)))
}
// ColumnDeclaredType returns the declared type of the table column of a particular result column in SELECT statement. If the result column is an expression or subquery, then a NULL pointer is returned.
// ColumnDeclaredType returns the declared type of the table column of a particular result column in SELECT statement.
// If the result column is an expression or subquery, then a NULL pointer is returned.
// The left-most column is column 0.
// (See http://www.sqlite.org/c3ref/column_decltype.html)
func (s *Stmt) ColumnDeclaredType(index int) string {
return C.GoString(C.sqlite3_column_decltype(s.stmt, C.int(index)))
}
// ForeignKey is the description of one table's foreign key
// See Conn.ForeignKeys
type ForeignKey struct {
Table string
......@@ -231,6 +234,7 @@ func (c *Conn) ForeignKeys(dbName, table string) (map[int]*ForeignKey, error) {
return fks, nil
}
// Index is the description of one table's index
// See Conn.Indexes
type Index struct {
Name string
......
......@@ -135,6 +135,7 @@ func (c *Conn) SetSynchronous(dbName string, mode int) error {
return c.exec(pragma(dbName, fmt.Sprintf("synchronous=%d", mode)))
}
// FkViolation is the description of one foreign key constraint violation.
type FkViolation struct {
Table string
Rowid int64
......
......@@ -229,7 +229,7 @@ func OpenVfs(filename string, vfsname string, flags ...OpenFlag) (*Conn, error)
}
func authorizer(d interface{}, action Action, arg1, arg2, dbName, triggerName string) Auth {
fmt.Fprintf(os.Stderr, "%p: %s, %s, %s, %s, %s\n", d, action, arg1, arg2, dbName, triggerName)
fmt.Fprintf(os.Stderr, "%p: %v, %s, %s, %s, %s\n", d, action, arg1, arg2, dbName, triggerName)
return AuthOk
}
......
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