MySQL  8.0.19
Source Code Documentation
COM_STMT_EXECUTE

COM_STMT_EXECUTE asks the server to execute a prepared statement as identified by statement_id.

It sends the values for the placeholders of the prepared statement (if it contained any) in Binary Protocol Value form. The type of each parameter is made up of two bytes:

  • the type as in enum_field_types
  • a flag byte which has the highest bit set if the type is unsigned [80]

The num_params used for this packet has to match the num_params of the COM_STMT_PREPARE_OK of the corresponsing prepared statement.

Returns
COM_STMT_EXECUTE Response
Payload
TypeNameDescription
int<1> status [0x17] COM_STMT_EXECUTE
int<4> statement_id ID of the prepared statement to execute
int<1> flags Flags. See enum_cursor_type
int<4> iteration_count Number of times to execute the statement. Currently always 1.
if num_params > 0 {
binary<var> null_bitmap NULL bitmap, length= (num_params + 7) / 8
int<1> new_params_bind_flag Flag if parameters must be re-bound
if new_params_bind_flag {
binary<var> parameter_types Type of each parameter, length: num_params * 2
binary<var> parameter_values value of each parameter
Example
12 00 00 00 17 01 00 00 00 00 01 00 00 00 00 01 ................
0f 00 03 66 6f 6f ...foo

null_bitmap is like the NULL-bitmap for the Binary Protocol Resultset Row just that it has a bit_offset of 0.

See also
mysql_stmt_execute, cli_stmt_execute, mysql_stmt_precheck, mysqld_stmt_execute