Documentation Home
MySQL Internals Manual


14.9.4.9 QUERY_EVENT

Binlog::QUERY_EVENT:

The query event is used to send text querys right the binlog.

Post-header
4              slave_proxy_id
4              execution time
1              schema length
2              error-code
  if binlog-version ≥ 4:
2              status-vars length
Payload
string[$len]   status-vars
string[$len]   schema
1              [00]
string[EOF]    query
Fields
  • status_vars_length (2) -- number of bytes in the following sequence of status-vars

  • status_vars (string.var_len) -- [len=$status_vars_length] a sequence of status key-value pairs. The key is 1-byte, while its value is dependent on the key.

    Hex

    Flag

    Value Length

    0x00

    Q_FLAGS2_CODE

    4

    0x01

    Q_SQL_MODE_CODE

    8

    0x02

    Q_CATALOG

    1 + n + 1

    0x03

    Q_AUTO_INCREMENT

    2 + 2

    0x04

    Q_CHARSET_CODE

    2 + 2 + 2

    0x05

    Q_TIME_ZONE_CODE

    1 + n

    0x06

    Q_CATALOG_NZ_CODE

    1 + n

    0x07

    Q_LC_TIME_NAMES_CODE

    2

    0x08

    Q_CHARSET_DATABASE_CODE

    2

    0x09

    Q_TABLE_MAP_FOR_UPDATE_CODE

    8

    0x0a

    Q_MASTER_DATA_WRITTEN_CODE

    4

    0x0b

    Q_INVOKERS

    1 + n + 1 + n

    0x0c

    Q_UPDATED_DB_NAMES

    1 + n*nul-term-string

    0x0d

    Q_MICROSECONDS

    3

    The value of the different status vars are:

    Q_FLAGS2_CODE

    Bitmask of flags that are usually set with SET:

    • SQL_AUTO_IS_NULL

    • FOREIGN_KEY_CHECKS

    • UNIQUE_CHECKS

    • AUTOCOMMIT

    Hex

    Flag

    0x00004000

    OPTION_AUTO_IS_NULL

    0x00080000

    OPTION_NOT_AUTOCOMMIT

    0x04000000

    OPTION_NO_FOREIGN_KEY_CHECKS

    0x08000000

    OPTION_RELAXED_UNIQUE_CHECKS

    Q_SQL_MODE_CODE

    Bitmask of flags that are usually set with SET sql_mode:

    Hex

    Flag

    0x00000001

    MODE_REAL_AS_FLOAT

    0x00000002

    MODE_PIPES_AS_CONCAT

    0x00000004

    MODE_ANSI_QUOTES

    0x00000008

    MODE_IGNORE_SPACE

    0x00000010

    MODE_NOT_USED

    0x00000020

    MODE_ONLY_FULL_GROUP_BY

    0x00000040

    MODE_NO_UNSIGNED_SUBTRACTION

    0x00000080

    MODE_NO_DIR_IN_CREATE

    0x00000100

    MODE_POSTGRESQL

    0x00000200

    MODE_ORACLE

    0x00000400

    MODE_MSSQL

    0x00000800

    MODE_DB2

    0x00001000

    MODE_MAXDB

    0x00002000

    MODE_NO_KEY_OPTIONS

    0x00004000

    MODE_NO_TABLE_OPTIONS

    0x00008000

    MODE_NO_FIELD_OPTIONS

    0x00010000

    MODE_MYSQL323

    0x00020000

    MODE_MYSQL40

    0x00040000

    MODE_ANSI

    0x00080000

    MODE_NO_AUTO_VALUE_ON_ZERO

    0x00100000

    MODE_NO_BACKSLASH_ESCAPES

    0x00200000

    MODE_STRICT_TRANS_TABLES

    0x00400000

    MODE_STRICT_ALL_TABLES

    0x00800000

    MODE_NO_ZERO_IN_DATE

    0x01000000

    MODE_NO_ZERO_DATE

    0x02000000

    MODE_INVALID_DATES

    0x04000000

    MODE_ERROR_FOR_DIVISION_BY_ZERO

    0x08000000

    MODE_TRADITIONAL

    0x10000000

    MODE_NO_AUTO_CREATE_USER

    0x20000000

    MODE_HIGH_NOT_PRECEDENCE

    0x40000000

    MODE_NO_ENGINE_SUBSTITUTION

    0x80000000

    MODE_PAD_CHAR_TO_FULL_LENGTH

    Q_AUTO_INCREMENT

    2-byte autoincrement-increment and 2-byte autoincrement-offset

    Note

    only written if the -increment is > 1

    Q_CATALOG

    1-byte length + <length> chars of the catalog + '0'-char

    Note

    only written length > 0

    Q_CHARSET_CODE

    2-byte character_set_client + 2-byte collation_connection + 2-byte collation_server

    See Connection Character Sets and Collations

    Q_TIME_ZONE_CODE

    1-byte length + <length> chars of the timezone

    timezone the master is in

    See MySQL Server Time Zone Support

    Note

    only written length > 0

    Q_CATALOG_NZ_CODE

    1-byte length + <length> chars of the catalog

    Note

    only written length > 0

    Q_LC_TIME_NAMES_CODE

    LC_TIME of the server. Defines how to parse week-, month and day-names in timestamps.

    Note

    only written if code > 0 (aka "en_US")

    Q_CHARSET_DATABASE_CODE

    characterset and collation of the schema

    Q_TABLE_MAP_FOR_UPDATE_CODE

    a 64bit-field ... should only be used in Row Based Replication and multi-table updates

    Q_MASTER_DATA_WRITTEN_CODE

    4-byte ...

    Q_INVOKERS

    1-byte length + <length> bytes username and 1-byte length + <length> bytes hostname

    Q_UPDATED_DB_NAMES

    1-byte count + <count> \0 terminated string

    Q_MICROSECONDS

    3-byte microseconds

  • schema (string.var_len) -- [len=$schema_length] schema

  • query (string.EOF) -- text of the query


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.