TABLE_MAP_EVENT

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

Used for row-based binary logging beginning (binlog_format=ROW in my.cnf)

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.

  • Event Type is 19 (0x13)

Fields

Fixed data part:

Variable data part:

  • uint<1> Database name length.
  • string<NUL> The database name (null-terminated).
  • uint<1> Table name length.
  • string<NUL> The table name (null-terminated).
  • int<lenenc> The number of columns in the table.
  • byte<n> An array of 'n' column types, one byte per column.
  • int<lenenc> The length of the metadata block.
  • byte<n> The metadata block;
  • byte<n> Bit-field indicating whether each column can be NULL, one bit per column.
  • if (more_data_available)

Metadata block

The metadata block contains type specific metadata information for each column

TypeLengthDescription
MYSQL_TYPE_BLOB1Number of bytes for length: e.g. 4 bytes means length is stored in a 4 byte integer)
MYSQL_TYPE_DATETIME21Length of microseconds
MYSQL_TYPE_DECIMAL2Not in use anymore
MYSQL_TYPE_DOUBLE ,MYSQL_TYPE_FLOAT1length (4 or 8 bytes
MYSQL_TPE_STRING21st byte contains type (MYSQL_TYPE_STRING, MYSQL_TYPE_ENUM, or MYSQL_TYPE_SET, 2nd byte contains length
MYSQL_TYPE_NEWDECIMAL2Precision, Sclale
MYSQL_TYPE_TIME21Number of bytes used to store microseconds
MYSQL_TYPE_TIMESTAMP21Number of bytes used to store microseconds
MYSQL_TYPE_VARCHAR, MYSQL_TYPE_VAR_STRING2Defined varchar length. If the value is > 255, length is stored in 2 bytes, otherwise 1 byte

Optional metadata block

Optional metadata will be available if global server variable BINLOG_ROW_METADATA was set to values MIN or FULL.

Example From mysqlbinlog

# 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

Complete Event

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

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.