// Package sqlite3 wraps the C SQLite API.
package sqlite3 import ( _ sqlite3_wasm ) type configKey struct{} // WithMaxMemory returns a derived context that configures // each SQLite connection not to use more than max amount of memory. func ( context.Context, int64) context.Context { if < 0 || > 65536*65536 { panic(errutil.OOMErr) } return context.WithValue(, configKey{}, /65536) } //go:linkname createWrapper func createWrapper( context.Context) (*sqlite3_wrap.Wrapper, error) { := &sqlite3_wrap.Memory{Max: 4096} // 256MB if bits.UintSize < 64 { .Max = 512 // 32MB } if , := .Value(configKey{}).(int64); { .Max = max(, int64(len(.Buf))/65536) } .Grow(5 /*320KB*/, .Max) := env{&sqlite3_wrap.Wrapper{Memory: }} .Module = sqlite3_wasm.New() .X_initialize() return .Wrapper, nil } //go:linkname connBad func connBad( *Conn) bool { return .wrp.Module == nil || .stack != *.wrp.X__stack_pointer() } type env struct{ *sqlite3_wrap.Wrapper } func ( env) ( int32) int32 { if vfs.Find(.ReadString(ptr_t(), _MAX_NAME)) != nil { return 1 } return 0 }