All pages
Powered by GitBook
1 of 1

Loading...

TABLE_MAP_EVENT

This event provides a mapping between a table ID and its table definition, preceding row events to interpret the row data correctly.

Used for row-based binary logging beginning (binlog_format=ROW or MIXED).

This event precedes each row operation event and maps a table definition to a number, where the table definition consists of database and table names.

Header

  • Event Type is 19 (0x13).

Fields

Fixed Data Part

  • The table ID.

  • Reserved for future use.

Variable Data Part

  • Database name length.

  • The database name (null-terminated).

  • Table name length.

  • The table name (null-terminated).

Metadata Block

The metadata block contains type specific metadata information for each column.

Type
Length
Description

Optional Metadata Block

Optional metadata are available if the global server variable BINLOG_ROW_METADATA is set to MIN or FULL.

The metadata block consists of one or more of the following blocks:

  • Optional metadata type.

  • Length.

  • Data.

Optional metadata types:

Name
Value
Mode
Description

Example From mysqlbinlog

Complete Event

This page is licensed: CC BY-SA / Gnu FDL

int The number of columns in the table.

  • byte An array of 'n' column types, one byte per column.

  • int The length of the metadata block.

  • byte The metadata block;

  • byte Bit-field indicating whether each column can be NULL, one bit per column.

  • If (more_data_available):

    • byte Optional metadata block.

  • MYSQL_TYPE_STRING

    2

    The first byte contains type (MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET). The second byte contains the length.

    MYSQL_TYPE_NEWDECIMAL

    2

    Precision, Scale.

    MYSQL_TYPE_TIME2

    1

    Length in microseconds.

    MYSQL_TYPE_TIMESTAMP2

    1

    Length in microseconds.

    MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VAR_STRING

    2

    Defined varchar length. If the value is > 255, the length is stored in 2 bytes, otherwise in 1 byte.

    COLUMN_NAME

    4

    FULL

    List of Column names, the first byte specifies the length of the column name.

    SET_STR_VALUE

    5

    FULL

    List of set values: First byte is the number of different values, followed by length/value pairs.

    ENUM_STR_VALUE

    6

    FULL

    Same as SET_STR_VALUE. Since ENUM values might have up to 0xFFFF members, the number of values is a length encoded integer.

    GEOMETRY_TYPE

    7

    FULL

    A sequence of bytes repesenting the type of GEOMETRY columns: 0 = GEOMETRY, 1 = POINT, 2 = LINESTRING, 3 = POLYGON, 4=MULTIPOINT, 5 = MULTILINESTRING, 6 = MULTIPOLYGON, 7 = GEOMETRYCOLLECTION.

    SIMPLE_PRIMARY_KEY

    8

    FULL

    A sequence of length encoded column indexes.

    PRIMARY_KEY_WITH_PREFIX

    9

    FULL

    A sequence of length encoded column indexes and prefix lengths.

    ENUM_AND_SET_DEFAULT_CHARSET

    10

    FULL

    The default character set number used for ENUM and SET columns.

    ENUM_AND_SET_COLUMN_CHARSET

    11

    FULL

    Character set of ENUM and SET columns, used if these columns have different character sets. Returned as a sequence of collation numbers.

    MYSQL_TYPE_BLOB

    1

    Number of bytes for length: e.g. 4 bytes means length is stored in a 4 byte integer).

    MYSQL_TYPE_DATETIME2

    1

    Length of microseconds.

    MYSQL_TYPE_DECIMAL

    2

    Not in use anymore.

    MYSQL_TYPE_DOUBLE ,MYSQL_TYPE_FLOAT

    1

    length (4 or 8 bytes).

    SIGNEDNESS

    1

    MIN

    Data contains a bitmap indicating which integer columns are signed.

    DEFAULT_CHARSET

    2

    MIN

    Character set of string columns, used if most columns have the same result. Columns with other character sets will follow as pair (column_index, collation number).

    COLUMN_CHARSET

    3

    MIN

    uint<6>
    uint<2>
    uint<1>
    string
    uint<1>
    string
    byte<1>
    int
    byte

    Character set of columns, used if columns have different character sets. Returned as a sequence of collation numbers.

    # at 847
    #171206 13:43:00 server id 10124  end_log_pos 892 CRC32 0xbe3c6b05 	Table_map: `test`.`t4` mapped to number 33
    # at 892
    d4 e5 27 5a 13 8c 27 00  00 2d 00 00 00 7c 03 00  ..'Z..'..-...|..
    00 00 00 21 00 00 00 00  00 01 00 04 74 65 73 74  ...!........test
    00 02 74 34 00 01 03 01  01 05 6b 3c be           ..t4......k<.