sqlitesrc

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sqlitesrc manages the pinned SQLite release that meyer is tested against. It downloads the official artifacts, verifies their checksums, compiles the oracle program, and unpacks the test scripts.

The pin lives here so that every command shares one version, and the artifacts live in a cache directory (.sqlite/ by default, gitignored) that is reused across runs.

Index

Constants

View Source
const (
	Version = "3530400" // 3.53.4

)

The pinned SQLite release. When advancing the pin, update all four constants and parser/testdata/README.md, regenerate the corpus, and review the diff.

Variables

This section is empty.

Functions

func FuzzSeeds

func FuzzSeeds(cacheDir string) ([]string, error)

FuzzSeeds returns the SQL fuzz inputs SQLite ships in test/fuzzdata*.db: tens of thousands of strings that have broken a SQLite parser at some point. PLAN.md wants them as fuzz seeds rather than vendored, so they are read out through the oracle on demand. They are a very different input distribution from anything a mutation of valid SQL produces.

func Oracle

func Oracle(cacheDir string) (string, error)

Oracle returns the path to the compiled oracle binary, downloading the pinned amalgamation and building it on first use.

func SplitDiffers

func SplitDiffers(sql string) bool

SplitDiffers reports whether Run would cut a script into statements somewhere the tokenizer would not, which makes its verdict incomparable with a parser's.

The oracle splits the way the sqlite3 shell does, with sqlite3_complete, whose scanner is much cruder than the tokenizer: it understands strings, the four quoting styles and comments, but nothing else. So a ";" ends a statement for it even inside brackets, and even inside a token the real tokenizer would have swallowed whole -- ":v(a;b)" is one bind parameter to the tokenizer and two statements to sqlite3_complete. Any caller of Run inherits this, which is why it lives here rather than in one of them.

func TestScripts

func TestScripts(cacheDir string) (string, error)

TestScripts returns the directory holding the pinned release's test/*.test scripts, downloading and unpacking them on first use.

Types

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner drives one long-lived oracle process in batch mode. Starting a process per script costs more than classifying one, which matters when a caller checks tens of thousands of small inputs; a Runner amortises it away. Runners are not safe for concurrent use — start one per worker.

func NewRunner

func NewRunner(cacheDir string) (*Runner, error)

NewRunner starts an oracle process, building it first if necessary.

func (*Runner) Close

func (r *Runner) Close() error

Close shuts the oracle process down.

func (*Runner) Run

func (r *Runner) Run(sql string) ([]testfile.StmtResult, error)

Run classifies every statement of one script.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL