Skip to main content

Module prepared

Module prepared 

Source
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

  1. 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)
  2. Execute: Client sends COM_STMT_EXECUTE with statement ID + binary params

    • Server returns result set (binary protocol) or OK packet
  3. Close: Client sends COM_STMT_CLOSE with statement ID

    • No server response

§References

Structs§

PreparedStatement
A prepared statement with its metadata.
StmtPrepareOk
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.