Versions in this module Expand all Collapse all v0 v0.4.0 Jun 8, 2026 v0.3.3 Jun 8, 2026 v0.3.2 Jun 8, 2026 v0.3.1 Jun 8, 2026 v0.3.0 Jun 8, 2026 Changes in this version + const OverflowPageHeaderSize + var ErrBadMagic = errors.New("sqlite: bad magic header") + var ErrBadPageSize = errors.New("sqlite: invalid page size") + var ErrBadPageType = errors.New("sqlite: invalid page type") + var ErrBadPayloadFrac = errors.New("sqlite: invalid payload fraction") + var ErrBadSerialType = errors.New("sqlite: invalid serial type") + var ErrCellTooSmall = errors.New("sqlite: cell data too small") + var ErrHeaderTooSmall = errors.New("sqlite: header data too small") + var ErrNoColumns = errors.New("sqlite: record has no columns") + var ErrPageHeaderTooSmall = errors.New("sqlite: page header data too small") + var ErrRecordTooSmall = errors.New("sqlite: record data too small") + var ErrTruncatedRecord = errors.New("sqlite: truncated record body") + var KeywordMap = map[string]TokenType + var NullValue = Value + func CloseDB(db *sql.DB) + func ComputePayloadSizes(payloadLen, usableSize int, isLeaf bool) (localSize, overflowSize int) + func DecodeVarint(data []byte) (int64, int, error) + func DecodeVarintRaw(data []byte) (uint64, int, error) + func EncodeVarint(v int64) []byte + func EncodeVarintInto(v uint64, buf []byte, off int) int + func EncodeVarintRaw(v uint64) []byte + func ExprString(expr Expr) string + func MaxOverflowPayload(usableSize int) int + func Open() (*sql.DB, error) + func OpenFile(path string) (*sql.DB, error) + func OpenWithData(data []byte) (*sql.DB, error) + func PutRecord(r *Record) + func ReadCellPointers(data []byte, offset int, count int) []uint16 + func ReadOverflowPage(data []byte, usableSize int) (nextPage uint32, payload []byte, err error) + func ReadRecordIntoRecord(data []byte, rec *Record, buf []Value) error + func VarintSize(v uint64) int + func WriteCell(c *Cell) []byte + func WriteCellPointers(ptrs []uint16) []byte + func WriteFreelistTrunk(trunk *FreelistTrunk, usableSize int) []byte + func WriteHeader(h *DatabaseHeader) []byte + func WriteInteriorTableCell(c *Cell) []byte + func WriteLeafTableCell(c *Cell) []byte + func WriteOverflowPage(nextPage uint32, payload []byte, usableSize int) []byte + func WritePageHeader(h *PageHeader) []byte + func WritePageHeaderTo(data []byte, h PageHeader) + func WriteRecord(r *Record) []byte + type AlterAddColumnStmt struct + Column ColumnDefAST + Table string + type AlterRenameColumnStmt struct + NewName string + OldName string + Table string + type AlterRenameTableStmt struct + NewName string + OldName string + type BTree struct + func NewBTree(pager *Pager) *BTree + func (b *BTree) CreateBTree() (int, error) + func (b *BTree) Delete(rootPage int, rowid int64) error + func (b *BTree) Insert(rootPage int, rowid int64, record *Record) error + func (b *BTree) Scan(rootPage int) (CursorInterface, error) + func (b *BTree) Search(rootPage int, rowid int64) (*Record, error) + type BTreeCursor struct + func (c *BTreeCursor) Close() error + func (c *BTreeCursor) Get() (int64, *Record, error) + func (c *BTreeCursor) Next() bool + func (c *BTreeCursor) RawRecordData() []byte + func (c *BTreeCursor) SeekToRowid(target int64) error + type BTreeInterface interface + CreateBTree func() (int, error) + Delete func(rootPage int, rowid int64) error + Insert func(rootPage int, rowid int64, record *Record) error + Scan func(rootPage int) (CursorInterface, error) + Search func(rootPage int, rowid int64) (*Record, error) + type BeginStmt struct + type BetweenExpr struct + Expr Expr + High Expr + Low Expr + Negate bool + func (e BetweenExpr) String() string + type BinaryExpr struct + Left Expr + Op BinaryOp + Right Expr + func (e BinaryExpr) String() string + type BinaryOp int + const OpAdd + const OpAnd + const OpBitAnd + const OpBitOr + const OpConcat + const OpDiv + const OpEq + const OpGe + const OpGt + const OpLe + const OpLt + const OpMod + const OpMul + const OpNe + const OpOr + const OpShiftLeft + const OpShiftRight + const OpSub + type CaseExpr struct + Else Expr + Operand Expr + Whens []CaseWhen + func (e CaseExpr) String() string + type CaseWhen struct + Condition Expr + Result Expr + type CastExpr struct + Expr Expr + Type string + func (e CastExpr) String() string + type Cell struct + IsLeaf bool + Key uint64 + LeftChildPage uint32 + OverflowPage uint32 + Payload []byte + PayloadSize uint64 + RowID uint64 + func ReadCell(data []byte, pageType byte) (*Cell, int, error) + type ColumnAffinity int + const AffinityBlob + const AffinityInteger + const AffinityNumeric + const AffinityReal + const AffinityText + func ResolveColumnAffinity(typeStr string) ColumnAffinity + type ColumnConstraint struct + Collate string + Name string + RefCols []string + RefTable string + Type ConstraintType + Value Expr + type ColumnDef struct + Affinity ColumnAffinity + Default *Value + IsPrimaryKey bool + IsRowID bool + Name string + NotNull bool + Type string + type ColumnDefAST struct + Constraints []ColumnConstraint + Name string + Type string + type ColumnRef struct + Column string + Table string + func CollectColumnRefs(expr Expr) []ColumnRef + func (e ColumnRef) String() string + type CommitStmt struct + type CompareResult int + const CompareEqual + const CompareGreater + const CompareLess + func CompareValues(a, b Value) CompareResult + type CompoundSelect struct + Left Statement + Limit Expr + Offset Expr + Op SetOp + OrderBy []OrderItem + Right Statement + type ConstraintType int + const ConstraintCheck + const ConstraintDefault + const ConstraintForeignKey + const ConstraintNotNull + const ConstraintPrimaryKey + const ConstraintUnique + type CreateIndexStmt struct + Columns []IndexedColumn + IfNotExists bool + Name string + Table string + Unique bool + Where Expr + type CreateTableStmt struct + Columns []ColumnDefAST + IfNotExists bool + Name string + type CreateViewStmt struct + As Statement + Name string + SQL string + type CursorInterface interface + Close func() error + Get func() (int64, *Record, error) + Next func() bool + RawRecordData func() []byte + type DataType int + const DataTypeBlob + const DataTypeFloat + const DataTypeInteger + const DataTypeNull + const DataTypeText + type DatabaseHeader struct + ApplicationID uint32 + DatabaseSizePages uint32 + DefaultPageCacheSize uint32 + FileChangeCounter uint32 + FileFormatReadVersion uint8 + FileFormatWriteVersion uint8 + FirstFreelistTrunkPage uint32 + IncrementalVacuum uint32 + LargestRootBTreePage uint32 + LeafPayloadFrac uint8 + Magic [16]byte + MaxEmbeddedPayloadFrac uint8 + MinEmbeddedPayloadFrac uint8 + PageSize int + ReservedExpansion [20]byte + ReservedSpace uint8 + SQLiteVersionNumber uint32 + SchemaCookie uint32 + SchemaFormatNumber uint32 + TextEncoding uint32 + TotalFreelistPages uint32 + UserVersion uint32 + VersionValidFor uint32 + func ReadHeader(data []byte) (*DatabaseHeader, error) + type DeleteStmt struct + Table TableRef + Where Expr + type DiskFile struct + func OpenDiskFile(path string) (*DiskFile, error) + func (d *DiskFile) Close() error + func (d *DiskFile) Len() int64 + func (d *DiskFile) ReadAt(p []byte, off int64) (int, error) + func (d *DiskFile) Sync() error + func (d *DiskFile) Truncate(size int64) error + func (d *DiskFile) WriteAt(p []byte, off int64) (int, error) + type DropIndexStmt struct + IfExists bool + Name string + type DropTableStmt struct + IfExists bool + Name string + type DropViewStmt struct + IfExists bool + Name string + type Engine struct + func NewEngine(pager PagerInterface, btree BTreeInterface) *Engine + func RawEngine() (*Engine, error) + func (e *Engine) Close() error + func (e *Engine) Execute(sql string, params ...Value) (*Result, error) + func (e *Engine) ExecuteAll(sql string, params ...Value) ([]*Result, error) + func (e *Engine) ExecuteStatement(stmt Statement, params ...Value) (*Result, error) + func (e *Engine) ExecuteWithCache(sql string, params ...Value) (*Result, error) + func (e *Engine) LoadSchema() error + func (e *Engine) SaveSchema() error + func (e *Engine) Schema() *Schema + type Expr interface + type ExprEval struct + ColumnMap map[string]int + Engine *Engine + Params []Value + Row []Value + TableMap map[string]map[string]int + func NewExprEval(row []Value) *ExprEval + func (e *ExprEval) Eval(expr Expr) (Value, error) + func (e *ExprEval) EvalAggregateAware(expr Expr, outputCols []outCol, aggRow []Value, groupRows [][]Value) (Value, error) + type FileBackend interface + Close func() error + Len func() int64 + ReadAt func(p []byte, off int64) (int, error) + Sync func() error + Truncate func(size int64) error + WriteAt func(p []byte, off int64) (int, error) + type ForeignKeyInfo struct + FromCol int + ToCols []string + ToTable string + type FreelistTrunk struct + LeafPages []uint32 + NextTrunkPage uint32 + func ReadFreelistTrunk(data []byte, usableSize int) (*FreelistTrunk, error) + type FromClause struct + Joins []JoinClause + Table *TableRef + type FunctionCall struct + Args []Expr + Distinct bool + Name string + Star bool + func (e FunctionCall) String() string + type InExpr struct + Expr Expr + Negate bool + Select *SelectStmt + Values []Expr + func (e InExpr) String() string + type IndexInfo struct + Columns []string + Name string + RootPage int + SQL string + TableName string + Unique bool + Where string + type IndexedColumn struct + Collate string + Desc bool + Name string + type InsertStmt struct + Columns []string + Select *SelectStmt + Table TableRef + Values [][]Expr + type IsNullExpr struct + Expr Expr + Negate bool + func (e IsNullExpr) String() string + type JoinClause struct + On Expr + Table TableRef + Type JoinType + Using []string + type JoinType int + const JoinCross + const JoinFull + const JoinInner + const JoinLeft + const JoinRight + type Lexer struct + func NewLexer(input string) *Lexer + func (l *Lexer) Next() Token + func (l *Lexer) Tokenize() ([]Token, error) + type LikeExpr struct + Escape Expr + Expr Expr + Negate bool + Op LikeOp + Pattern Expr + func (e LikeExpr) String() string + type LikeOp int + const LikeGlob + const LikeLike + type LiteralExpr struct + BlobVal []byte + FloatVal float64 + IntVal int64 + TextVal string + Type DataType + func (e LiteralExpr) String() string + type MemFile struct + func NewMemFile() *MemFile + func (m *MemFile) Bytes() []byte + func (m *MemFile) Close() error + func (m *MemFile) Len() int64 + func (m *MemFile) ReadAt(p []byte, off int64) (int, error) + func (m *MemFile) Sync() error + func (m *MemFile) Truncate(size int64) error + func (m *MemFile) WriteAt(p []byte, off int64) (int, error) + type OrderItem struct + Desc bool + Expr Expr + type PageHeader struct + CellCount uint16 + ContentOffset uint16 + FirstFreeblock uint16 + FragmentedBytes uint8 + PageType byte + RightMostPtr uint32 + func ReadPageHeader(data []byte, isFirst bool) (*PageHeader, error) + func ReadPageHeaderFrom(data []byte) PageHeader + func (h *PageHeader) HeaderSize() int + type Pager struct + func NewPager(file FileBackend, pageSize int) (*Pager, error) + func (p *Pager) AllocatePage() (int, error) + func (p *Pager) BeginTxn() + func (p *Pager) Close() error + func (p *Pager) CommitTxn() + func (p *Pager) Flush() error + func (p *Pager) GetHeader() *DatabaseHeader + func (p *Pager) GetPageBuffer() []byte + func (p *Pager) GetPageData(num int) ([]byte, error) + func (p *Pager) GetPageDataMutable(num int) ([]byte, error) + func (p *Pager) GetPageDataReadOnly(num int) ([]byte, error) + func (p *Pager) GetPageSize() int + func (p *Pager) GetSchemaPage() int + func (p *Pager) InitNew() error + func (p *Pager) LoadHeader() error + func (p *Pager) PageCount() int + func (p *Pager) PageHeaderOffset(pageNum int) int + func (p *Pager) PutPageBuffer(b []byte) + func (p *Pager) Restore(data []byte) error + func (p *Pager) RollbackTxn() error + func (p *Pager) SetPageData(num int, data []byte) error + func (p *Pager) SetSchemaPage(page int) + func (p *Pager) Snapshot() []byte + func (p *Pager) UpdateHeader(h *DatabaseHeader) error + type PagerInterface interface + AllocatePage func() (int, error) + BeginTxn func() + Close func() error + CommitTxn func() + Flush func() error + GetPageData func(num int) ([]byte, error) + GetPageDataMutable func(num int) ([]byte, error) + GetPageSize func() int + GetSchemaPage func() int + PageCount func() int + Restore func([]byte) error + RollbackTxn func() error + SetPageData func(num int, data []byte) error + SetSchemaPage func(page int) + Snapshot func() []byte + type ParamExpr struct + Index int + Name string + func (e ParamExpr) String() string + type ParenExpr struct + Expr Expr + func (e ParenExpr) String() string + type ParseError struct + Col int + Line int + Msg string + func (e *ParseError) Error() string + type Parser struct + func NewParser(sql string) *Parser + func (p *Parser) Parse() (Statement, error) + func (p *Parser) ParseAll() ([]Statement, error) + type PragmaStmt struct + Name string + Value Expr + type Record struct + Columns []Value + func GetRecord() *Record + func ReadRecord(data []byte) (*Record, error) + func ReadRecordInto(data []byte, buf []Value) (*Record, error) + type ReindexStmt struct + TableName string + type Result struct + Columns []string + LastInsertID int64 + Rows [][]Value + RowsAffected int64 + type RollbackStmt struct + type RowIDExpr struct + func (e RowIDExpr) String() string + type Schema struct + func NewSchema() *Schema + func (s *Schema) AddIndex(info *IndexInfo) + func (s *Schema) AddTable(info *TableInfo) + func (s *Schema) Copy() *Schema + func (s *Schema) DropIndex(name string) bool + func (s *Schema) DropTable(name string) bool + func (s *Schema) GetIndex(name string) (*IndexInfo, bool) + func (s *Schema) GetTable(name string) (*TableInfo, bool) + func (s *Schema) IndexNames() []string + func (s *Schema) IndexesForTable(tableName string) []*IndexInfo + func (s *Schema) RenameTable(oldName, newName string) bool + func (s *Schema) TableNames() []string + type SelectColumn struct + As string + Expr Expr + type SelectStmt struct + Columns []SelectColumn + Distinct bool + From *FromClause + GroupBy []Expr + Having Expr + Limit Expr + Offset Expr + OrderBy []OrderItem + Where Expr + type SetClause struct + Column string + Expr Expr + type SetOp int + const SetOpExcept + const SetOpIntersect + const SetOpUnion + const SetOpUnionAll + type StarColumn struct + func (e StarColumn) String() string + type Statement interface + type SubqueryExpr struct + Select *SelectStmt + type TableInfo struct + AutoInc int64 + Columns []ColumnDef + ForeignKeys []ForeignKeyInfo + Name string + PrimaryKey int + RootPage int + SQL string + func BuildTableInfo(stmt *CreateTableStmt, rootPage int) *TableInfo + func (t *TableInfo) ColumnByName(name string) (ColumnDef, bool) + func (t *TableInfo) ColumnIndex(name string) int + func (t *TableInfo) HasRowIDAlias() bool + func (t *TableInfo) NextAutoIncrement() int64 + func (t *TableInfo) RowIDAliasColumn() string + func (t *TableInfo) SetAutoIncrement(v int64) + type TableRef struct + As string + Name string + Schema string + type Token struct + Col int + Line int + Pos int + Type TokenType + Value string + func (t Token) String() string + type TokenType int + const TokenADD + const TokenALL + const TokenALTER + const TokenAND + const TokenAS + const TokenASC + const TokenAUTOINCREMENT + const TokenAnd + const TokenBEGIN + const TokenBETWEEN + const TokenBLOB_KW + const TokenBY + const TokenBlob + const TokenCASE + const TokenCAST + const TokenCHECK + const TokenCOLLATE + const TokenCOLUMN + const TokenCOMMIT + const TokenCREATE + const TokenComma + const TokenConcat + const TokenDEFAULT + const TokenDELETE + const TokenDESC + const TokenDISTINCT + const TokenDROP + const TokenDot + const TokenDoubleEqual + const TokenELSE + const TokenEND + const TokenEOF + const TokenEXCEPT + const TokenEXISTS + const TokenEqual + const TokenError + const TokenFOREIGN + const TokenFROM + const TokenFloat + const TokenGLOB + const TokenGROUP + const TokenGreater + const TokenGreaterEq + const TokenHAVING + const TokenIF + const TokenIN + const TokenINDEX + const TokenINNER + const TokenINSERT + const TokenINTEGER_KW + const TokenINTERSECT + const TokenINTO + const TokenIS + const TokenIdent + const TokenInteger + const TokenJOIN + const TokenKEY + const TokenLEFT + const TokenLIKE + const TokenLIMIT + const TokenLParen + const TokenLess + const TokenLessEq + const TokenMinus + const TokenNOT + const TokenNULL + const TokenNot + const TokenNotEqual + const TokenOFFSET + const TokenON + const TokenOR + const TokenORDER + const TokenOUTER + const TokenOr + const TokenPRAGMA + const TokenPRIMARY + const TokenPercent + const TokenPlus + const TokenQuestion + const TokenQuotedID + const TokenREAL_KW + const TokenREFERENCES + const TokenREINDEX + const TokenRENAME + const TokenRIGHT + const TokenROLLBACK + const TokenROWID + const TokenRParen + const TokenSELECT + const TokenSET + const TokenSemicolon + const TokenSlash + const TokenStar + const TokenString + const TokenTABLE + const TokenTEXT_KW + const TokenTHEN + const TokenTO + const TokenTRANSACTION + const TokenTilde + const TokenUNION + const TokenUNIQUE + const TokenUPDATE + const TokenVACUUM + const TokenVALUES + const TokenVIEW + const TokenWHEN + const TokenWHERE + type UnaryExpr struct + Expr Expr + Op UnaryOp + func (e UnaryExpr) String() string + type UnaryOp int + const OpBitNot + const OpNegate + const OpNot + type UpdateStmt struct + Sets []SetClause + Table TableRef + Where Expr + type VacuumStmt struct + type Value struct + BlobVal []byte + FloatVal float64 + IntVal int64 + TextVal string + Type DataType + func ApplyAffinity(v Value, affinity ColumnAffinity) Value + func BlobValue(v []byte) Value + func DecodeRecordColumn(data []byte, colIdx int) (Value, error) + func FloatValue(v float64) Value + func IntegerValue(v int64) Value + func TextValue(v string) Value + func (v Value) AsFloat64() (float64, bool) + func (v Value) AsInt64() (int64, bool) + func (v Value) AsText() string + func (v Value) IsNull() bool + func (v Value) String() string + type ViewInfo struct + As Statement + Name string + SQL string v0.2.2 Jun 1, 2026 v0.2.1 Jun 1, 2026 v0.2.0 Jun 1, 2026