How project-mydb/mydb works
MYDB is a partition-isolated relational database served by one daemon. A client connects over Unix socket or TCP, authenticates, submits SQL, and receives a result; the engine coordinates parsing, execution, and partition-scoped state. SQL capabilities include DDL, DML, queries, joins, transactions, and ANALYZE-driven planning. The graph preserves the documented planner and clustered-storage branches. Some implementation files were not sampled, so uncertain runtime links are dashed rather than asserted.
Main entry points: engine.c Engine and sessions · pm_api.c Partition operations · storage.c Table storage API · server.c Session dispatch
Components 23
Client
- Command-line REPL
client/src/client_repl.c - Client connection
client/src/client_conn.c
Server and identity
- Database daemon
bin/mydbd.c - Unix and TCP listeners
server/src/listener.c - Packet protocol
server/src/protocol.c - Challenge-response auth
server/src/auth.c - Password hashing
crypto/src/crypto.c - Session dispatch
server/src/server.c
SQL processing
- Engine and sessions
engine/src/engine.c - SQL lexer and parser
query_parser/src/Parser.cpp - Statement execution
execution_engine/src/exec_engine_api.cpp - Cost-based planner
planner/src/planner.c
Partition management
- Partition operations
partition_manager/src/pm_api.c - Partition lifecycle
partition_manager/src/partition_ctx.c - Partition catalog
partition_manager/src/partition.c - Schema definitions
partition_manager/src/schema_file.c - Column statistics
partition_manager/src/stats.c
Storage and metadata
- Table storage API
storage_engine/src/storage.c - Clustered B+ trees
storage_engine/src/btree.c - Buffer pool
storage_engine/src/buffer_pool.c - Table files and pages
storage_engine/src/disk_manager.c - System schema
system_schema/src/system_schema.c
Other components
- SQL user
Connections 25
- SQL user → Command-line REPL: enters SQL
README.md - Command-line REPL → Client connection: submits queries
client/src/client_repl.c - Client connection → Packet protocol: exchanges packets
client/src/client_conn.c - Client connection → Unix and TCP listeners: connects over socket
README.md - Database daemon → Session dispatch: runs event loop
- Unix and TCP listeners → Session dispatch: accepts sessions
- Session dispatch → Challenge-response auth: authenticates
- Challenge-response auth → Password hashing: checks response
server/src/auth.c - Session dispatch → Engine and sessions: dispatches SQL
- Engine and sessions → SQL lexer and parser: parses statements
- Engine and sessions → Statement execution: executes AST
- Statement execution → Partition operations: runs table operations
- Statement execution → Cost-based planner: plans queries
- Cost-based planner → Column statistics: reads statistics
- Cost-based planner → Schema definitions: reads definitions
- Engine and sessions → Partition lifecycle: acquires partition
engine/src/engine.c - Partition operations → Partition lifecycle: uses context
partition_manager/src/pm_api.c - Partition operations → Schema definitions: updates metadata
partition_manager/src/pm_api.c - Partition operations → Column statistics: collects ANALYZE stats
- Partition operations → Table storage API: performs table I/O
partition_manager/src/pm_api.c - Table storage API → Clustered B+ trees: uses indexes
- Table storage API → Buffer pool: caches pages
- Table storage API → Table files and pages: reads and writes pages
- Engine and sessions → System schema: manages accounts
- Engine and sessions → Partition catalog: opens partition catalog
engine/src/engine.c