$ show mackyle/sqlite
This repository contains the SQLite embedded SQL database engine source code, mirrored from the actively maintained SQLite project. The core is a C library that parses SQL, compiles it into a custom bytecode virtual machine (VDBE), and executes it against a B-tree storage layer backed by a transactional pager and a pluggable OS abstraction (VFS). Primary entry points are the public C API in src/sqlite.h.in, the sqlite3 command-line shell built from src/shell.c.in, and the init functions of many loadable extensions.
The LLM identified 5 files worth highlighting for reuse:
Self-contained SQLite loadable extension implementing REGEXP/REGEXPI using a compact NFA with opcodes. Handles compilation, execution, and an allocation limit to avoid ReDoS. Exposes sqlite3_regexp_init() and can be lifted into any C project needing an embeddable regex engine.
Implements a bitmap that automatically switches among flat array, hash table, and recursive subdivision representations based on set density. It is used to track b-tree pages but is self-contained enough to extract as a generic sparse bit set, and demonstrates non-trivial memory/CPU trade-offs.
A no-fragmentation power-of-two memory allocator implementing sqlite3_mem_methods. Uses free-list segregation and coalescing under a single mutex. Could be reused in freestanding/embedded projects or as a reference allocator design.
Implements arbitrary-precision decimal arithmetic as SQL scalar functions using a custom Decimal struct. Handles rounding, exponentiation, comparison, and string formatting in one portable C file. Demonstrates a clean single-file SQLite extension entry point.
A standalone LALR parser generator that reads .y grammars and emits C tables. SQLite uses it to generate its SQL parser. This is a reusable compiler-construction tool independent of the SQLite codebase, and a rare example of a small, readable parser generator.