# System map — sqlite/sqlite

> Canonical page: https://codevetter.com/unpack/sqlite/system-map

# System map — sqlite/sqlite

Scanned commit fde3a84dddf35f4c19797c8afad04a44c596f4d8 (2026-09-21). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

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.
- The public C API is defined by the template `src/sqlite.h.in` (11,463 lines), which `tool/mksqlite3h.tcl` expands into the deliverable `sqlite3.h` by splicing in `VERSION` (3.54.0) and the SHA3 check-in id from `manifest.uuid`. — [src/sqlite.h.in](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/sqlite.h.in) [tool/mksqlite3h.tcl](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/mksqlite3h.tcl) [VERSION](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/VERSION) [manifest.uuid](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/manifest.uuid) [README.md#L230-L246](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/README.md#L230-L246)
- `openDatabase()` in `src/main.c:3388` is the single funnel for `sqlite3_open`, `sqlite3_open_v2` and `sqlite3_open16`: it calls `sqlite3_initialize()`, decides thread-safety from `SQLITE_OPEN_NOMUTEX`/`FULLMUTEX` vs `sqlite3GlobalConfig.bFullMutex`, masks off internal-only open flags, allocates the `sqlite3` handle with `sqlite3MallocZero`, and enables lookaside plus `sqlite3_wal_autocheckpoint`. — [src/main.c#L3388-L3470](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/main.c#L3388-L3470) [src/main.c#L3753-L3772](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/main.c#L3753-L3772)
- Compilation runs through `sqlite3LockAndPrepare()` (`src/prepare.c:854`), which takes `db->mutex`, calls `sqlite3BtreeEnterAll()` to hold every B-Tree mutex, and retries `sqlite3Prepare()` on `SQLITE_ERROR_RETRY` / `SQLITE_SCHEMA` up to `SQLITE_MAX_PREPARE_RETRY`. — [src/prepare.c#L854-L900](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/prepare.c#L854-L900)
- The VDBE is the execution boundary: `sqlite3VdbeExec()` (`src/vdbe.c:902`) is one giant `for(pOp=&aOp[p->pc]; 1; pOp++)` dispatch loop over 190 `case OP_*` handlers, and `tool/mkopcodeh.tcl` scrapes those `case OP_` lines out of `vdbe.c` to assign opcode numbers. — [src/vdbe.c#L902-L990](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/vdbe.c#L902-L990) [tool/mkopcodeh.tcl](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/mkopcodeh.tcl) [AGENTS.md](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/AGENTS.md)
- Storage is layered strictly: `src/btree.c` (407KB, the largest file) exposes `sqlite3BtreeOpen/BeginTrans/Cursor/CommitPhaseOne/CommitPhaseTwo`, which sits on `src/pager.c`'s `sqlite3PagerOpen/Get/Write/CommitPhaseOne`, which in turn either journals or writes WAL frames via `src/wal.c`'s `sqlite3WalFrames`/`sqlite3WalCheckpoint`. — [src/btree.c#L2562-L2570](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/btree.c#L2562-L2570) [src/pager.c#L4789](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/pager.c#L4789) [src/pager.c#L6527-L6580](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/pager.c#L6527-L6580) [src/wal.c#L4361-L4390](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/wal.c#L4361-L4390)
- The OS boundary is a registry of `sqlite3_vfs` objects; `os_unix.c` registers up to 12 named VFSes (`unix`, `unix-none`, `unix-dotfile`, `unix-excl`, `unix-flock`, `unix-afp`, `unix-nfs`, `unix-proxy`, …) via a `UNIXVFS()` macro table at `src/os_unix.c:8497`, each pairing a locking style with an `IOMETHODS()`-generated `sqlite3_io_methods` vtable. — [src/os_unix.c#L5808-L5945](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/os_unix.c#L5808-L5945) [src/os_unix.c#L8465-L8536](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/os_unix.c#L8465-L8536)
- Alternative VFS backends ship in-tree: `src/memdb.c` registers a `memdb` VFS backing `sqlite3_serialize`/`sqlite3_deserialize`, and `src/os_kv.c` registers `kvvfs`, the key/value VFS used by the WASM/browser build. — [src/memdb.c#L750-L935](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/memdb.c#L750-L935) [src/os_kv.c#L1086-L1095](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/os_kv.c#L1086-L1095)
- The build entrypoint is `./configure`, a 4-line shell wrapper that execs autosetup; `auto.def` drives it via `sqlite-configure canonical`, where `--dev` implies `--all --debug`, disables the amalgamation, and sets `CFLAGS=-O0 -g`. — [configure](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/configure) [auto.def#L20-L35](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/auto.def#L20-L35) [autosetup/sqlite-config.tcl#L160-L250](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/autosetup/sqlite-config.tcl#L160-L250)
- `main.mk` is the real makefile body (84KB): it defines `LIBOBJS0` (per-file objects) vs `LIBOBJS1 = sqlite3.o` (amalgamation) selected by `USE_AMALGAMATION`, and builds `sqlite3.c` by running `tool/mksqlite3c.tcl` over a generated `tsrc/` directory. — [main.mk#L529-L565](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/main.mk#L529-L565) [main.mk#L1145-L1152](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/main.mk#L1145-L1152) [tool/mksqlite3c.tcl#L1-L25](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/mksqlite3c.tcl#L1-L25)
- The CLI shell is generated, not compiled directly: `src/shell.c.in` uses `INCLUDE ../ext/...` directives (processed by `tool/mkshellc.tcl`) to inline ~25 extension source files — sha1/shathree, base64/base85, decimal, ieee754, series, regexp, fileio, completion, appendvfs, zipfile, sqlar, vfstrace, diskused, plus the `expert`, `intck`, `recover` and `qrf` libraries. — [src/shell.c.in#L259-L326](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/shell.c.in#L259-L326) [tool/mkshellc.tcl](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/mkshellc.tcl)
- Auxiliary deliverables live in `tool/`: `sqldiff.c` (database diffing), `sqlite3_rsync.c` (rsync-like replication over SSH), `sqlite3_analyzer.c.in` (space analysis, paired with `tool/spaceanal.tcl`), `showdb.c`/`showwal.c`/`showjournal.c` (file-format forensics), and `lemon.c` (the parser generator itself). — [tool/sqldiff.c](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/sqldiff.c) [tool/sqlite3_rsync.c#L23-L40](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/sqlite3_rsync.c#L23-L40) [tool/spaceanal.tcl](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/spaceanal.tcl) [tool/showwal.c](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/showwal.c) [tool/lemon.c](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/lemon.c)
- A second, reduced build tree exists under `autoconf/` for the shipped amalgamation tarball (its own `auto.def`, `Makefile.in`, `Makefile.msc`, `Makefile.fallback`, plus a `tea/` TCL Extension Architecture build), and `tool/srctree-check.tcl` enforces that `autoconf/Makefile.msc` stays in sync with the top-level `Makefile.msc`. — [autoconf/README.first](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/autoconf/README.first) [autoconf/Makefile.msc](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/autoconf/Makefile.msc) [tool/srctree-check.tcl#L37-L45](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/tool/srctree-check.tcl#L37-L45)
- There is no CI configuration in the repository — no `.github/`, `.gitlab-ci.yml`, or Travis file exists; the only VCS metadata is `.fossil-settings/` (`binary-glob`, `empty-dirs`, `ignore-glob`) plus the Fossil `manifest`, consistent with the README's statement that the Git remote is a mirror. — [.fossil-settings/ignore-glob](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/.fossil-settings/ignore-glob) [manifest.uuid](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/manifest.uuid) [README.md#L13-L30](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/README.md#L13-L30)
- Language-binding boundaries ship in-tree: `src/tclsqlite.c` (150KB) exposes `Sqlite3_Init`/`DbMain`/`DbObjCmd` as a TCL package, `ext/jni/src/c/sqlite3-jni.c` with 58 Java files provides JNI bindings, and `ext/wasm/api/` provides an Emscripten/WASM JS API with OPFS-backed VFS variants. — [src/tclsqlite.c#L4310-L4513](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/src/tclsqlite.c#L4310-L4513) [ext/jni/src/c/sqlite3-jni.c](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/ext/jni/src/c/sqlite3-jni.c) [ext/wasm/api/sqlite3-api-oo1.c-pp.js](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/ext/wasm/api/sqlite3-api-oo1.c-pp.js) [ext/wasm/api/sqlite3-vfs-opfs.c-pp.js](https://github.com/sqlite/sqlite/blob/fde3a84dddf35f4c19797c8afad04a44c596f4d8/ext/wasm/api/sqlite3-vfs-opfs.c-pp.js)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
