mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Tests.
This commit is contained in:
29
vtab.go
29
vtab.go
@@ -66,6 +66,9 @@ func implements[T any](typ reflect.Type) bool {
|
||||
return typ.Implements(reflect.TypeOf(ptr).Elem())
|
||||
}
|
||||
|
||||
// DeclareVtab declares the schema of a virtual table.
|
||||
//
|
||||
// https://sqlite.org/c3ref/declare_vtab.html
|
||||
func (c *Conn) DeclareVtab(sql string) error {
|
||||
// defer c.arena.reset()
|
||||
sqlPtr := c.arena.string(sql)
|
||||
@@ -73,6 +76,32 @@ func (c *Conn) DeclareVtab(sql string) error {
|
||||
return c.error(r)
|
||||
}
|
||||
|
||||
// IndexConstraintOp is a virtual table constraint operator code.
|
||||
//
|
||||
// https://sqlite.org/c3ref/c_vtab_constraint_support.html
|
||||
type VtabConfigOption uint8
|
||||
|
||||
const (
|
||||
VTAB_CONSTRAINT_SUPPORT VtabConfigOption = 1
|
||||
VTAB_INNOCUOUS VtabConfigOption = 2
|
||||
VTAB_DIRECTONLY VtabConfigOption = 3
|
||||
VTAB_USES_ALL_SCHEMAS VtabConfigOption = 4
|
||||
)
|
||||
|
||||
// VtabConfig configures various facets of the virtual table interface.
|
||||
//
|
||||
// https://sqlite.org/c3ref/vtab_config.html
|
||||
func (c *Conn) VtabConfig(op VtabConfigOption, args ...any) error {
|
||||
var i uint64
|
||||
if op == VTAB_CONSTRAINT_SUPPORT && len(args) > 0 {
|
||||
if b, ok := args[0].(bool); ok && b {
|
||||
i = 1
|
||||
}
|
||||
}
|
||||
r := c.call(c.api.vtabConfig, uint64(c.handle), uint64(op), i)
|
||||
return c.error(r)
|
||||
}
|
||||
|
||||
// VTabConstructor is a virtual table constructor function.
|
||||
type VTabConstructor[T VTab] func(db *Conn, arg ...string) (T, error)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user