MySQL 8.0.39
Source Code Documentation
Messages

Topics in this section:

This section provides detailed information about how X Protocol defines messages.

Message Structure

Messages have a:

  • 4 byte length (little endian)
  • 1 byte message type
  • a message_payload of length .length - 1
Mysqlx.Message
Container of all messages that are exchanged between client and server.
Parameters
  • length – length of the whole message
  • message_type – type of the message_payload
  • message_payload – the message's payload encoded using Google Protobuf if not otherwise noted.
struct Message {
uint32 length;
uint8 message_type;
opaque message_payload[Message.length - 1];
};
Note
The message_payload is generated from the protobuf files using protoc:
$ protoc --cpp_out=protodir mysqlx*.proto
  • [mysqlx.proto]
  • [mysqlx_connection.proto]
  • [mysqlx_session.proto]
  • [mysqlx_crud.proto]
  • [mysqlx_sql.proto]
  • [mysqlx_resultset.proto]
  • [mysqlx_expr.proto]
  • [mysqlx_datatypes.proto]
  • [mysqlx_expect.proto]
  • [mysqlx_notice.proto]
Note
The message_type can be taken from the Mysqlx::ClientMessages for client-messages and from Mysqlx::ServerMessages of server-side messages.
In C++ they are exposed in mysqlx.pb.h in the ClientMessages class.
ClientMessages.MsgCase.kMsgConGetCap
ClientMessages.kMsgConGetCapFieldNumber

Message Sequence

Messages usually appear in a sequence. Each initial message (one referenced by Mysqlx::ClientMessages) is associated with a set of possible following messages.

A message sequence either:

  • finishes successfully if it reaches its end-state or
  • is aborted with a Mysqlx::Error message

At any time in between local Notices may be sent by the server as part of the message sequence.

Global Notices may be sent by the server at any time.

Common Messages

Error Message

After the client sent the initial message, the server may send a Mysqlx::Error message at any time to terminate the current message sequence.