Database Engine
A toy relational database written in C from scratch. Supports a subset of SQL, a B-tree index structure, and page-level disk persistence.
First commit. Decided to write this in C mostly to force myself to
think about memory layout explicitly. Started with the pager — a thin
abstraction over read/write that hands out
fixed-size pages.
No indexes yet, just a flat heap scan. Even that was more work than expected.
Spent the week getting the B-tree insertion right. Split logic was subtly broken — off-by-one in the sibling pointer update. Classic.
The test harness now inserts 100k rows and verifies the tree invariants on every write. Slow, but it caught three bugs I didn’t know existed.
Got basic SELECT and INSERT working
end-to-end. The parser is still a hand-rolled recursive descent mess,
but it handles the subset I care about.
Next up: making sure page eviction doesn’t corrupt the B-tree on a hard restart.