mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
Document typical flow
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.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
|
||||
participant main as cli/main
|
||||
participant Database as core/lib/Database
|
||||
participant Connection as core/lib/Connection
|
||||
participant Statement as core/lib/Statement
|
||||
participant Parser as sql/mod/Parser
|
||||
participant Scanner as sql/mod/Scanner
|
||||
participant translate as translate/mod
|
||||
participant Program as vdbe/mod/Program
|
||||
|
||||
main->>Database: open_file
|
||||
Database->>main: Connection
|
||||
main->>Connection: query(sql)
|
||||
Note right of Parser: Uses vendored sqlite3-parser
|
||||
Connection->>Parser: next()
|
||||
Note left of Parser: Passes the SQL query to Parser
|
||||
|
||||
Parser->>Scanner: scan()
|
||||
Scanner->>Parser: returns tokens
|
||||
|
||||
|
||||
Parser->>Connection: Cmd::Stmt
|
||||
Connection->>translate:translate()
|
||||
|
||||
Note left of translate: Translates SQL statement into bytecode
|
||||
|
||||
Connection->>main: Ok(Some(Rows { Statement }))
|
||||
main->>Statement: step()
|
||||
Statement->>Program: step()
|
||||
Note left of 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