Executes a previously prepared statement.

If specific data is large, it can be sent separately prior to this command (see COM_STMT_SEND_LONG_DATA).

If a statement is re-executed without changing the bind types, the types do not need to be sent to the server again.


Client to server.


  • int<1> 0x17 : COM_STMT_EXECUTE header
  • int<4> statement id
  • int<1> flags:
  • int<4> Iteration count (always 1)
  • if (param_count > 0)
    • byte<(param_count + 7)/8> null bitmap
    • byte<1>: send type to server (0 / 1)
    • if (send type to server)
    • for each parameter (i.e param_count times)
      • byte<n> binary parameter value

Statement Id

Since MariaDB server version 10.2, can be -1 (or, 0xFFFFFFFF), indicating execution of the last statement prepared on current connection. In such case COM_STMT_EXECUTE must follow COM_STMT_PREPARE or another COM_STMT_EXECUTE with statement id=-1


0no cursor
1read only
2cursor for update
4scrollable cursor

Parameter flag

parameter type flag byte:



The NULL-Bitmap indicates if parameters are null (one bit per parameter).
NULL-bitmap size is (parameter number + 7) / 8


The server can answer with 3 different responses:

  • 0xff: ERR_Packet if any errors occur.
  • 0x00: OK_packet when query execution works without resultset.
  • one (or more) Resultset, when query execution return rows (in case of SELECT query for example).


Comments loading...