CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

sqlite/sqlite

Scanned commit fde3a84ddd dated 2026-09-21 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/sqlite/sqlite ↗ · 2207 files · 34.5 MB

SQLite Source Repository This repository contains the complete source code for the SQLite database engine going back to 2000-05-29.

Deep analysis by claude-opus-5 via the claude CLI on 2026-09-22 (543s) — every claim below links to its cited source files.

Overview

This is the canonical source tree for SQLite 3.54.0 (VERSION, manifest.uuid `c9b4695f...`) — a serverless, zero-configuration, public-domain SQL database engine implemented as a C library that compiles down to a single-file amalgamation (`sqlite3.c`). The tree is far more than the library: it also carries the `sqlite3` CLI shell (`src/shell.c.in`, ~14.9k lines with ~40 dot-commands), a dozen major extensions under `ext/` (FTS3/5, R-Tree/Geopoly, session/changesets, RBU, recover, intck, JNI bindings, a WASM/OPFS browser build), a TCL binding, and an unusually large test apparatus (1,195 `.test` scripts plus fuzzers). It is distinctive for being managed in Fossil rather than Git (this GitHub remote is a mirror), for refusing pull requests and agentic code on copyright grounds (AGENTS.md), for generating much of its own C (parser, opcodes, pragma table, keyword hash) from TCL/Lemon tooling, and for a testing culture where `make devtest` is the minimum bar before any check-in.

System map

The library is a layered stack inside one process: SQL text enters the tokenizer, goes through a Lemon-generated LALR(1) parser into a code generator, is optimized by the `where*.c` planner, and is executed as bytecode by the VDBE, which reaches storage through B-Tree → Pager → WAL → VFS. There is no daemon and no network boundary in the core; the only OS boundary is the `sqlite3_vfs` interface, implemented by `os_unix.c`, `os_win.c`, `os_kv.c` (key/value / browser localStorage) and `memdb.c`. Build is driven by autosetup (JimTCL-compatible), not GNU Autoconf, with `main.mk` holding the real rules and `Makefile.msc` mirroring them for MSVC. Deployment shape is a static/shared library plus the amalgamation tarball, the `sqlite3` CLI, and auxiliary binaries (`sqldiff`, `sqlite3_rsync`, `sqlite3_analyzer`, `testfixture`, `fuzzcheck`). Version control is Fossil; `manifest`, `manifest.uuid`, and `.fossil-settings/` are Fossil artifacts carried into the Git mirror.

All 14 system map claims →

Feature catalog

User-facing surface splits three ways: the C API in `sqlite.h.in`, the `sqlite3` CLI's dot-command language, and the loadable/compiled-in extension set. The CLI carries roughly 40 dot-commands covering schema inspection, import/export, archives, diagnostics, and integrity checking, plus 23 result-output modes now rendered by the new `ext/qrf` formatting library. Extensions add full-text search, spatial indexing, changeset/session replication, incremental update (RBU), corruption recovery, index recommendation, and a large `ext/misc/` grab-bag of 60 single-file functions and virtual tables. Configure-time feature flags (`--all` implies fts4, fts5, rtree, geopoly, session, dbpage, dbstat, carray) decide what lands in the amalgamation.

All 15 feature catalog claims →

Data flow

Data enters as UTF-8 (or UTF-16, transcoded at the API edge) SQL text or as bound parameter values. `sqlite3RunParser` drives `sqlite3GetToken` token-by-token into the Lemon parser, which builds `Select`/`Expr`/`SrcList` trees inside a `Parse` object; the code generators turn those trees into a VDBE program of `Op` records. At run time the VDBE owns register memory (`Mem *aMem`) and cursors; reads and writes go through B-Tree cursors into the pager's page cache, and out to disk either as rollback-journal writes or WAL frame appends, always via `sqlite3_vfs` methods. Output leaves either as `sqlite3_column_*` values pulled from `p->pResultRow`, or — in the CLI — through QRF's `xWrite` callback into a `FILE*`. Schema itself round-trips through this same machinery: `sqlite3_schema` rows are re-parsed on load, which is why a schema cookie mismatch forces `sqlite3Reprepare`.

All 14 data flow claims →

Behavior traces

