musiclink/vendor/modernc.org/sqlite
2026-01-21 22:42:18 -08:00
..
lib Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
vtab Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
AUTHORS Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
backup.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
bench.png Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
builder.json Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
CHANGELOG.md Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
conn.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
CONTRIBUTORS Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
convert.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
dmesg.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
doc.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
driver.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
embed.db Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
embed2.db Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
error.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
fcntl.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
HACKING.md Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
issue120.diff Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
LICENSE Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
logo.png Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
Makefile Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
mutex.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
nodmesg.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
norlimit.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
pre_update_hook.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
README.md Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
result.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
rlimit.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
rows.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
rulimit.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
SQLITE-LICENSE Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
sqlite.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
stmt.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
tpch.sh Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
tx.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
unconvert.sh Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00
vtab.go Update vendor directory and flake hash 2026-01-21 22:42:18 -08:00

Important: Repository Mirroring

This project is primarily developed on GitLab. The repository you are currently viewing might be a mirror. Please review the guidelines below based on where you are viewing this:

Platform Role Contributing Guidelines
GitLab Primary Source This is the canonical repository (cznic/sqlite). CI pipelines and main development happen here.
GitHub Mirror This is a mirror (modernc-org/sqlite). We do accept Issues and Pull Requests here for your convenience!
Note: PRs submitted here will be manually merged into the GitLab source, so please allow extra time for processing.

Go Reference LiberaPay receives patrons


heart Github Sponsors Account / j-modernc-org

Enterprise Infrastructure Tier Sponsor

tailscale Tailscale

Startup / Small Business Tier Sponsor

octoberswimmer October Swimmer


benchmarks The SQLite Drivers Benchmarks Game


Virtual Tables (vtab)

The driver exposes a Go API to implement SQLite virtual table modules in pure Go via the modernc.org/sqlite/vtab package. This lets you back SQL tables with arbitrary data sources (e.g., vector indexes, CSV files, remote APIs) and integrate with SQLites planner.

  • Register: vtab.RegisterModule(db, name, module). Registration applies to new connections only.
  • Schema declaration: Call ctx.Declare("CREATE TABLE <name>(<cols...>)") within Create or Connect. The driver does not auto-declare schemas, enabling dynamic schemas.
  • Module arguments: args []string passed to Create/Connect are configuration parsed from USING module(...). They are not treated as columns unless your module chooses to.
  • Planning (BestIndex):
    • Inspect info.Constraints (with Column, Op, Usable, 0-based ArgIndex, and Omit), info.OrderBy, and info.ColUsed (bitmask of referenced columns).
    • Set ArgIndex (0-based) to populate Filters vals in the chosen order; set Omit to ask SQLite not to re-check a constraint you fully handle.
  • Execution: Cursor.Filter(idxNum, idxStr, vals) receives arguments in the order implied by ArgIndex.
  • Operators: Common SQLite operators map to ConstraintOp (EQ/NE/GT/GE/LT/LE/MATCH/IS/ISNOT/ISNULL/ISNOTNULL/LIKE/GLOB/REGEXP/FUNCTION/LIMIT/OFFSET). Unknown operators map to OpUnknown.
  • Errors: Returning an error from vtab methods surfaces a descriptive message to SQLite (e.g., zErrMsg for xCreate/xConnect/xBestIndex/xFilter; sqlite3_result_error for xColumn).

Examples

  • Vector search (sqlite-vec style):

    • CREATE VIRTUAL TABLE vec_docs USING vec(dim=128, metric="cosine")
    • Module reads args (e.g., dim, metric), calls ctx.Declare("CREATE TABLE vec_docs(id, embedding, content HIDDEN)"), and implements search via BestIndex/Filter.
  • CSV loader:

    • CREATE VIRTUAL TABLE csv_users USING csv(filename="/tmp/users.csv", delimiter=",", header=true)
    • Module reads the file header to compute columns, declares them via ctx.Declare("CREATE TABLE csv_users(name, email, ...)"), and streams rows via a cursor.

See vtab package docs for full API details.