mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-06 01:34:21 +01:00
Merge 'Document typical code flow with charts' from Kacper Madej
I'd love to contribute to Limbo, but wrapping my head around the whole project is hard. I decided to start by creating a diagram of a typical flow so that other potential contributors might have an easier time :) LMK if this is useful, I can create more of those when I dig deeper. Closes #456
This commit is contained in:
37
docs/internals/typical_query.md
Normal file
37
docs/internals/typical_query.md
Normal file
@@ -0,0 +1,37 @@
|
||||
The following sequence diagram shows the typical flow of a query from the CLI to the [VDBE](https://www.sqlite.org/opcode.html).
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
|
||||
participant main as cli/main
|
||||
participant Database as core/lib/Database
|
||||
participant Connection as core/lib/Connection
|
||||
participant Parser as sql/mod/Parser
|
||||
participant translate as translate/mod
|
||||
participant Statement as core/lib/Statement
|
||||
participant Program as vdbe/mod/Program
|
||||
|
||||
main->>Database: open_file
|
||||
Database->>main: Connection
|
||||
main->>Connection: query(sql)
|
||||
Note left of Parser: Parser uses vendored sqlite3-parser
|
||||
Connection->>Parser: next()
|
||||
Note left of Parser: Passes the SQL query to Parser
|
||||
|
||||
Parser->>Connection: Cmd::Stmt (ast/mod.rs)
|
||||
|
||||
Note right of translate: Translates SQL statement into bytecode
|
||||
Connection->>translate:translate(stmt)
|
||||
|
||||
translate->>Connection: Program
|
||||
|
||||
Connection->>main: Ok(Some(Rows { Statement }))
|
||||
|
||||
note right of main: a Statement with <br />a reference to Program is returned
|
||||
|
||||
main->>Statement: step()
|
||||
Statement->>Program: step()
|
||||
Note left of Program: Program executes bytecode instructions<br />See https://www.sqlite.org/opcode.html
|
||||
Program->>Statement: StepResult
|
||||
Statement->>main: StepResult
|
||||
```
|
||||
Reference in New Issue
Block a user