Three flows carry most of the system's weight: library startup and connection open; the prepare/step/finalize query cycle including automatic recompilation on schema change; and the CLI's REPL loop from argv parsing through dot-command dispatch to statement execution. A fourth, the durability path, is worth tracing separately because commit behavior forks sharply between rollback-journal and WAL mode. Each trace below names the actual functions in call order as read from the sources.

All 14 behavior traces claims →

Testing signals

Testing is TCL-first: 1,195 `.test` scripts in `test/` are executed by `testfixture`, an augmented tclsh built from `src/tclsqlite.c` plus 44 `src/test*.c` harness modules that expose internals (malloc fault injection, VFS shims, thread control, syscall interception) to TCL. `test/testrunner.tcl` parallelizes across cores and drives named suites and permutations; `permutations.test` defines 58 test_suite configurations. `make devtest` — the developers' minimum pre-check-in bar — chains `srctree-check` (generated files up to date) and `sourcetest` before running `testrunner.tcl mdevtest`. Fuzzing is a separate, substantial tier: `fuzzcheck` replays fuzzer corpora stored as SQLite databases, and `ossfuzz.c` is the OSS-Fuzz entry point. No CI configuration lives in the repo; extension suites are colocated with their extensions.

All 15 testing signals claims →

Risk map

The core library is one of the most heavily tested C codebases in existence, so the interesting risk is not 'is this correct' but 'where does trust boundary crossing happen'. The sharpest edges are: the CLI, which by design shells out and touches the filesystem; `sqlite3_load_extension`, which `dlopen`s attacker-suppliable paths; the schema itself, which is executable input (the `trusted-schema`/`defensive` model exists precisely because of this); and `sqlite3_rsync`, which `fork`/`execl`s a shell. Structurally, the blast radius is concentrated in a handful of enormous files — `btree.c`, `select.c`, `vdbe.c`, `pager.c`, `where.c` are each 300–400KB — and in generated-file drift, which `srctree-check` only partially guards. Note that AGENTS.md explicitly states the project does not accept agentic code, which is itself a process constraint on any change made here.

All 16 risk map claims →

Extension points

SQLite is built almost entirely out of registries, which is why it has such a large third-party ecosystem. At the C level there are seven pluggable interfaces: VFS, virtual-table modules, scalar/aggregate/window functions, collations, page cache, memory allocator, and mutex implementation — plus auto-extensions that fire on every new connection. Above that, FTS5 has its own nested registry for tokenizers and ranking functions. On the source-tree side, the extension points are code generators: adding a PRAGMA means editing `tool/mkpragmatab.tcl`, adding an opcode means adding a `case OP_` in `vdbe.c`, adding grammar means editing `parse.y`, and adding a CLI dot-command means editing the `do_meta_command` chain in `shell.c.in`.

All 14 extension points claims →

Contributor handoff

The hard constraints here are unusual and worth internalizing before touching anything: this is public-domain C with no license headers ever added, it is developed in Fossil (the Git remote is a mirror with different check-in names), and AGENTS.md states outright that the project does not accept agentic code — agentic *bug reports with reproducible test cases* are welcome, and patches are accepted only as proof-of-concept documentation. Practically, that means the safe posture is: read, reproduce, write a `.test` case, and propose rather than land. When editing is in scope, the rules are C89/C99 only, `sqlite3Malloc` family for all allocation, `i64`/`u32`/`u64` for width-sensitive values, `SQLITE_OK`/`SQLITE_*` return codes, liberal `assert` with `ALWAYS`/`NEVER` for compiler-opaque invariants, and never touching a generated file. Always run at least `make devtest` after any `src/` change.

All 15 contributor handoff claims →

Languages

LanguageFilesShare of source
C35773%
Java5812%
JavaScript429%
Markdown27docs/config
HTML21docs/config
SQL143%
Shell143%
C#20%

Start reading here

Probable source entrypoint: src/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

src/ (154 files)

Repository structure

Top-level pathFiles
test/1285
ext/593
src/154
tool/95
autosetup/22
autoconf/15
doc/13
mptest/6

Docs found: AGENTS.mdLICENSE.mdREADME.md

CI & config entrypoints

Structural health signals

Average score 7.7/10 across 93 analyzed source files; 24 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history