# SQLite Engine SQLite Engine carries the complete SQLite source tree and starts a gradual port of engine components to Ziran. The upstream engine is built from `upstream/`. The first Ziran component, `src/Varint.zi`, decodes SQLite file-format varints with an explicit input length. Its C ABI is exercised by the differential tests. The baseline library and CLI use upstream SQLite C throughout. [SQLite file format](https://sqlite.org/fileformat2.html) The separate [Ziran SQLite binding](https://git.waozi.xyz/ziranlang/sqlite) continues to own its public API. That repository already owns the `sqlite` slug, so the canonical source fork lives under `ziranlang/sqlite-engine`. ## Upstream source The baseline is SQLite **3.54.1**, Fossil check-in `555e07ef33f69a0957d24d8e555b702464a131d6f1607f4c3c1e4551e8e6ca76`. The official `sqlite-src-3540100.zip` release archive was checked against its published SHA3-256 before extraction into `upstream/`. The Fossil manifest, release metadata, upstream license information and individual license notices remain with the imported source. [Release history](https://sqlite.org/changes.html#version_3_54_1) [Source archive](https://sqlite.org/2026/sqlite-src-3540100.zip) [Published archive checksums](https://sqlite.org/download.html) To independently verify a download from the repository root: ```sh mkdir -p build curl --fail --location -o build/sqlite-src-3540100.zip \ https://sqlite.org/2026/sqlite-src-3540100.zip openssl dgst -sha3-256 build/sqlite-src-3540100.zip ``` The expected SHA3-256 is `877c6f4996ce7adb368686bce21638de9e3d91534832ad3d9d119037d1bc22ad`. With the baseline build flags, `openssl dgst -sha3-256 build/baseline/sqlite3.c` matches the published amalgamation digest `e2b869d3003b33c942b7dd7063604fbc53553e1b66609570df39b9b7b558ee81`. `make upstream-test` also runs SQLite's source verifier against the embedded Fossil manifest. ## Build and test On Linux, install a C compiler, GNU Make, and zlib development headers. Use Ziran with the exact toolchain revision in `ziran.lock` for the Ziran build. The compatibility test uses Python 3 with its `sqlite3` module and GNU `stdbuf`. The decoder tests require compiler support for ASan and UBSan. ```sh make -j2 native # builds sqlite3, libsqlite3.a, libsqlite3.so and sqlite3.h make test-varint # runs the decoder differential suite, including ASan/UBSan make test-compat # runs the isolated SQL, file interoperability and recovery suite make -j2 check # runs both suites and checks the locked Ziran package make -j2 upstream-test # needs Tcl and Tcl development headers ``` Native outputs live under `build/baseline/`. The `native` target configures out of tree with `--disable-tcl --disable-readline --enable-fts5 --enable-static --enable-shared` and asks upstream Make for `sqlite3`, `libsqlite3.a` and `libsqlite3.so`. Native tests exercise these sources without an installed SQLite build dependency. The compatibility tests use the Python SQLite library as an independent legacy reader and writer. `upstream-test` configures `build/upstream-test/` separately with `--dev`, builds `coretestprogs`, runs `verify-source`, `srctree-check`, and `sourcetest`, and runs `test/testrunner.tcl veryquick` through the in-tree test fixture with `TZ=UTC` for reproducible ZIP timestamp checks. For a nonstandard Tcl installation, pass `TCL_CONFIG=/path/to/tcl-config-directory` and `TCLSH=/path/to/tclsh`. With system Tcl development files, upstream's broader development matrix can also be run after `make upstream-test`. [Upstream testing guide](https://sqlite.org/testing.html) ```sh cd build/upstream-test TZ=UTC ./testfixture ../../upstream/test/testrunner.tcl mdevtest -j 2 ``` ## Updates and compatibility When refreshing the baseline, verify the official archive against SQLite's published SHA3-256, compare the embedded Fossil check-in with the release record, and import the tree byte for byte. Preserve executable bits and the upstream license and build-tool notices. Record the new release, check-in and archive hash here, and run both local suites and the upstream suite. Keep Ziran code and integration changes outside `upstream/`; generate build products under `build/`. The [rewrite plan](plans/rewrite.md) records compatibility gates and the binding integration contract.