Skip to main content

build_stmt_execute_packet

Function build_stmt_execute_packet 

Source
pub fn build_stmt_execute_packet(
    statement_id: u32,
    params: &[Value],
    param_types: Option<&[FieldType]>,
    sequence_id: u8,
) -> Vec<u8> 
Expand description

Build a COM_STMT_EXECUTE packet.

§Arguments

  • statement_id - The statement ID from COM_STMT_PREPARE_OK
  • params - Parameter values (must match the number of placeholders)
  • param_types - Optional parameter type hints from previous prepare
  • sequence_id - The packet sequence number (typically 0)

§Binary Protocol Parameter Encoding

The execute packet format is:

  • Command byte (0x17)
  • Statement ID (4 bytes, little-endian)
  • Flags (1 byte): 0x00 = no cursor, 0x01 = cursor read-only
  • Iteration count (4 bytes, always 1)
  • NULL bitmap (if num_params > 0)
  • New params bound flag (1 byte)
  • Parameter types and values (if new_params_bound = 1)