ext/

directory
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0

README

ext/ — loadable Go extensions

Optional SQL extensions you can register on a connection. Each sub-package is independent: pick the ones you need, leave the rest off your import graph.

Two registration shapes per extension:

// Explicit — register on a specific *sqlite.Conn (the per-conn idiom).
import "gosqlite.org/ext/regexp"
regexp.Register(conn)

// Implicit — blank-import auto-wires via Driver.ConnectHook so every
// connection the driver opens picks the extension up.
import _ "gosqlite.org/ext/regexp/auto"

The explicit form is canonical; the /auto blank-import is a thin shim that calls Register from a ConnectHook so the extension survives connection pool churn.

Available extensions

Coverage matrix and status (✓ landed / ⚠ partial / ✗ deferred) lives at dev/coverage/ext.md. Shipped today:

Package What it gives you
array Eponymous vtab that exposes a bound Go slice as a single-column SQL table. Two binding styles: transparent via sqlite.Pointer(slice) (preferred — SQLite's destructor releases on stmt finalize) or explicit array.Bind(c, slice) → token, release() for long-lived bindings.
csv Virtual table over RFC 4180 CSV files. CREATE VIRTUAL TABLE name USING csv(filename='x.csv', header=on, schema='CREATE TABLE x(a INTEGER, b TEXT)'). csv.Register(c) opens via os.Open; csv.RegisterFS(c, fsys) sandboxes to any fs.FS.
regexp regexp_like, regexp_count, regexp_instr, regexp_substr, regexp_replace, and the binary REGEXP operator over Go's regexp (RE2 syntax).
uuid uuid([ver, ns, data]), gen_random_uuid, uuid_str/blob/extract_* over github.com/google/uuid. v1 / v3 / v4 / v5 / v6 / v7 (DCE Security v2 not implemented).
hash md4, md5, sha1, sha224, sha256, sha384, sha512, sha3, blake2s, blake2b, blake3 (XOF, byte-sized), xxh64, ripemd160 with size variants. crypto.Hash algorithms gated on .Available(); blake3 / xxh64 always registered.
ipaddr ipcontains, ipoverlaps, ipfamily, iphost, ipmasklen, ipnetwork over net/netip. Fixes an upstream ipoverlaps self-reference bug.
zorder zorder(d1, …, dN) / unzorder(z, N, i) Morton encoding for 2–24 dimensions.
stats Aggregates + windows: var_pop/var_samp/stddev_*, skewness_*, kurtosis_*, covar_*, corr, the full regr_* family, percentile_cont/disc, median, mode, every, some. Welford + Terriberry + Kahan; streaming Inverse path for sliding windows. Plus cbrt, cot scalars.
unicode Unicode-aware upper / lower / initcap / casefold / normalize (NFC/NFD/NFKC/NFKD) / unaccent via golang.org/x/text. Preset NOCASE_UNICODE and NOCASE_ACCENT collations register automatically. RegisterLocaleCollation(c, locale, name) for BCP-47-tagged collators. Unicode-aware LIKE override is opt-in via unicode.Register(c, unicode.WithLike()).
blobio readblob(schema, table, column, rowid) / writeblob(...) scalars over sqlite3_blob_open, plus the typed (*Conn).OpenBlob API. Stream large zeroblob(N) allocations in/out of TEXT/BLOB columns without materialising in memory.
bloom Persistent Bloom-filter vtab. CREATE VIRTUAL TABLE name USING bloom(capacity=N, error_rate=R, ...); shadow-blob persistence so the filter survives reopens. Kirsch-Mitzenmacher double-hashing with stable per-table salts.
closure transitive_closure(root_col, depth) vtab — full and depth-bounded graph walks over an adjacency-list table. Eponymous; WHERE root=? AND depth<=? parametrises each walk.
fileio readfile(path) / writefile(path, data, mode) scalars + fsdir(path, depth) recursive walker vtab. fileio.Register(c) uses the live OS; fileio.RegisterFS(c, fsys) sandboxes to any fs.FS (writefile then errors).
lines Eponymous vtab lines(text) that yields one row per line. Streams via bufio.Scanner so large blobs of text don't materialise twice.
pivot pivot_vtab(...) three-SELECT cross-tab — rows × columns × cell aggregate. Constructs a dynamic schema from the column-key projection and caches the cell-aggregate stmt per cell.
spellfix1 CREATE VIRTUAL TABLE name USING spellfix1 — fuzzy lookup vtab. Soundex prefilter + Damerau-Levenshtein edit-distance ranking, persistent vocabulary shadow table. Go-native re-implementation of SQLite's spellfix1 (same SQL surface, simpler internals).
statement CREATE VIRTUAL TABLE name USING statement(sql='...') — parametrised views. ?N anonymous and :name named binds become HIDDEN columns on the vtab; SELECTs ... WHERE :pat=? drive the underlying prepared stmt.
rtree R-Tree spatial index: the built-in rtree/geopoly vtabs plus a typed rtree.Table (Create/Insert/InsertPoint/Search bounding-box/SearchCircle/Delete/Drop) and a ready-made circle(cx, cy, r) geometry. Arbitrary geometry via root (*Conn).RegisterRTreeGeometry / RegisterRTreeQuery.
series generate_series(start, stop[, step]) table-valued function — an integer sequence usable as a SQL table source.
text Rune-aware string scalars SQLite lacks: text_reverse, text_repeat, text_lpad, text_rpad, text_split.
fuzzy Approximate string matching: levenshtein, damerau_levenshtein, hamming, jaro, jaro_winkler, soundex. Rune-aware distances; the stateless-scalar cousin of spellfix1.
encode encode(data, format) / decode(text, format) for base64 / base64url / base32 / base32hex / base16 / ascii85 / url. The codec half of sqlean crypto; digests live in ext/hash.
regexp/gorm gorm helpers built on ext/regexp. regexpgorm.WhereRegex(db, col, pattern) adds a col REGEXP ? clause without touching the dialect.

Attribution

Several extensions are Go-native ports of ncruces/go-sqlite3 extensions. The function lineup and semantics follow upstream closely; the runtime is different (we target modernc.org/sqlite, ncruces targets a Wazero-based WASM build). See LICENSE.ncruces and the NOTICE attribution.

Adding a new extension

See the bottom of dev/coverage/ext.md for the per-extension scaffolding checklist.

Directories

Path Synopsis
Package array provides the `array` table-valued SQL function — a way to feed a Go slice into a SQL query as a single-column table.
Package array provides the `array` table-valued SQL function — a way to feed a Go slice into a SQL query as a single-column table.
auto
Package auto wires the array extension via a sqlite.Driver.ConnectHook so every new connection auto-registers the `array` module.
Package auto wires the array extension via a sqlite.Driver.ConnectHook so every new connection auto-registers the `array` module.
Package blobio exposes SQLite's incremental BLOB I/O API as SQL scalar functions, so callers can stream parts of large BLOBs from SQL without materializing the whole row into memory.
Package blobio exposes SQLite's incremental BLOB I/O API as SQL scalar functions, so callers can stream parts of large BLOBs from SQL without materializing the whole row into memory.
auto
Package auto wires the blobio extension via a sqlite.Driver.ConnectHook so every new connection registers readblob and writeblob.
Package auto wires the blobio extension via a sqlite.Driver.ConnectHook so every new connection registers readblob and writeblob.
Package bloom provides a Bloom filter virtual table — a space-efficient probabilistic structure for set-membership testing.
Package bloom provides a Bloom filter virtual table — a space-efficient probabilistic structure for set-membership testing.
auto
Package auto wires the bloom extension via a sqlite.Driver.ConnectHook so every new connection registers the `bloom` vtab module.
Package auto wires the bloom extension via a sqlite.Driver.ConnectHook so every new connection registers the `bloom` vtab module.
Package closure implements the `transitive_closure` virtual table: a parent-child graph walker that returns every descendant of a given node, with optional depth bounds.
Package closure implements the `transitive_closure` virtual table: a parent-child graph walker that returns every descendant of a given node, with optional depth bounds.
auto
Package auto wires the transitive_closure extension via a sqlite.Driver.ConnectHook so every new connection registers the vtab.
Package auto wires the transitive_closure extension via a sqlite.Driver.ConnectHook so every new connection registers the vtab.
csv
Package csv exposes RFC 4180 comma-separated values as a SQLite virtual table.
Package csv exposes RFC 4180 comma-separated values as a SQLite virtual table.
auto
Package auto wires the csv extension via a sqlite.Driver.ConnectHook so every new connection auto-registers the `csv` module with os-backed file access.
Package auto wires the csv extension via a sqlite.Driver.ConnectHook so every new connection auto-registers the `csv` module with os-backed file access.
Package decimal adds exact base-10 arithmetic scalar functions, for workloads where binary floating point's rounding is unacceptable (money, tax, billing).
Package decimal adds exact base-10 arithmetic scalar functions, for workloads where binary floating point's rounding is unacceptable (money, tax, billing).
auto
Package auto wires the decimal_* scalar + aggregate functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the decimal_* scalar + aggregate functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package encode adds `encode(data, format)` and `decode(text, format)` scalar functions covering the common binary-to-text codecs SQLite lacks (only hex/quote are built in):
Package encode adds `encode(data, format)` and `decode(text, format)` scalar functions covering the common binary-to-text codecs SQLite lacks (only hex/quote are built in):
auto
Package auto wires the encode / decode scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the encode / decode scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package eval adds an eval() scalar function that runs dynamic SQL on the calling connection and returns the result as text — sqlean's distinctive "SQL from SQL" capability, which no other pure-Go SQLite driver exposes.
Package eval adds an eval() scalar function that runs dynamic SQL on the calling connection and returns the result as text — sqlean's distinctive "SQL from SQL" capability, which no other pure-Go SQLite driver exposes.
auto
Package auto wires the eval() function via a sqlite.Driver.ConnectHook so every new connection registers it.
Package auto wires the eval() function via a sqlite.Driver.ConnectHook so every new connection registers it.
Package fileio exposes SQL functions and a virtual table for reading and walking files.
Package fileio exposes SQL functions and a virtual table for reading and walking files.
auto
Package auto wires the fileio extension via a sqlite.Driver.ConnectHook so every new connection registers readfile, writefile, lsmode, and the fsdir vtab.
Package auto wires the fileio extension via a sqlite.Driver.ConnectHook so every new connection registers readfile, writefile, lsmode, and the fsdir vtab.
Package fuzzy adds approximate-string-matching SQL scalar functions — edit distances, the Jaro / Jaro-Winkler similarity, and the Soundex phonetic code:
Package fuzzy adds approximate-string-matching SQL scalar functions — edit distances, the Jaro / Jaro-Winkler similarity, and the Soundex phonetic code:
auto
Package auto wires the fuzzy string-matching scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the fuzzy string-matching scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package hash provides cryptographic hash SQL functions.
Package hash provides cryptographic hash SQL functions.
auto
Package auto wires the hash extension via a sqlite.Driver.ConnectHook so every new connection registers the SQL hash functions.
Package auto wires the hash extension via a sqlite.Driver.ConnectHook so every new connection registers the SQL hash functions.
internal
bigdec
Package bigdec is the exact base-10 arithmetic backend shared by ext/decimal and ext/money.
Package bigdec is the exact base-10 arithmetic backend shared by ext/decimal and ext/money.
filevtab
Package filevtab holds the file-backed virtual-table scaffolding shared by the file-reading ext modules (ext/csv, ext/lines).
Package filevtab holds the file-backed virtual-table scaffolding shared by the file-reading ext modules (ext/csv, ext/lines).
Package ipaddr provides typed IP / CIDR helper functions for SQL queries.
Package ipaddr provides typed IP / CIDR helper functions for SQL queries.
auto
Package auto wires the ipaddr extension via a sqlite.Driver.ConnectHook so every new connection registers the IP / CIDR helpers.
Package auto wires the ipaddr extension via a sqlite.Driver.ConnectHook so every new connection registers the IP / CIDR helpers.
Package lines exposes a text file as a SQLite virtual table — one row per line.
Package lines exposes a text file as a SQLite virtual table — one row per line.
auto
Package auto wires the lines extension via sqlite.Driver.ConnectHook so every new connection registers the `lines` vtab module with os-backed file access.
Package auto wires the lines extension via sqlite.Driver.ConnectHook so every new connection registers the `lines` vtab module with os-backed file access.
Package money adds fixed-point currency scalar functions over the same exact base-10 backend as ext/decimal.
Package money adds fixed-point currency scalar functions over the same exact base-10 backend as ext/decimal.
auto
Package auto wires the money_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the money_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package pivot implements a pivot virtual table — a parametrized cross-tab over three caller-supplied SELECT statements:
Package pivot implements a pivot virtual table — a parametrized cross-tab over three caller-supplied SELECT statements:
auto
Package auto wires the pivot extension via a sqlite.Driver.ConnectHook so every new connection registers the `pivot` vtab.
Package auto wires the pivot extension via a sqlite.Driver.ConnectHook so every new connection registers the `pivot` vtab.
Package regexp provides Go-regexp-syntax SQL functions plus the binary `REGEXP` operator SQLite leaves unimplemented by default.
Package regexp provides Go-regexp-syntax SQL functions plus the binary `REGEXP` operator SQLite leaves unimplemented by default.
auto
Package auto wires the regexp extension via a sqlite.Driver.ConnectHook so every new connection registers the REGEXP operator and the regexp_* SQL function family.
Package auto wires the regexp extension via a sqlite.Driver.ConnectHook so every new connection registers the REGEXP operator and the regexp_* SQL function family.
gorm
Package regexpgorm provides gorm helpers around the ext/regexp extension.
Package regexpgorm provides gorm helpers around the ext/regexp extension.
Package rtree adds ready-made custom geometry callbacks for SQLite's built-in R-Tree module, layered on [gosqlite.org.Conn.RegisterRTreeGeometry].
Package rtree adds ready-made custom geometry callbacks for SQLite's built-in R-Tree module, layered on [gosqlite.org.Conn.RegisterRTreeGeometry].
auto
Package auto wires the rtree geometry functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the rtree geometry functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package series implements the `generate_series` table-valued function — an eponymous virtual table that yields a sequence of integers:
Package series implements the `generate_series` table-valued function — an eponymous virtual table that yields a sequence of integers:
auto
Package auto wires the generate_series table-valued function via a sqlite.Driver.ConnectHook so every new connection registers it.
Package auto wires the generate_series table-valued function via a sqlite.Driver.ConnectHook so every new connection registers it.
Package spellfix1 implements a fuzzy-text-matching virtual table inspired by SQLite's spellfix1 extension.
Package spellfix1 implements a fuzzy-text-matching virtual table inspired by SQLite's spellfix1 extension.
auto
Package auto wires the spellfix1 extension via a sqlite.Driver.ConnectHook so every new connection registers the `spellfix1` vtab.
Package auto wires the spellfix1 extension via a sqlite.Driver.ConnectHook so every new connection registers the `spellfix1` vtab.
Package statement implements a virtual table that turns any SQL statement into a parametrized view.
Package statement implements a virtual table that turns any SQL statement into a parametrized view.
auto
Package auto wires the statement extension via a sqlite.Driver.ConnectHook so every new connection registers the `statement` vtab.
Package auto wires the statement extension via a sqlite.Driver.ConnectHook so every new connection registers the `statement` vtab.
Package stats provides PostgreSQL-style statistical aggregate and window functions plus two scalar helpers.
Package stats provides PostgreSQL-style statistical aggregate and window functions plus two scalar helpers.
auto
Package auto wires the stats extension via a sqlite.Driver.ConnectHook so every new connection registers the statistical aggregate / window function lineup.
Package auto wires the stats extension via a sqlite.Driver.ConnectHook so every new connection registers the statistical aggregate / window function lineup.
Package text adds Unicode-aware string scalar functions that SQLite's built-ins and ext/unicode don't cover:
Package text adds Unicode-aware string scalar functions that SQLite's built-ins and ext/unicode don't cover:
auto
Package auto wires the text_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the text_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package timeext adds Go-time-backed scalar functions that go beyond SQLite's built-in datetime(): duration arithmetic with Go duration syntax, field extraction, truncation, and unix conversions.
Package timeext adds Go-time-backed scalar functions that go beyond SQLite's built-in datetime(): duration arithmetic with Go duration syntax, field extraction, truncation, and unix conversions.
auto
Package auto wires the time_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package auto wires the time_* scalar functions via a sqlite.Driver.ConnectHook so every new connection registers them.
Package unicode provides Unicode-aware string SQL functions and collations as an alternative to the SQLite ICU extension.
Package unicode provides Unicode-aware string SQL functions and collations as an alternative to the SQLite ICU extension.
auto
Package auto wires the unicode extension via a sqlite.Driver.ConnectHook so every new connection registers the Unicode-aware scalar functions plus the NOCASE_UNICODE / NOCASE_ACCENT collations.
Package auto wires the unicode extension via a sqlite.Driver.ConnectHook so every new connection registers the Unicode-aware scalar functions plus the NOCASE_UNICODE / NOCASE_ACCENT collations.
Package uuid provides RFC 4122 UUID SQL functions backed by github.com/google/uuid.
Package uuid provides RFC 4122 UUID SQL functions backed by github.com/google/uuid.
auto
Package auto wires the uuid extension via a sqlite.Driver.ConnectHook so every new connection registers the UUID SQL functions.
Package auto wires the uuid extension via a sqlite.Driver.ConnectHook so every new connection registers the UUID SQL functions.
Package zorder provides z-order curve helpers for mapping multi-dimensional integer coordinates to a single ordered scalar (Morton encoding).
Package zorder provides z-order curve helpers for mapping multi-dimensional integer coordinates to a single ordered scalar (Morton encoding).
auto
Package auto wires the zorder extension via a sqlite.Driver.ConnectHook so every new connection registers `zorder` and `unzorder`.
Package auto wires the zorder extension via a sqlite.Driver.ConnectHook so every new connection registers `zorder` and `unzorder`.

Jump to

Keyboard shortcuts

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