How a query runs
The four stages from SQL text to rows: parse, plan, execute, store.
A database turns a sentence of SQL into rows. Fishbowl does it in four stages. Each stage hands a more precise description to the next.
- Parse. The text
SELECT name FROM fish WHERE id > 1becomes a syntax tree: a SELECT with one output column, one table and one condition. At this point nobody has checked thatfishexists. Fishbowl uses thesqlparsercrate for this step. - Plan. The planner looks names up in the catalog, the list of tables and
their columns.
idbecomes "column 0 of fish". Then it decides which steps will produce the answer and in what order. The result is a plan: a small tree of steps. See query plans. - Execute. The executor runs the plan. Rows flow up from the table through each step. See the iterator model.
- Store. Rows live in B+trees made of 4 KiB pages, in a file or, in the browser, in memory.
Splitting the work this way means each stage can be tested and replaced on its own. It also means mistakes surface early: a misspelled column fails during planning, before any row is read.
Code: crates/engine/src/lib.rs (Database::execute) wires the stages
together.