# Protocol Data Types

## List of Possible Types

Unknown type:

|                                         |                          |
| --------------------------------------- | ------------------------ |
| [byte<1>](#fixed-length-bytes)          | Fixed-length bytes       |
| [byte\<lenenc>](#length-encoded-bytes)  | Length-encoded bytes     |
| [byte\<EOF>](#end-of-file-length-bytes) | End-of-file length bytes |

Integer type:

|                                          |                         |
| ---------------------------------------- | ----------------------- |
| [int<1>](#fixed-length-integers)         | Fixed-length integers   |
| [int\<lenenc>](#length-encoded-integers) | Length-encoded integers |

String type:

|                                             |                            |
| ------------------------------------------- | -------------------------- |
| [string\<fix>](#fixed-length-strings)       | Fixed-length strings       |
| [string\<NUL>](#null-terminated-strings)    | Null-terminated strings    |
| [string\<lenenc>](#length-encoded-strings)  | Length-encoded strings     |
| [string\<EOF>](#end-of-file-length-strings) | End-of-file length strings |

### Fixed-Length Bytes

The notation is `byte`*`<n>`*, where *`<n>`* is a positive integer. A fixed-length byte stores the value in a series of `n` bytes.

### Length-Encoded Bytes

The notation is `byte<lenenc>`. Length-encoded bytes are prefixed by a length-encoded integer which describes the length of the byte value, followed by the bytes value.

### End of File Length Bytes

The notation is `byte<EOF>`. Bytes whose length is calculated by the packet remaining length.

### Fixed-Length Integers

Notation is `int`*`<n>`*, where *`<n>`* is a positive integer. 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 of `2` is stored as `02 00 00 00` .

### Length-Encoded Integers

The 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, depending on the value of the first byte:

* < `0xFB` - Integer value is this a 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

The notation is `string<fix>`. Fixed-length strings have a known hardcoded length.

### Null-Terminated Strings

The notation is `string<NUL>`. Null-terminated strings have a variable size and are terminated by a `0x00` character.

### Length-Encoded Strings

The 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" is encoded in 515 bytes:

{% code overflow="wrap" %}

```
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
```

{% endcode %}

The `NULL` value is encoded using null (`0xfb`) length.

An empty value is encoded with a 0 (`0x00`) length.

### End of File Length Strings

The notation is `string<EOF>`.

Strings whose length is calculated by the packet remaining length. For an example, see the [COM\_STMT\_PREPARE](/docs/server/reference/clientserver-protocol/3-binary-protocol-prepared-statements/com_stmt_prepare.md) packet.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @marketo/form formId="4316" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/clientserver-protocol/protocol-data-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
