Expand description
MySQL prepared statement (binary protocol) implementation.
This module implements COM_STMT_PREPARE, COM_STMT_EXECUTE, and COM_STMT_CLOSE for the MySQL binary protocol. Prepared statements provide:
- Type-safe parameter binding (no SQL injection risk)
- Better performance for repeated queries (parse once, execute many)
- Binary data transfer (more efficient than text protocol)
§Protocol Flow
-
Prepare: Client sends COM_STMT_PREPARE with SQL
- Server returns statement ID, param count, column count
- Server sends param column definitions (if any)
- Server sends result column definitions (if any)
-
Execute: Client sends COM_STMT_EXECUTE with statement ID + binary params
- Server returns result set (binary protocol) or OK packet
-
Close: Client sends COM_STMT_CLOSE with statement ID
- No server response
§References
Structs§
- Prepared
Statement - A prepared statement with its metadata.
- Stmt
Prepare Ok - Response from COM_STMT_PREPARE.
Functions§
- build_
stmt_ close_ packet - Build a COM_STMT_CLOSE packet.
- build_
stmt_ execute_ packet - Build a COM_STMT_EXECUTE packet.
- build_
stmt_ prepare_ packet - Build a COM_STMT_PREPARE packet.
- build_
stmt_ reset_ packet - Build a COM_STMT_RESET packet.
- parse_
stmt_ prepare_ ok - Parse a COM_STMT_PREPARE_OK response.