> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/clientserver-protocol/replication-protocol/user_var_event.md).

# USER\_VAR\_EVENT

A `USER_VAR_EVENT` is written every time a statement uses a user defined variable.

## Header

* Event Type is `14` (`0x0e`).

## Fields

* [uint<4>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) The length of the user variable name.
* [string\<len>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-strings) The name of the user variable.
* [uint<1>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) `NULL` indicator.
* If (not null indicator):
  * [uint<1>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) variable type.
  * [uint<4>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) collation number.
  * [uint<4>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) The length of value.
  * [string\<len>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-strings) value.
  * [uint<1>](/docs/server/reference/clientserver-protocol/protocol-data-types.md#fixed-length-integers) flags.

## Variable type

| Value | Type            | Example              |
| ----- | --------------- | -------------------- |
| 0x00  | STRING\_RESULT  | set @a:="foo"        |
| 0x01  | REAL\_RESULT    | set @a:= @@timestamp |
| 0x02  | INT\_RESULT     | set @a:= 4           |
| 0x03  | ROW\_RESULT     | (not in use)         |
| 0x04  | DECIMAL\_RESULT | set @a:=1.2345       |

## Flag

|      |          |
| ---- | -------- |
| 0x01 | unsigned |

## Example for `SET @foo:="bar"` From mysqlbinlog Utility, CRC32

```
# at 511
#180610 10:26:43 server id 1  end_log_pos 554 CRC32 0x7dd93d6b 	User_var
SET @`foo`:=_utf8 X'626172' COLLATE `utf8_general_ci`/*!*/;
```

## Example Event as Written to the Binlog File

```
c3 e0 1c 5b 0e 01 00 00 00 2b 00       ...[.....+.
00 00 2a 02 00 00 00 00 03 00 00 00 66 6f 6f 00  ..*.........foo.
00 21 00 00 00 03 00 00 00 62 61 72 6b 3d d9 7d  .!.......bark=.}                                          ....
```

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/replication-protocol/user_var_event.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.
