Documentation
¶
Index ¶
- Constants
- Variables
- func Backup(src, dst RawConn, pages int, progress func(status, remaining, total int) error, ...) error
- func BackupContext(ctx context.Context, src, dst RawConn, pages int, ...) error
- func CreateFunction(conn RawConn, name string, nArg int, deterministic bool, fn ScalarFunc) error
- func InTransaction(conn RawConn) (bool, error)
- func IsOperational(code int) bool
- func SetAuthorizer(conn RawConn, auth Authorizer) error
- func SetProgressHandler(conn RawConn, interrupt func() bool, n int) error
- func SetTrace(conn RawConn, fn func(sql string)) error
- func WithHandle(conn RawConn, fn func(tls *libc.TLS, db uintptr) error) error
- type Authorizer
- type Error
- type RawConn
- type ScalarFunc
Constants ¶
const ( // Verdict letting the access go ahead AuthOK = sqlite3.SQLITE_OK // Verdict failing the statement as not authorized AuthDeny = sqlite3.SQLITE_DENY // Verdict letting the statement run with that access silently skipped, a column read giving NULL AuthIgnore = sqlite3.SQLITE_IGNORE // Action of reading a column, arguments table and column; the other action codes are the SQLITE_ constants of modernc.org/sqlite/lib ActionRead = sqlite3.SQLITE_READ // Action of inserting into a table, first argument the table ActionInsert = sqlite3.SQLITE_INSERT // Action of updating a column, arguments table and column ActionUpdate = sqlite3.SQLITE_UPDATE // Action of deleting from a table, first argument the table ActionDelete = sqlite3.SQLITE_DELETE )
Variables ¶
var ErrClosed = errors.New("sqlite connection is closed")
Error of a driver connection whose database is already closed
var ErrSameConnection = errors.New("backup source and target are the same connection")
Error of a backup asked to copy a connection onto itself
var ErrUnsupportedConn = errors.New("connection is not a modernc.org/sqlite connection")
Error of a driver connection that is not a modernc.org/sqlite connection, wrapped with its type
Functions ¶
func Backup ¶
func Backup(src, dst RawConn, pages int, progress func(status, remaining, total int) error, sleep time.Duration) error
Copies the main database of src over the main database of dst with SQLite's online backup: pages per step (every page in one step when not positive), progress called after each step with the step's result code and the pages remaining and in total (its error ends the copy and is returned), sleep paused after a step that found the source busy or locked; a *Error when SQLite fails, also when dst is inside a transaction
func BackupContext ¶
func BackupContext(ctx context.Context, src, dst RawConn, pages int, progress func(status, remaining, total int) error, sleep time.Duration) error
Backup that also stops before a step and during a pause once ctx is done, returning the context's error
func CreateFunction ¶
Registers fn on conn as the SQL function name taking nArg arguments (-1 for any number), replacing one of the same name and count; deterministic lets SQLite treat equal arguments as giving equal results, so the function may serve in indexes and checks; a nil fn removes the function
func InTransaction ¶
Whether a transaction is open on conn
func IsOperational ¶
Whether a result code, extended or primary, reports an operational failure: one of the database's state or surroundings such as a missing table or column, a lock, a read-only or full disk, an interrupt or a changed schema, not of the statement's values or the caller's use of the API
func SetAuthorizer ¶
func SetAuthorizer(conn RawConn, auth Authorizer) error
Installs auth as the authorizer of conn, consulted for every access of each statement prepared from then on; nil removes it
func SetProgressHandler ¶
Calls interrupt about every n virtual machine steps of each statement running on conn, the statement failing as interrupted once it answers true; a nil interrupt or an n that is not positive removes the handler
Types ¶
type Authorizer ¶
Decision on one access SQLite asks about while it prepares a statement: the action code, its two detail arguments (table and column for reads and updates), the database name and the innermost trigger or view, absent arguments empty; it answers AuthOK, AuthDeny or AuthIgnore
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Failure SQLite reported on a connection, its extended result code and the database's message; the Code method matches the one modernc.org/sqlite errors have
type RawConn ¶
Connection whose driver connection can be borrowed, as *sql.Conn and the types wrapping one give it
type ScalarFunc ¶
Body of a scalar SQL function: it receives the arguments as nil, int64, float64, string or []byte and answers nil, a bool, an integer, a float, a string or a []byte, or an error that becomes the statement's error