Documentation Home
MySQL Internals Manual


14.7.6 COM_STMT_EXECUTE

COM_STMT_EXECUTE asks the server to execute a prepared statement as identified by stmt-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 Protocol::ColumnType

  • 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 corresponding prepared statement.

The server returns a COM_STMT_EXECUTE Response.

COM_STMT_EXECUTE:
COM_STMT_EXECUTE
  execute a prepared statement

  direction: client -> server
  response: COM_STMT_EXECUTE Response

  payload:
    1              [17] COM_STMT_EXECUTE
    4              stmt-id
    1              flags
    4              iteration-count
      if num-params > 0:
    n              NULL-bitmap, length: (num-params+7)/8
    1              new-params-bound-flag
      if new-params-bound-flag == 1:
    n              type of each parameter, length: num-params * 2
    n              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

The iteration-count is always 1.

The flags are:

Flags

Constant Name

0x00

CURSOR_TYPE_NO_CURSOR

0x01

CURSOR_TYPE_READ_ONLY

0x02

CURSOR_TYPE_FOR_UPDATE

0x04

CURSOR_TYPE_SCROLLABLE

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


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.