Protocol field types

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

List of possible field types

Unknown type :

byte<1>Fixed length bytes
byte<lenenc>Length encoded bytes

Integer type :

int<1>Fixed length integers
int<lenenc>Length encoded integers

String type :

string<fix>Fixed length strings
string<NUL>Null terminated strings
string<lenenc>Length encoded strings
string<EOF>end of file length Strings


Fixed length bytes

Notation is "byte<n>"

A fixed length bytes stores the value in a series of n bytes.

Fixed length integers

Notation is "int<n>"

A fixed length integer stores the value in a series of n bytes. The least significant byte is always the first byte (little-endian format).

Example

An int<4> with value 2 is stored as 02 00 00 00

Length encoded integers

notation is "int<lenenc>" 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

  • < 0xFB - Integer value is this 1 byte integer
  • 0xFB - NULL value
  • 0xFC - Integer value is encoded in the next 2 bytes (3 bytes total)
  • 0xFD - Integer value is encoded in the next 3 bytes (4 bytes total)
  • 0xFE - Integer value is encoded in the next 8 bytes (9 bytes total)

Fixed length strings

notation is "string<fix>" Fixed length strings have a known hardcoded length.

Null terminated strings

notation is "string<NUL>" Null terminated strings have a variable size and are terminated by a 0x00 character

Length encoded strings

notation is "string<lenenc>" Length encoded strings are prefixed by a length encoded integer which describes the length of the string, followed by the string value.



Example

An string of 512 "a" will be encoded in 515 bytes :

fc 00 02 97 97 97 97 97 97 97 97 97 97 97 97 97² .. a a a a a a a a a a a a a

...



End of file length strings

notation is "string<EOF>" Strings which will be calculated by the packet remaining length . 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.