SQLite
I'm working through the Codecrafters Build Your Own SQLite course.
Language completion:
[ ]
C[ ]
Common Lisp
SQLite database file headers
The header is 100 bytes, and is described here. For the purposes of this challenge, we'll skip the first 16 bytes (the string "SQLite format 3\\000"). Bytes 16-17 are the "The database page size in bytes. Must be a power of two between 512 and 32768 inclusive, or the value 1 representing a page size of 65536." The value is in big-endian format.
The sqlite_schema
table
- SQLite databases are made up of at least one page; tables
(including
sqlite_schema
) are stored in one or more B-tree pages. - Challenge note: assume tables fit in one page. The course will
dive into more detail on pages later, but for now:
sqlite_schema
is always page 1, and always begins at offset 0.- The rows are stored in cells, where each cell is one row.
- The page header stores a two-byte big-endian value (similar to the page size) specifying the number of cells on the page.
Links
- SQLite Internals: Pages & B-trees
- This is a good test of the CInEmacs setup.