Documentation
¶
Index ¶
- Constants
- Variables
- func AdjustTree(a0 uintptr, a1 uintptr, a2 uintptr, a3 uintptr) uintptr
- func ChooseLeaf(a0 uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr) uintptr
- func LibVersion() (string, error)
- func SortByDimension(a0 uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr, ...)
- type Agg
- type Conn
- func (c *Conn) AutoCommit() bool
- func (c *Conn) Broken() bool
- func (c *Conn) BusyTimeout(ms int) error
- func (c *Conn) Changes() int64
- func (c *Conn) Close() error
- func (c *Conn) CreateAggregate(name string, nArg int, flags int, newAgg func() Agg) error
- func (c *Conn) CreateCollation(name string, cmp func(a, b string) int) error
- func (c *Conn) CreateFunction(name string, nArg int, flags int, f Func) error
- func (c *Conn) DeferredFKs() bool
- func (c *Conn) Exec(sql string) error
- func (c *Conn) Filename(schema string) string
- func (c *Conn) Interrupt() error
- func (c *Conn) LastInsertRowID() int64
- func (c *Conn) Prepare(sql string) (s *Stmt, tail string, err error)
- func (c *Conn) ReadOnly() bool
- func (c *Conn) SetLastInsertRowID(id int64)
- func (c *Conn) VirtualTablesInTx() bool
- type Error
- type Func
- type Stmt
- func (s *Stmt) BindBlob(i int, v []byte) error
- func (s *Stmt) BindDouble(i int, v float64) error
- func (s *Stmt) BindInt64(i int, v int64) error
- func (s *Stmt) BindNull(i int) error
- func (s *Stmt) BindText(i int, v string) error
- func (s *Stmt) ChangesConn() bool
- func (s *Stmt) ClearBindings() error
- func (s *Stmt) ColumnBlob(i int) []byte
- func (s *Stmt) ColumnCount() int
- func (s *Stmt) ColumnDeclType(i int) string
- func (s *Stmt) ColumnDouble(i int) float64
- func (s *Stmt) ColumnInt64(i int) int64
- func (s *Stmt) ColumnName(i int) string
- func (s *Stmt) ColumnText(i int) string
- func (s *Stmt) ColumnType(i int) int
- func (s *Stmt) Finalize() error
- func (s *Stmt) Mergeable() bool
- func (s *Stmt) ParamCount() int
- func (s *Stmt) ParamName(i int) string
- func (s *Stmt) ReadOnly() bool
- func (s *Stmt) Reprepares() int
- func (s *Stmt) Reset() error
- func (s *Stmt) Step() (bool, error)
Constants ¶
const ( OK = 0 Row = 100 Done = 101 OpenReadOnly = 0x00000001 OpenReadWrite = 0x00000002 OpenCreate = 0x00000004 OpenURI = 0x00000040 OpenMemory = 0x00000080 OpenNoMutex = 0x00008000 OpenFullMutex = 0x00010000 OpenPrivateCache = 0x00040000 OpenExResCode = 0x02000000 TypeInteger = 1 TypeFloat = 2 TypeText = 3 TypeBlob = 4 TypeNull = 5 )
Result codes and flags of sqlite3.h.
const ( FuncDeterministic = 0x000000800 FuncDirectOnly = 0x000080000 FuncInnocuous = 0x000200000 )
Flags of CreateFunction (sqlite3.h).
Variables ¶
var ErrBroken = errors.New("sqlite: connection is broken")
ErrBroken is the error of a call on a connection a host callback panicked under. Test for it with errors.Is.
var ErrCollationPanic = errors.New("panic in a Go collation")
ErrCollationPanic is under the error of a statement in which a Go collation panicked.
var ErrRolledBack = errors.New("sqlite: the transaction of the statement was rolled back while it ran: what it wrote is gone")
ErrRolledBack is the error of a statement that wrote, at its end, when SQLite rolled back its transaction while it ran: another statement of the connection failed in a way that ends the transaction (out of memory, an I/O error, a full disk, a panic in a Go collation), or ROLLBACK ran.
Functions ¶
func ChooseLeaf ¶
func LibVersion ¶
LibVersion is the version of the SQLite in the engine.
Types ¶
type Agg ¶
Agg is the state of one group of an aggregate function written in Go: Step for each row of the group, then Final once. Step's arguments are copies, like a Func's.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a connection to a database.
func Open ¶
Open opens a connection. It does not take OpenFullMutex: a connection has one shadow stack, so two goroutines cannot run on it at once, and a mutex of SQLite could not tell them apart.
func (*Conn) AutoCommit ¶
AutoCommit says whether no transaction is open.
func (*Conn) Broken ¶
Broken says a host callback panicked under the connection. It is safe to call from any goroutine.
func (*Conn) BusyTimeout ¶
BusyTimeout sets how long a statement waits for a lock.
func (*Conn) Close ¶
Close closes the connection. Its statements must be finalized first: with one open, Close returns SQLITE_BUSY and the connection stays open and usable, since SQLite would otherwise keep a half-closed connection that runs on a shadow stack already given back. A broken connection runs no C: Close frees its stack and returns the error that says so.
func (*Conn) CreateAggregate ¶
CreateAggregate makes an aggregate function name: newAgg makes the state of each group.
func (*Conn) CreateCollation ¶
CreateCollation makes cmp the collation name. cmp returns a negative number, 0 or a positive number as a sorts before, with or after b.
func (*Conn) CreateFunction ¶
CreateFunction makes f the SQL function name of nArg arguments (-1 for any number) on the connection, in place of one of the same name and nArg.
func (*Conn) DeferredFKs ¶
DeferredFKs says foreign key constraints of the transaction are not resolved yet (SQLITE_DBSTATUS_DEFERRED_FKS).
func (*Conn) Filename ¶
Filename is the absolute name of the file of database schema ("main"), or "" for a memory or temporary database.
func (*Conn) Interrupt ¶
Interrupt stops the statement running on the connection, from any goroutine. The statement returns SQLITE_INTERRUPT.
func (*Conn) LastInsertRowID ¶
LastInsertRowID is the rowid of the last row inserted.
func (*Conn) Prepare ¶
Prepare compiles the first statement of sql. tail is the rest of sql. A nil statement with no error is sql with no statement in it.
func (*Conn) SetLastInsertRowID ¶
SetLastInsertRowID sets what LastInsertRowID and last_insert_rowid() give.
func (*Conn) VirtualTablesInTx ¶
VirtualTablesInTx says virtual tables take part in the open transaction: one was written since it began.
type Error ¶
type Error struct {
Code int // the extended result code
Msg string
// contains filtered or unexported fields
}
Error is a result code of SQLite with its message.
type Func ¶
Func is a SQL function written in Go. Its arguments are copies, of the types int64, float64, string, []byte and nil. It returns one of those, an int or a bool, or an error that becomes the error of the statement. A panic in it is recovered and becomes the error of the statement too.
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
Stmt is a prepared statement.
func (*Stmt) ChangesConn ¶
ChangesConn says the statement changes the connection itself: a PRAGMA that sets something, ATTACH, DETACH, or a temporary table, index, view or trigger.
func (*Stmt) ClearBindings ¶
ClearBindings sets every parameter to NULL.
func (*Stmt) ColumnBlob ¶
ColumnBlob is the bytes of column i, copied: nil for NULL.
func (*Stmt) ColumnCount ¶
ColumnCount is the number of columns of a row.
func (*Stmt) ColumnDeclType ¶
ColumnDeclType is the declared type of column i, or "".
func (*Stmt) ColumnDouble ¶
func (*Stmt) ColumnInt64 ¶
func (*Stmt) ColumnName ¶
func (*Stmt) ColumnText ¶
ColumnText is the text of column i, copied.
func (*Stmt) ColumnType ¶
func (*Stmt) Mergeable ¶
Mergeable says the statement changes tables of the main database and touches nothing only its connection has: run on another connection of the same file, it does the same.
func (*Stmt) ParamCount ¶
ParamCount is the number of the largest parameter.
func (*Stmt) Reprepares ¶
Reprepares is how many times SQLite prepared the statement again, after a change of the schema.