Protocol field types

You are viewing an old version of this article. View the current version here.

Fixed length integers

A fixed length integer stores the value in a series of n bytes. The least significant byte is always the first byte.

  • int_1
  • int_2
  • int_3
  • int_4
  • int_6
  • int_8
Example

An int_4 with value 2 is stored as

02 00 00 00

Length encoded integers

An integer which depending on its value is represented by n bytes. The first byte represents the size of the integer:

If the value of first byte is

  • < xFB - 1 byte integer
  • FB - NULL value
  • xFC - 2 byte integer (consumes 3 bytes)
  • xFD - 3 byte integer (consumes 4 bytes)
  • xFE - 8 byte integer (consumes 9 bytes)

String types

  • str_FIX
  • str_NTS
  • str_LEC
  • str_REST

Fixed length strings

Fixed length strings (str_FIX) have a known hardcoded length.

Null terminated strings

Null terminated strings (str_NTS) have variable size and are terminated by a 0x00 character

Length encoded strings

Length encoded strings (str_LEC) is prefixed by a length encoded integer which describes the length of the string.

Strings calculated by packet length

Strings which will be calculated by the packet length (str_REST) appear at the end of the packet. For an example see COM_STMT_PREPARE packet.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.