On this page

0273. Vendored SQLite as a toolchain battery

Context

plugins/sqlite needs a system libsqlite3 (pkg-config) and returns only text cells. ADR-0245 lists SQLite in the toolchain set. SQ0 left three questions: may the toolchain vendor C sources, what the package's capability boundary is, and what the defaults are.

Decision

  1. Vendoring. The toolchain may vendor C sources under third_party/<name>/<version>/ with the upstream version, a SHA3-256 or SHA-256 checksum and a license note. The first is SQLite's public-domain amalgamation (sqlite3.c, sqlite3.h). The driver compiles vendored translation units once into cached objects (keyed like other native builds, including the compiler and its flags) and links them into C builds and the ffi-host helper. An owner-run script updates the pinned copy. A system-library opt-out (TENON_SQLITE=system) keeps the pkg-config path.
  2. Compile options. Use a fixed, documented set: threadsafe off (single-threaded use, as today), extension loading omitted, defensive mode on, and the ATTACH-denying authorizer kept. PRAGMA compile_options has a golden.
  3. Capability boundary. The toolchain-shipped sqlite package needs only fs. Apps do not declare an ffi ceiling for it, because its native code ships with the toolchain. Fs grants and sandbox rules cover the database directory, since SQLite writes -wal, -shm and -journal files beside the file.
  4. Defaults. WAL journal mode, a busy timeout, foreign keys on, BEGIN IMMEDIATE for write transactions, and STRICT tables recommended. Hostile-input guards stay: defensive mode, no extensions, sqlite3_limit settings and a progress-handler deadline (SQ4).
  5. plugins/sqlite stays as the FFI teaching example until SQ7 decides whether to keep or remove it.

Alternatives considered

Consequences

SQ1 changes the build path that every test uses. It lands behind the full make check and a test-suite timing check. The vendored copy is the toolchain's to update, and the release checklist reviews SQLite's security page.