Documentation ¶
Index ¶
- Constants
- Variables
- func Call(contractState *state.ContractState, code, contractAddress []byte, ...) (string, []*types.Event, *big.Int, error)
- func CloseDatabase()
- func Create(contractState *state.ContractState, code, contractAddress []byte, ...) (string, []*types.Event, *big.Int, error)
- func CreateContractID(account []byte, nonce uint64) []byte
- func Execute(bs *state.BlockState, tx *types.Tx, blockNo uint64, ts int64, ...) (rv string, events []*types.Event, usedFee *big.Int, err error)
- func FreeLState(state *LState)
- func GetABI(contractState *state.ContractState) (*types.ABI, error)
- func IsPublic() C.int
- func IsRuntimeError(err error) bool
- func LoadDatabase(dataDir string) error
- func LuaCallContract(L *LState, service *C.int, contractId *C.char, fname *C.char, args *C.char, ...) (C.int, *C.char)
- func LuaClearRecovery(L *LState, service *C.int, start int, error bool) *C.char
- func LuaCryptoSha256(L *LState, arg unsafe.Pointer, argLen C.int) (*C.char, *C.char)
- func LuaDelDB(L *LState, service *C.int, key *C.char) *C.char
- func LuaDelegateCallContract(L *LState, service *C.int, contractId *C.char, fname *C.char, args *C.char, ...) (C.int, *C.char)
- func LuaDeployContract(L *LState, service *C.int, contract *C.char, args *C.char, amount *C.char) (C.int, *C.char)
- func LuaECVerify(L *LState, msg *C.char, sig *C.char, addr *C.char) (C.int, *C.char)
- func LuaEvent(L *LState, service *C.int, eventName *C.char, args *C.char) *C.char
- func LuaGetAmount(L *LState, service *C.int) *C.char
- func LuaGetBalance(L *LState, service *C.int, contractId *C.char) (*C.char, *C.char)
- func LuaGetBlockNo(L *LState, service *C.int) C.lua_Integer
- func LuaGetContractId(L *LState, service *C.int) *C.char
- func LuaGetDB(L *LState, service *C.int, key *C.char) (*C.char, *C.char)
- func LuaGetDbHandle(service *C.int) *C.sqlite3
- func LuaGetHash(L *LState, service *C.int) *C.char
- func LuaGetOrigin(L *LState, service *C.int) *C.char
- func LuaGetPrevBlockHash(L *LState, service *C.int) *C.char
- func LuaGetSender(L *LState, service *C.int) *C.char
- func LuaGetTimeStamp(L *LState, service *C.int) C.lua_Integer
- func LuaGovernance(L *LState, service *C.int, gType C.char, arg *C.char) *C.char
- func LuaIsContract(L *LState, service *C.int, contractId *C.char) (C.int, *C.char)
- func LuaPrint(L *LState, service *C.int, args *C.char)
- func LuaRandomInt(min, max, service C.int) C.int
- func LuaSendAmount(L *LState, service *C.int, contractId *C.char, amount *C.char) *C.char
- func LuaSetDB(L *LState, service *C.int, key *C.char, value *C.char) *C.char
- func LuaSetRecoveryPoint(L *LState, service *C.int) (C.int, *C.char)
- func NewLuaTxAccount(name string, balance uint64) *luaTxAccount
- func NewLuaTxAccountBig(name string, balance *big.Int) *luaTxAccount
- func NewLuaTxCall(sender, contract string, amount uint64, code string) *luaTxCall
- func NewLuaTxCallBig(sender, contract string, amount *big.Int, code string) *luaTxCall
- func NewLuaTxDef(sender, contract string, amount uint64, code string) *luaTxDef
- func NewLuaTxSendBig(sender, receiver string, balance *big.Int) *luaTxSend
- func NewRawLuaTxDef(sender, contract string, amount uint64, code string) *luaTxDef
- func PermittedCmd(cmd *C.char) C.int
- func PreCall(ce *Executor, bs *state.BlockState, sender *state.V, ...) (string, []*types.Event, *big.Int, error)
- func PreLoadRequest(bs *state.BlockState, tx *types.Tx, preLoadService int)
- func Query(contractAddress []byte, bs *state.BlockState, ...) (res []byte, err error)
- func SaveRecoveryPoint(bs *state.BlockState) error
- func SetPreloadTx(tx *types.Tx, service int)
- func StartLStateFactory()
- func StrToAddress(name string) string
- func Version() (libVersion string, libVersionNumber int, sourceID string)
- type CallState
- type ContractInfo
- type DB
- type Database
- type DbSystemError
- type DummyChain
- func (bc *DummyChain) BeginReceiptTx() db.Transaction
- func (bc *DummyChain) BestBlockNo() uint64
- func (bc *DummyChain) ConnectBlock(txs ...luaTx) error
- func (bc *DummyChain) DisConnectBlock() error
- func (bc *DummyChain) GetABI(contract string) (*types.ABI, error)
- func (bc *DummyChain) GetAccountState(name string) (*types.State, error)
- func (bc *DummyChain) GetStaking(name string) (*types.Staking, error)
- func (bc *DummyChain) Query(contract, queryInfo, expectedErr string, expectedRvs ...string) error
- func (bc *DummyChain) QueryOnly(contract, queryInfo string) (string, error)
- type ErrNo
- type ErrNoExtended
- type ErrRuntime
- type ErrSystem
- type Error
- type Executor
- type LState
- type ReadOnlyTx
- func (tx *ReadOnlyTx) Commit() error
- func (tx *ReadOnlyTx) Release() error
- func (tx *ReadOnlyTx) Rollback() error
- func (tx *ReadOnlyTx) RollbackToSavepoint() error
- func (tx *ReadOnlyTx) RollbackToSubSavepoint(name string) error
- func (tx *ReadOnlyTx) Savepoint() error
- func (tx *ReadOnlyTx) SubRelease(name string) error
- func (tx *ReadOnlyTx) SubSavepoint(name string) error
- type SQLiteConn
- func (c *SQLiteConn) AutoCommit() bool
- func (c *SQLiteConn) Begin() (driver.Tx, error)
- func (c *SQLiteConn) Close() error
- func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error)
- func (c *SQLiteConn) GetFilename(schemaName string) string
- func (c *SQLiteConn) GetLimit(id int) int
- func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error)
- func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error)
- func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error
- func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, string) int)
- func (c *SQLiteConn) RegisterCollation(name string, cmp func(string, string) int) error
- func (c *SQLiteConn) RegisterCommitHook(callback func() int)
- func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error
- func (c *SQLiteConn) RegisterRollbackHook(callback func())
- func (c *SQLiteConn) RegisterUpdateHook(callback func(int, string, string, int64))
- func (c *SQLiteConn) SetLimit(id int, newVal int) int
- type SQLiteDriver
- type SQLiteResult
- type SQLiteRows
- type SQLiteStmt
- type SQLiteTx
- type StateSet
- type Tx
- type TxCommon
- type VmSystemError
- type WritableTx
- func (tx *WritableTx) Commit() error
- func (tx *WritableTx) Release() error
- func (tx *WritableTx) Rollback() error
- func (tx *WritableTx) RollbackToSavepoint() error
- func (tx *WritableTx) RollbackToSubSavepoint(name string) error
- func (tx *WritableTx) Savepoint() error
- func (tx *WritableTx) SubRelease(name string) error
- func (tx *WritableTx) SubSavepoint(name string) error
Constants ¶
const ( // used by authorizer and pre_update_hook SQLITE_DELETE = C.SQLITE_DELETE SQLITE_INSERT = C.SQLITE_INSERT SQLITE_UPDATE = C.SQLITE_UPDATE // used by authorzier - as return value SQLITE_OK = C.SQLITE_OK SQLITE_IGNORE = C.SQLITE_IGNORE SQLITE_DENY = C.SQLITE_DENY // different actions query tries to do - passed as argument to authorizer SQLITE_CREATE_INDEX = C.SQLITE_CREATE_INDEX SQLITE_CREATE_TABLE = C.SQLITE_CREATE_TABLE SQLITE_CREATE_TEMP_INDEX = C.SQLITE_CREATE_TEMP_INDEX SQLITE_CREATE_TEMP_TABLE = C.SQLITE_CREATE_TEMP_TABLE SQLITE_CREATE_TEMP_TRIGGER = C.SQLITE_CREATE_TEMP_TRIGGER SQLITE_CREATE_TEMP_VIEW = C.SQLITE_CREATE_TEMP_VIEW SQLITE_CREATE_TRIGGER = C.SQLITE_CREATE_TRIGGER SQLITE_CREATE_VIEW = C.SQLITE_CREATE_VIEW SQLITE_CREATE_VTABLE = C.SQLITE_CREATE_VTABLE SQLITE_DROP_INDEX = C.SQLITE_DROP_INDEX SQLITE_DROP_TABLE = C.SQLITE_DROP_TABLE SQLITE_DROP_TEMP_INDEX = C.SQLITE_DROP_TEMP_INDEX SQLITE_DROP_TEMP_TABLE = C.SQLITE_DROP_TEMP_TABLE SQLITE_DROP_TEMP_TRIGGER = C.SQLITE_DROP_TEMP_TRIGGER SQLITE_DROP_TEMP_VIEW = C.SQLITE_DROP_TEMP_VIEW SQLITE_DROP_TRIGGER = C.SQLITE_DROP_TRIGGER SQLITE_DROP_VIEW = C.SQLITE_DROP_VIEW SQLITE_DROP_VTABLE = C.SQLITE_DROP_VTABLE SQLITE_PRAGMA = C.SQLITE_PRAGMA SQLITE_READ = C.SQLITE_READ SQLITE_SELECT = C.SQLITE_SELECT SQLITE_TRANSACTION = C.SQLITE_TRANSACTION SQLITE_ATTACH = C.SQLITE_ATTACH SQLITE_DETACH = C.SQLITE_DETACH SQLITE_ALTER_TABLE = C.SQLITE_ALTER_TABLE SQLITE_REINDEX = C.SQLITE_REINDEX SQLITE_ANALYZE = C.SQLITE_ANALYZE SQLITE_FUNCTION = C.SQLITE_FUNCTION SQLITE_SAVEPOINT = C.SQLITE_SAVEPOINT SQLITE_COPY = C.SQLITE_COPY )
const ( SQLITE_LIMIT_LENGTH = C.SQLITE_LIMIT_LENGTH SQLITE_LIMIT_SQL_LENGTH = C.SQLITE_LIMIT_SQL_LENGTH SQLITE_LIMIT_COLUMN = C.SQLITE_LIMIT_COLUMN SQLITE_LIMIT_EXPR_DEPTH = C.SQLITE_LIMIT_EXPR_DEPTH SQLITE_LIMIT_COMPOUND_SELECT = C.SQLITE_LIMIT_COMPOUND_SELECT SQLITE_LIMIT_VDBE_OP = C.SQLITE_LIMIT_VDBE_OP SQLITE_LIMIT_FUNCTION_ARG = C.SQLITE_LIMIT_FUNCTION_ARG SQLITE_LIMIT_ATTACHED = C.SQLITE_LIMIT_ATTACHED SQLITE_LIMIT_LIKE_PATTERN_LENGTH = C.SQLITE_LIMIT_LIKE_PATTERN_LENGTH SQLITE_LIMIT_VARIABLE_NUMBER = C.SQLITE_LIMIT_VARIABLE_NUMBER SQLITE_LIMIT_TRIGGER_DEPTH = C.SQLITE_LIMIT_TRIGGER_DEPTH SQLITE_LIMIT_WORKER_THREADS = C.SQLITE_LIMIT_WORKER_THREADS )
Run-Time Limit Categories. See: http://www.sqlite.org/c3ref/c_limit_attached.html
const BlockFactory = 0
const ChainService = 1
const ErrNoMask C.int = 0xff
ErrNoMask is mask code.
const MAX_LSTATE_SIZE = 150
const StateSqlMaxDbSize = 1024 * 1024 * 1024 * 1024
Variables ¶
var ( ErrError = ErrNo(1) /* SQL error or missing database */ ErrInternal = ErrNo(2) /* Internal logic error in SQLite */ ErrPerm = ErrNo(3) /* Access permission denied */ ErrAbort = ErrNo(4) /* Callback routine requested an abort */ ErrBusy = ErrNo(5) /* The database file is locked */ ErrLocked = ErrNo(6) /* A table in the database is locked */ ErrNomem = ErrNo(7) /* A malloc() failed */ ErrReadonly = ErrNo(8) /* Attempt to write a readonly database */ ErrInterrupt = ErrNo(9) /* Operation terminated by sqlite3_interrupt() */ ErrIoErr = ErrNo(10) /* Some kind of disk I/O error occurred */ ErrCorrupt = ErrNo(11) /* The database disk image is malformed */ ErrNotFound = ErrNo(12) /* Unknown opcode in sqlite3_file_control() */ ErrFull = ErrNo(13) /* Insertion failed because database is full */ ErrCantOpen = ErrNo(14) /* Unable to open the database file */ ErrProtocol = ErrNo(15) /* Database lock protocol error */ ErrEmpty = ErrNo(16) /* Database is empty */ ErrSchema = ErrNo(17) /* The database schema changed */ ErrTooBig = ErrNo(18) /* String or BLOB exceeds size limit */ ErrConstraint = ErrNo(19) /* Abort due to constraint violation */ ErrMismatch = ErrNo(20) /* Data type mismatch */ ErrMisuse = ErrNo(21) /* Library used incorrectly */ ErrNoLFS = ErrNo(22) /* Uses OS features not supported on host */ ErrAuth = ErrNo(23) /* Authorization denied */ ErrFormat = ErrNo(24) /* Auxiliary database format error */ ErrRange = ErrNo(25) /* 2nd parameter to sqlite3_bind out of range */ ErrNotADB = ErrNo(26) /* File opened that is not a database file */ ErrNotice = ErrNo(27) /* Notifications from sqlite3_log() */ ErrWarning = ErrNo(28) /* Warnings from sqlite3_log() */ )
result codes from http://www.sqlite.org/c3ref/c_abort.html
var ( ErrIoErrRead = ErrIoErr.Extend(1) ErrIoErrShortRead = ErrIoErr.Extend(2) ErrIoErrWrite = ErrIoErr.Extend(3) ErrIoErrFsync = ErrIoErr.Extend(4) ErrIoErrDirFsync = ErrIoErr.Extend(5) ErrIoErrTruncate = ErrIoErr.Extend(6) ErrIoErrFstat = ErrIoErr.Extend(7) ErrIoErrUnlock = ErrIoErr.Extend(8) ErrIoErrRDlock = ErrIoErr.Extend(9) ErrIoErrDelete = ErrIoErr.Extend(10) ErrIoErrBlocked = ErrIoErr.Extend(11) ErrIoErrNoMem = ErrIoErr.Extend(12) ErrIoErrAccess = ErrIoErr.Extend(13) ErrIoErrCheckReservedLock = ErrIoErr.Extend(14) ErrIoErrLock = ErrIoErr.Extend(15) ErrIoErrClose = ErrIoErr.Extend(16) ErrIoErrDirClose = ErrIoErr.Extend(17) ErrIoErrSHMOpen = ErrIoErr.Extend(18) ErrIoErrSHMSize = ErrIoErr.Extend(19) ErrIoErrSHMLock = ErrIoErr.Extend(20) ErrIoErrSHMMap = ErrIoErr.Extend(21) ErrIoErrSeek = ErrIoErr.Extend(22) ErrIoErrDeleteNoent = ErrIoErr.Extend(23) ErrIoErrMMap = ErrIoErr.Extend(24) ErrIoErrGetTempPath = ErrIoErr.Extend(25) ErrIoErrConvPath = ErrIoErr.Extend(26) ErrBusyRecovery = ErrBusy.Extend(1) ErrBusySnapshot = ErrBusy.Extend(2) ErrCantOpenNoTempDir = ErrCantOpen.Extend(1) ErrCantOpenIsDir = ErrCantOpen.Extend(2) ErrCantOpenFullPath = ErrCantOpen.Extend(3) ErrCantOpenConvPath = ErrCantOpen.Extend(4) ErrCorruptVTab = ErrCorrupt.Extend(1) ErrReadonlyRecovery = ErrReadonly.Extend(1) ErrReadonlyCantLock = ErrReadonly.Extend(2) ErrReadonlyRollback = ErrReadonly.Extend(3) ErrReadonlyDbMoved = ErrReadonly.Extend(4) ErrAbortRollback = ErrAbort.Extend(2) ErrConstraintCheck = ErrConstraint.Extend(1) ErrConstraintCommitHook = ErrConstraint.Extend(2) ErrConstraintForeignKey = ErrConstraint.Extend(3) ErrConstraintFunction = ErrConstraint.Extend(4) ErrConstraintNotNull = ErrConstraint.Extend(5) ErrConstraintPrimaryKey = ErrConstraint.Extend(6) ErrConstraintTrigger = ErrConstraint.Extend(7) ErrConstraintUnique = ErrConstraint.Extend(8) ErrConstraintVTab = ErrConstraint.Extend(9) ErrConstraintRowID = ErrConstraint.Extend(10) ErrNoticeRecoverWAL = ErrNotice.Extend(1) ErrNoticeRecoverRollback = ErrNotice.Extend(2) ErrWarningAutoIndex = ErrWarning.Extend(1) )
result codes from http://www.sqlite.org/c3ref/c_abort_rollback.html
var ( ErrDBOpen = errors.New("failed to open the sql database") ErrUndo = errors.New("failed to undo the sql database") ErrFindRp = errors.New("cannot find a recover point") )
var (
PubNet bool
)
var SQLiteTimestampFormats = []string{
"2006-01-02 15:04:05.999999999-07:00",
"2006-01-02T15:04:05.999999999-07:00",
"2006-01-02 15:04:05.999999999",
"2006-01-02T15:04:05.999999999",
"2006-01-02 15:04:05",
"2006-01-02T15:04:05",
"2006-01-02 15:04",
"2006-01-02T15:04",
"2006-01-02",
}
SQLiteTimestampFormats is timestamp formats understood by both this module and SQLite. The first format in the slice will be used when saving time values into the database. When parsing a string from a timestamp or datetime column, the formats are tried in order.
Functions ¶
func CloseDatabase ¶
func CloseDatabase()
func CreateContractID ¶
func FreeLState ¶
func FreeLState(state *LState)
func IsRuntimeError ¶ added in v0.10.0
func LoadDatabase ¶
func LuaCallContract ¶
func LuaClearRecovery ¶ added in v0.8.1
func LuaCryptoSha256 ¶ added in v0.8.3
func LuaDelegateCallContract ¶
func LuaDeployContract ¶ added in v0.10.0
func LuaECVerify ¶ added in v0.8.3
func LuaGetBalance ¶ added in v0.8.2
func LuaGetBlockNo ¶ added in v0.8.2
func LuaGetBlockNo(L *LState, service *C.int) C.lua_Integer
func LuaGetPrevBlockHash ¶ added in v0.9.4
func LuaGetTimeStamp ¶ added in v0.8.2
func LuaGetTimeStamp(L *LState, service *C.int) C.lua_Integer
func LuaGovernance ¶ added in v1.0.0
func LuaIsContract ¶ added in v1.0.0
func LuaSendAmount ¶
func LuaSetRecoveryPoint ¶ added in v0.8.1
func NewLuaTxAccount ¶ added in v0.8.1
func NewLuaTxAccountBig ¶ added in v0.12.0
func NewLuaTxCall ¶ added in v0.8.1
func NewLuaTxCallBig ¶ added in v0.12.0
func NewLuaTxDef ¶ added in v0.8.1
func NewLuaTxSendBig ¶ added in v0.12.0
func NewRawLuaTxDef ¶ added in v1.0.0
func PreLoadRequest ¶
func PreLoadRequest(bs *state.BlockState, tx *types.Tx, preLoadService int)
func Query ¶
func Query(contractAddress []byte, bs *state.BlockState, contractState *state.ContractState, queryInfo []byte) (res []byte, err error)
func SaveRecoveryPoint ¶
func SaveRecoveryPoint(bs *state.BlockState) error
func SetPreloadTx ¶
func StartLStateFactory ¶ added in v0.9.9
func StartLStateFactory()
func StrToAddress ¶ added in v0.8.1
Types ¶
type ContractInfo ¶ added in v0.8.2
type ContractInfo struct {
// contains filtered or unexported fields
}
type DbSystemError ¶ added in v0.8.1
type DbSystemError struct {
// contains filtered or unexported fields
}
func (*DbSystemError) System ¶ added in v0.10.0
func (e *DbSystemError) System() bool
type DummyChain ¶ added in v0.8.1
type DummyChain struct {
// contains filtered or unexported fields
}
func LoadDummyChain ¶ added in v0.8.1
func LoadDummyChain() (*DummyChain, error)
func (*DummyChain) BeginReceiptTx ¶ added in v0.8.1
func (bc *DummyChain) BeginReceiptTx() db.Transaction
func (*DummyChain) BestBlockNo ¶ added in v0.8.1
func (bc *DummyChain) BestBlockNo() uint64
func (*DummyChain) ConnectBlock ¶ added in v0.8.1
func (bc *DummyChain) ConnectBlock(txs ...luaTx) error
func (*DummyChain) DisConnectBlock ¶ added in v0.8.1
func (bc *DummyChain) DisConnectBlock() error
func (*DummyChain) GetABI ¶ added in v0.8.1
func (bc *DummyChain) GetABI(contract string) (*types.ABI, error)
func (*DummyChain) GetAccountState ¶ added in v0.8.1
func (bc *DummyChain) GetAccountState(name string) (*types.State, error)
func (*DummyChain) GetStaking ¶ added in v1.0.0
func (bc *DummyChain) GetStaking(name string) (*types.Staking, error)
type ErrNoExtended ¶
type ErrNoExtended int
ErrNoExtended is extended errno.
func (ErrNoExtended) Error ¶
func (err ErrNoExtended) Error() string
Error return error message that is extended code.
type ErrRuntime ¶ added in v0.10.0
type ErrRuntime interface {
Runtime() bool
}
type Error ¶
type Error struct { Code ErrNo /* The error code returned by SQLite */ ExtendedCode ErrNoExtended /* The extended error code returned by SQLite */ // contains filtered or unexported fields }
Error implement sqlite error code.
type LState ¶
type LState = C.struct_lua_State
type ReadOnlyTx ¶
type ReadOnlyTx struct {
TxCommon
}
func (*ReadOnlyTx) Commit ¶
func (tx *ReadOnlyTx) Commit() error
func (*ReadOnlyTx) Release ¶
func (tx *ReadOnlyTx) Release() error
func (*ReadOnlyTx) Rollback ¶
func (tx *ReadOnlyTx) Rollback() error
func (*ReadOnlyTx) RollbackToSavepoint ¶
func (tx *ReadOnlyTx) RollbackToSavepoint() error
func (*ReadOnlyTx) RollbackToSubSavepoint ¶ added in v0.8.1
func (tx *ReadOnlyTx) RollbackToSubSavepoint(name string) error
func (*ReadOnlyTx) Savepoint ¶
func (tx *ReadOnlyTx) Savepoint() error
func (*ReadOnlyTx) SubRelease ¶ added in v0.8.1
func (tx *ReadOnlyTx) SubRelease(name string) error
func (*ReadOnlyTx) SubSavepoint ¶ added in v0.8.1
func (tx *ReadOnlyTx) SubSavepoint(name string) error
type SQLiteConn ¶
type SQLiteConn struct {
// contains filtered or unexported fields
}
SQLiteConn implements driver.Conn.
func (*SQLiteConn) AutoCommit ¶
func (c *SQLiteConn) AutoCommit() bool
AutoCommit return which currently auto commit or not.
func (*SQLiteConn) GetFilename ¶
func (c *SQLiteConn) GetFilename(schemaName string) string
GetFilename returns the absolute path to the file containing the requested schema. When passed an empty string, it will instead use the database's default schema: "main". See: sqlite3_db_filename, https://www.sqlite.org/c3ref/db_filename.html
func (*SQLiteConn) GetLimit ¶
func (c *SQLiteConn) GetLimit(id int) int
GetLimit returns the current value of a run-time limit. See: sqlite3_limit, http://www.sqlite.org/c3ref/limit.html
func (*SQLiteConn) Prepare ¶
func (c *SQLiteConn) Prepare(query string) (driver.Stmt, error)
Prepare the query string. Return a new statement.
func (*SQLiteConn) RegisterAggregator ¶
func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error
RegisterAggregator makes a Go type available as a SQLite aggregation function.
Because aggregation is incremental, it's implemented in Go with a type that has 2 methods: func Step(values) accumulates one row of data into the accumulator, and func Done() ret finalizes and returns the aggregate value. "values" and "ret" may be any type supported by RegisterFunc.
RegisterAggregator takes as implementation a constructor function that constructs an instance of the aggregator type each time an aggregation begins. The constructor must return a pointer to a type, or an interface that implements Step() and Done().
The constructor function and the Step/Done methods may optionally return an error in addition to their other return values.
See _example/go_custom_funcs for a detailed example.
func (*SQLiteConn) RegisterAuthorizer ¶
RegisterAuthorizer sets the authorizer for connection.
The parameters to the callback are the operation (one of the constants SQLITE_INSERT, SQLITE_DELETE, or SQLITE_UPDATE), and 1 to 3 arguments, depending on operation. More details see: https://www.sqlite.org/c3ref/c_alter_table.html
func (*SQLiteConn) RegisterCollation ¶
RegisterCollation makes a Go function available as a collation.
cmp receives two UTF-8 strings, a and b. The result should be 0 if a==b, -1 if a < b, and +1 if a > b.
cmp must always return the same result given the same inputs. Additionally, it must have the following properties for all strings A, B and C: if A==B then B==A; if A==B and B==C then A==C; if A<B then B>A; if A<B and B<C then A<C.
If cmp does not obey these constraints, sqlite3's behavior is undefined when the collation is used.
func (*SQLiteConn) RegisterCommitHook ¶
func (c *SQLiteConn) RegisterCommitHook(callback func() int)
RegisterCommitHook sets the commit hook for a connection.
If the callback returns non-zero the transaction will become a rollback.
If there is an existing commit hook for this connection, it will be removed. If callback is nil the existing hook (if any) will be removed without creating a new one.
func (*SQLiteConn) RegisterFunc ¶
func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error
RegisterFunc makes a Go function available as a SQLite function.
The Go function can have arguments of the following types: any numeric type except complex, bool, []byte, string and interface{}. interface{} arguments are given the direct translation of the SQLite data type: int64 for INTEGER, float64 for FLOAT, []byte for BLOB, string for TEXT.
The function can additionally be variadic, as long as the type of the variadic argument is one of the above.
If pure is true. SQLite will assume that the function's return value depends only on its inputs, and make more aggressive optimizations in its queries.
See _example/go_custom_funcs for a detailed example.
func (*SQLiteConn) RegisterRollbackHook ¶
func (c *SQLiteConn) RegisterRollbackHook(callback func())
RegisterRollbackHook sets the rollback hook for a connection.
If there is an existing rollback hook for this connection, it will be removed. If callback is nil the existing hook (if any) will be removed without creating a new one.
func (*SQLiteConn) RegisterUpdateHook ¶
func (c *SQLiteConn) RegisterUpdateHook(callback func(int, string, string, int64))
RegisterUpdateHook sets the update hook for a connection.
The parameters to the callback are the operation (one of the constants SQLITE_INSERT, SQLITE_DELETE, or SQLITE_UPDATE), the database name, the table name, and the rowid.
If there is an existing update hook for this connection, it will be removed. If callback is nil the existing hook (if any) will be removed without creating a new one.
func (*SQLiteConn) SetLimit ¶
func (c *SQLiteConn) SetLimit(id int, newVal int) int
SetLimit changes the value of a run-time limits. Then this method returns the prior value of the limit. See: sqlite3_limit, http://www.sqlite.org/c3ref/limit.html
type SQLiteDriver ¶
type SQLiteDriver struct { Extensions []string ConnectHook func(*SQLiteConn) error }
SQLiteDriver implements driver.Driver.
func (*SQLiteDriver) Open ¶
func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error)
Open database and return a new connection.
A pragma can take either zero or one argument. The argument is may be either in parentheses or it may be separated from the pragma name by an equal sign. The two syntaxes yield identical results. In many pragmas, the argument is a boolean. The boolean can be one of:
1 yes true on 0 no false off
You can specify a DSN string using a URI as the filename.
test.db file:test.db?cache=shared&mode=memory :memory: file::memory: mode Access mode of the database. https://www.sqlite.org/c3ref/open.html Values: - ro - rw - rwc - memory shared SQLite Shared-Cache Mode https://www.sqlite.org/sharedcache.html Values: - shared - private immutable=Boolean The immutable parameter is a boolean query parameter that indicates that the database file is stored on read-only media. When immutable is set, SQLite assumes that the database file cannot be changed, even by a process with higher privilege, and so the database is opened read-only and all locking and change detection is disabled. Caution: Setting the immutable property on a database file that does in fact change can result in incorrect query results and/or SQLITE_CORRUPT errors.
go-sqlite3 adds the following query parameters to those used by SQLite:
_loc=XXX Specify location of time format. It's possible to specify "auto". _mutex=XXX Specify mutex mode. XXX can be "no", "full". _txlock=XXX Specify locking behavior for transactions. XXX can be "immediate", "deferred", "exclusive". _auto_vacuum=X | _vacuum=X 0 | none - Auto Vacuum disabled 1 | full - Auto Vacuum FULL 2 | incremental - Auto Vacuum Incremental _busy_timeout=XXX"| _timeout=XXX Specify value for sqlite3_busy_timeout. _case_sensitive_like=Boolean | _cslike=Boolean https://www.sqlite.org/pragma.html#pragma_case_sensitive_like Default or disabled the LIKE operation is case-insensitive. When enabling this options behaviour of LIKE will become case-sensitive. _defer_foreign_keys=Boolean | _defer_fk=Boolean Defer Foreign Keys until outermost transaction is committed. _foreign_keys=Boolean | _fk=Boolean Enable or disable enforcement of foreign keys. _ignore_check_constraints=Boolean This pragma enables or disables the enforcement of CHECK constraints. The default setting is off, meaning that CHECK constraints are enforced by default. _journal_mode=MODE | _journal=MODE Set journal mode for the databases associated with the current connection. https://www.sqlite.org/pragma.html#pragma_journal_mode _locking_mode=X | _locking=X Sets the database connection locking-mode. The locking-mode is either NORMAL or EXCLUSIVE. https://www.sqlite.org/pragma.html#pragma_locking_mode _query_only=Boolean The query_only pragma prevents all changes to database files when enabled. _recursive_triggers=Boolean | _rt=Boolean Enable or disable recursive triggers. _secure_delete=Boolean|FAST When secure_delete is on, SQLite overwrites deleted content with zeros. https://www.sqlite.org/pragma.html#pragma_secure_delete _synchronous=X | _sync=X Change the setting of the "synchronous" flag. https://www.sqlite.org/pragma.html#pragma_synchronous _writable_schema=Boolean When this pragma is on, the SQLITE_MASTER tables in which database can be changed using ordinary UPDATE, INSERT, and DELETE statements. Warning: misuse of this pragma can easily result in a corrupt database file.
type SQLiteResult ¶
type SQLiteResult struct {
// contains filtered or unexported fields
}
SQLiteResult implements sql.Result.
func (*SQLiteResult) LastInsertId ¶
func (r *SQLiteResult) LastInsertId() (int64, error)
LastInsertId teturn last inserted ID.
func (*SQLiteResult) RowsAffected ¶
func (r *SQLiteResult) RowsAffected() (int64, error)
RowsAffected return how many rows affected.
type SQLiteRows ¶
type SQLiteRows struct {
// contains filtered or unexported fields
}
SQLiteRows implements driver.Rows.
func (*SQLiteRows) DeclTypes ¶
func (rc *SQLiteRows) DeclTypes() []string
DeclTypes return column types.
type SQLiteStmt ¶
type SQLiteStmt struct {
// contains filtered or unexported fields
}
SQLiteStmt implements driver.Stmt.
func (*SQLiteStmt) NumInput ¶
func (s *SQLiteStmt) NumInput() int
NumInput return a number of parameters.
type SQLiteTx ¶
type SQLiteTx struct {
// contains filtered or unexported fields
}
SQLiteTx implements driver.Tx.
type StateSet ¶
type StateSet struct {
// contains filtered or unexported fields
}
func NewContext ¶
func NewContextQuery ¶ added in v0.8.2
func NewContextQuery(blockState *state.BlockState, receiverId []byte, contractState *state.ContractState, node string, confirmed bool, rp uint64) *StateSet
type Tx ¶
type VmSystemError ¶ added in v1.0.0
type VmSystemError struct {
// contains filtered or unexported fields
}
func (*VmSystemError) System ¶ added in v1.0.0
func (e *VmSystemError) System() bool
type WritableTx ¶
func (*WritableTx) Commit ¶
func (tx *WritableTx) Commit() error
func (*WritableTx) Release ¶
func (tx *WritableTx) Release() error
func (*WritableTx) Rollback ¶
func (tx *WritableTx) Rollback() error
func (*WritableTx) RollbackToSavepoint ¶
func (tx *WritableTx) RollbackToSavepoint() error
func (*WritableTx) RollbackToSubSavepoint ¶ added in v0.8.1
func (tx *WritableTx) RollbackToSubSavepoint(name string) error
func (*WritableTx) Savepoint ¶
func (tx *WritableTx) Savepoint() error
func (*WritableTx) SubRelease ¶ added in v0.8.1
func (tx *WritableTx) SubRelease(name string) error
func (*WritableTx) SubSavepoint ¶ added in v0.8.1
func (tx *WritableTx) SubSavepoint(name string) error