Commit b5cfeaf5 authored by gwenn's avatar gwenn

Improve doc.

parent 0178feae
......@@ -29,7 +29,7 @@ import (
// err = bck.Run(100, 250000, cbs)
// check(err)
//
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit)
func NewBackup(dst *Conn, dstDbName string, src *Conn, srcDbName string) (*Backup, error) {
dname := C.CString(dstDbName)
sname := C.CString(srcDbName)
......@@ -50,7 +50,7 @@ type Backup struct {
}
// Copy up to N pages between the source and destination databases
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep)
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 {
......@@ -66,12 +66,12 @@ type BackupStatus struct {
}
// Return the number of pages still to be backed up and the total number of pages in the source database file.
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupremaining)
func (b *Backup) Status() BackupStatus {
return BackupStatus{int(C.sqlite3_backup_remaining(b.sb)), int(C.sqlite3_backup_pagecount(b.sb))}
}
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep, sqlite3_backup_remaining and sqlite3_backup_pagecount
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupstep, sqlite3_backup_remaining and sqlite3_backup_pagecount)
func (b *Backup) Run(npage int, sleepNs time.Duration, c chan<- BackupStatus) error {
var err error
for {
......@@ -90,7 +90,7 @@ func (b *Backup) Run(npage int, sleepNs time.Duration, c chan<- BackupStatus) er
}
// Finish/stop the backup
// Calls http://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish
// (See http://sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish)
func (b *Backup) Close() error {
if b.sb == nil {
return os.EINVAL
......
......@@ -49,7 +49,7 @@ type ZeroBlobLength int
// n, err = br.Read(content)
// // check err
//
// Calls http://sqlite.org/c3ref/blob_open.html
// (See http://sqlite.org/c3ref/blob_open.html)
// TODO A real 'incremental' example...
func (c *Conn) NewBlobReader(db, table, column string, row int64) (*BlobReader, error) {
bl, err := c.blob_open(db, table, column, row, false)
......@@ -60,7 +60,7 @@ func (c *Conn) NewBlobReader(db, table, column string, row int64) (*BlobReader,
}
// Open a BLOB For incremental I/O
// Calls http://sqlite.org/c3ref/blob_open.html
// (See http://sqlite.org/c3ref/blob_open.html)
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 {
......@@ -91,7 +91,7 @@ func (c *Conn) blob_open(db, table, column string, row int64, write bool) (*C.sq
}
// Close a BLOB handle
// Calls http://sqlite.org/c3ref/blob_close.html
// (See http://sqlite.org/c3ref/blob_close.html)
func (r *BlobReader) Close() error {
rv := C.sqlite3_blob_close(r.bl)
if rv != C.SQLITE_OK {
......@@ -102,7 +102,7 @@ func (r *BlobReader) Close() error {
}
// Read data from a BLOB incrementally
// Calls http://sqlite.org/c3ref/blob_read.html
// (See http://sqlite.org/c3ref/blob_read.html)
func (r *BlobReader) Read(v []byte) (int, error) {
var p *byte
if len(v) > 0 {
......@@ -117,14 +117,14 @@ func (r *BlobReader) Read(v []byte) (int, error) {
}
// Return the size of an open BLOB
// Calls http://sqlite.org/c3ref/blob_bytes.html
// (See http://sqlite.org/c3ref/blob_bytes.html)
func (r *BlobReader) Size() (int, error) {
s := C.sqlite3_blob_bytes(r.bl)
return int(s), nil
}
// Write data into a BLOB incrementally
// Calls http://sqlite.org/c3ref/blob_write.html
// (See http://sqlite.org/c3ref/blob_write.html)
func (w *BlobReadWriter) Write(v []byte) (int, error) {
var p *byte
if len(v) > 0 {
......@@ -139,7 +139,7 @@ func (w *BlobReadWriter) Write(v []byte) (int, error) {
}
// Move a BLOB handle to a new row
// Calls http://sqlite.org/c3ref/blob_reopen.html
// (See http://sqlite.org/c3ref/blob_reopen.html)
func (r *BlobReader) Reopen(rowid int64) error {
rv := C.sqlite3_blob_reopen(r.bl, C.sqlite3_int64(rowid))
if rv != C.SQLITE_OK {
......
......@@ -143,7 +143,7 @@ func (c *Context) ResultBool(b bool) {
}
// Set the result of an SQL function
// Calls sqlite3_result_blob, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_blob, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultBlob(b []byte) {
var p *byte
if len(b) > 0 {
......@@ -153,13 +153,13 @@ func (c *Context) ResultBlob(b []byte) {
}
// Set the result of an SQL function
// Calls sqlite3_result_double, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_double, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultDouble(d float64) {
C.sqlite3_result_double(c.sc, C.double(d))
}
// Set the result of an SQL function
// Calls sqlite3_result_error, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_error, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultError(msg string) {
cs := C.CString(msg)
defer C.free(unsafe.Pointer(cs))
......@@ -167,43 +167,43 @@ func (c *Context) ResultError(msg string) {
}
// Set the result of an SQL function
// Calls sqlite3_result_error_toobig, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_error_toobig, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultErrorTooBig() {
C.sqlite3_result_error_toobig(c.sc)
}
// Set the result of an SQL function
// Calls sqlite3_result_error_nomem, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_error_nomem, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultErrorNoMem() {
C.sqlite3_result_error_nomem(c.sc)
}
// Set the result of an SQL function
// Calls sqlite3_result_error_code, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_error_code, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultErrorCode(e Errno) {
C.sqlite3_result_error_code(c.sc, C.int(e))
}
// Set the result of an SQL function
// Calls sqlite3_result_int, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_int, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultInt(i int) {
C.sqlite3_result_int(c.sc, C.int(i))
}
// Set the result of an SQL function
// Calls sqlite3_result_int64, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_int64, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultInt64(i int64) {
C.sqlite3_result_int64(c.sc, C.sqlite3_int64(i))
}
// Set the result of an SQL function
// Calls sqlite3_result_null, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_null, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultNull() {
C.sqlite3_result_null(c.sc)
}
// Set the result of an SQL function
// Calls sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_text, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultText(s string) {
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
......@@ -212,26 +212,26 @@ func (c *Context) ResultText(s string) {
// Set the result of an SQL function
// The leftmost value is number 0.
// Calls sqlite3_result_value, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_value, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultValue(i int) {
C.my_result_value(c.sc, c.argv, C.int(i))
}
// Set the result of an SQL function
// Calls sqlite3_result_zeroblob, http://sqlite.org/c3ref/result_blob.html
// (See sqlite3_result_zeroblob, http://sqlite.org/c3ref/result_blob.html)
func (c *Context) ResultZeroblob(n ZeroBlobLength) {
C.sqlite3_result_zeroblob(c.sc, C.int(n))
}
// User data for functions
// Calls http://sqlite.org/c3ref/user_data.html
// (See http://sqlite.org/c3ref/user_data.html)
func (c *Context) UserData() interface{} {
udf := (*sqliteFunction)(C.sqlite3_user_data(c.sc))
return udf.pApp
}
// Function auxiliary data
// Calls sqlite3_get_auxdata, http://sqlite.org/c3ref/get_auxdata.html
// (See sqlite3_get_auxdata, http://sqlite.org/c3ref/get_auxdata.html)
func (c *Context) GetAuxData(n int) interface{} {
if len(c.ad) == 0 {
return nil
......@@ -241,7 +241,7 @@ func (c *Context) GetAuxData(n int) interface{} {
// Function auxiliary data
// No destructor is needed a priori
// Calls sqlite3_set_auxdata, http://sqlite.org/c3ref/get_auxdata.html
// (See sqlite3_set_auxdata, http://sqlite.org/c3ref/get_auxdata.html)
func (c *Context) SetAuxData(n int, ad interface{}) {
if len(c.ad) == 0 {
c.ad = make(map[int]interface{})
......@@ -255,7 +255,7 @@ func (c *Context) Bool(i int) bool {
}
// The leftmost value is number 0.
// Calls sqlite3_value_blob and sqlite3_value_bytes, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_blob and sqlite3_value_bytes, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Blob(i int) (value []byte) {
p := C.my_value_blob(c.argv, C.int(i))
if p != nil {
......@@ -266,25 +266,25 @@ func (c *Context) Blob(i int) (value []byte) {
}
// The leftmost value is number 0.
// Calls sqlite3_value_double, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_double, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Double(i int) float64 {
return float64(C.my_value_double(c.argv, C.int(i)))
}
// The leftmost value is number 0.
// Calls sqlite3_value_int, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_int, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Int(i int) int {
return int(C.my_value_int(c.argv, C.int(i)))
}
// The leftmost value is number 0.
// Calls sqlite3_value_int64, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_int64, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Int64(i int) int64 {
return int64(C.my_value_int64(c.argv, C.int(i)))
}
// The leftmost value is number 0.
// Calls sqlite3_value_text, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_text, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Text(i int) string {
p := C.my_value_text(c.argv, C.int(i))
if p == nil {
......@@ -296,14 +296,14 @@ func (c *Context) Text(i int) string {
// The leftmost value is number 0.
// SQL function parameter value type
// Calls sqlite3_value_type, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_type, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) Type(i int) Type {
return Type(C.my_value_type(c.argv, C.int(i)))
}
// The leftmost value is number 0.
// SQL function parameter value numeric type (with possible conversion)
// Calls sqlite3_value_numeric_type, http://sqlite.org/c3ref/value_blob.html
// (See sqlite3_value_numeric_type, http://sqlite.org/c3ref/value_blob.html)
func (c *Context) NumericType(i int) Type {
return Type(C.my_value_numeric_type(c.argv, C.int(i)))
}
......@@ -417,7 +417,7 @@ func goXDestroy(pApp unsafe.Pointer) {
// Create or redefine SQL functions
// TODO Make possible to specify the preferred encoding
// Calls http://sqlite.org/c3ref/create_function.html
// (See http://sqlite.org/c3ref/create_function.html)
func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interface{}, f FuncOrStep, d DestroyFunctionData) error {
fname := C.CString(functionName)
defer C.free(unsafe.Pointer(fname))
......@@ -438,7 +438,7 @@ func (c *Conn) CreateScalarFunction(functionName string, nArg int, pApp interfac
// Create or redefine SQL functions
// TODO Make possible to specify the preferred encoding
// Calls http://sqlite.org/c3ref/create_function.html
// (See http://sqlite.org/c3ref/create_function.html)
func (c *Conn) CreateAggregateFunction(functionName string, nArg int, pApp interface{},
step FuncOrStep, final FinalFunction, d DestroyFunctionData) error {
fname := C.CString(functionName)
......
......@@ -46,7 +46,7 @@ func goXCommitHook(udp unsafe.Pointer) C.int {
}
// Commit notification callback
// Calls http://sqlite.org/c3ref/commit_hook.html
// (See http://sqlite.org/c3ref/commit_hook.html)
func (c *Conn) CommitHook(f CommitHook, udp interface{}) {
if f == nil {
c.commitHook = nil
......@@ -72,7 +72,7 @@ func goXRollbackHook(udp unsafe.Pointer) {
}
// Rollback notification callback
// Calls http://sqlite.org/c3ref/commit_hook.html
// (See http://sqlite.org/c3ref/commit_hook.html)
func (c *Conn) RollbackHook(f RollbackHook, udp interface{}) {
if f == nil {
c.rollbackHook = nil
......@@ -98,7 +98,7 @@ func goXUpdateHook(udp unsafe.Pointer, action int, dbName, tableName *C.char, ro
}
// Data change notification callbacks
// Calls http://sqlite.org/c3ref/update_hook.html
// (See http://sqlite.org/c3ref/update_hook.html)
func (c *Conn) UpdateHook(f UpdateHook, udp interface{}) {
if f == nil {
c.updateHook = nil
......
......@@ -90,7 +90,6 @@ type Column struct {
// Executes pragma 'table_info'
// TODO Make possible to specify the database-name (PRAGMA %Q.table_info(%Q))
// TODO sqlite3_table_column_metadata?
func (c *Conn) Columns(table string) ([]Column, error) {
s, err := c.Prepare(Mprintf("PRAGMA table_info(%Q)", table))
if err != nil {
......@@ -112,6 +111,8 @@ func (c *Conn) Columns(table string) ([]Column, error) {
return columns, nil
}
// Extract metadata about a column of a table
// (See http://sqlite.org/c3ref/table_column_metadata.html)
func (c *Conn) Column(dbName, tableName, columnName string) (*Column, error) {
var zDbName *C.char
if len(dbName) > 0 {
......@@ -223,7 +224,7 @@ func (c *Conn) IndexColumns(index string) ([]Column, error) {
return columns, nil
}
// Calls http://sqlite.org/c3ref/mprintf.html
// (See http://sqlite.org/c3ref/mprintf.html)
func Mprintf(format string, arg string) string {
cf := C.CString(format)
defer C.free(unsafe.Pointer(cf))
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ func goXTrace(udp unsafe.Pointer, sql *C.char) {
}
// Tracing function
// Calls sqlite3_trace, http://sqlite.org/c3ref/profile.html
// (See sqlite3_trace, http://sqlite.org/c3ref/profile.html)
func (c *Conn) Trace(f Tracer, udp interface{}) {
if f == nil {
c.trace = nil
......@@ -98,7 +98,7 @@ func goXProfile(udp unsafe.Pointer, sql *C.char, nanoseconds C.sqlite3_uint64) {
}
// Profiling Function
// Calls sqlite3_profile, http://sqlite.org/c3ref/profile.html
// (See sqlite3_profile, http://sqlite.org/c3ref/profile.html)
func (c *Conn) Profile(f Profiler, udp interface{}) {
if f == nil {
c.profile = nil
......@@ -174,7 +174,7 @@ func goXAuth(udp unsafe.Pointer, action int, arg1, arg2, dbName, triggerName *C.
}
// Compile-time authorization callbacks
// Calls http://sqlite.org/c3ref/set_authorizer.html
// (See http://sqlite.org/c3ref/set_authorizer.html)
func (c *Conn) SetAuthorizer(f Authorizer, udp interface{}) error {
if f == nil {
c.authorizer = nil
......@@ -203,7 +203,7 @@ func goXBusy(udp unsafe.Pointer, count int) C.int {
// Register a callback to handle SQLITE_BUSY errors
// TODO NOT TESTED
// Calls http://sqlite.org/c3ref/busy_handler.html
// (See http://sqlite.org/c3ref/busy_handler.html)
func (c *Conn) BusyHandler(f BusyHandler, udp interface{}) error {
if f == nil {
c.busyHandler = nil
......@@ -231,7 +231,7 @@ func goXProgress(udp unsafe.Pointer) C.int {
}
// Query progress callbacks
// Calls http://sqlite.org/c3ref/progress_handler.html
// (See http://sqlite.org/c3ref/progress_handler.html)
func (c *Conn) ProgressHandler(f ProgressHandler, numOps int, udp interface{}) {
if f == nil {
c.progressHandler = nil
......@@ -253,37 +253,37 @@ const (
)
// Prepared statement status
// Calls http://sqlite.org/c3ref/stmt_status.html
// (See http://sqlite.org/c3ref/stmt_status.html)
func (s *Stmt) Status(op StmtStatus, reset bool) int {
return int(C.sqlite3_stmt_status(s.stmt, C.int(op), btocint(reset)))
}
// Memory allocator statistics
// Calls sqlite3_memory_used: http://sqlite.org/c3ref/memory_highwater.html
// (See sqlite3_memory_used: http://sqlite.org/c3ref/memory_highwater.html)
func MemoryUsed() int64 {
return int64(C.sqlite3_memory_used())
}
// Memory allocator statistics
// Calls sqlite3_memory_highwater: http://sqlite.org/c3ref/memory_highwater.html
// (See sqlite3_memory_highwater: http://sqlite.org/c3ref/memory_highwater.html)
func MemoryHighwater(reset bool) int64 {
return int64(C.sqlite3_memory_highwater(btocint(reset)))
}
// Limit on heap size
// Calls http://sqlite.org/c3ref/soft_heap_limit64.html
// (See http://sqlite.org/c3ref/soft_heap_limit64.html)
func SoftHeapLimit() int64 {
return SetSoftHeapLimit(-1)
}
// Impose a limit on heap size
// Calls http://sqlite.org/c3ref/soft_heap_limit64.html
// (See http://sqlite.org/c3ref/soft_heap_limit64.html)
func SetSoftHeapLimit(n int64) int64 {
return int64(C.sqlite3_soft_heap_limit64(C.sqlite3_int64(n)))
}
// Determine if an SQL statement is complete
// Calls http://sqlite.org/c3ref/complete.html
// (See http://sqlite.org/c3ref/complete.html)
func Complete(sql string) bool {
cs := C.CString(sql)
defer C.free(unsafe.Pointer(cs))
......@@ -291,7 +291,7 @@ func Complete(sql string) bool {
}
// Error logging interface
// Calls http://sqlite.org/c3ref/log.html
// (See http://sqlite.org/c3ref/log.html)
func Log(err /*Errno*/ int, msg string) {
cs := C.CString(msg)
defer C.free(unsafe.Pointer(cs))
......@@ -316,7 +316,7 @@ func goXLog(udp unsafe.Pointer, err int, msg *C.char) {
var logger *sqliteLogger
// Configure the logger of the SQLite library
// Calls sqlite3_config(SQLITE_CONFIG_LOG,...)
// (See sqlite3_config(SQLITE_CONFIG_LOG,...): http://sqlite.org/c3ref/config.html)
func ConfigLog(f Logger, udp interface{}) error {
var rv C.int
if f == 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