Documentation Home
MySQL Internals Manual


The first event used in Row Based Replication declares how a table that is about to be changed is defined.


The TABLE_MAP_EVENT defines the structure if the tables that are about to be changed.

    if post_header_len == 6 {
  4              table id
    } else {
  6              table id
  2              flags

  1              schema name length
  string         schema name
  1              [00]
  1              table name length
  string         table name
  1              [00]
  lenenc-int     column-count
  string.var_len [length=$column-count] column-def
  lenenc-str     column-meta-def
  n              NULL-bitmask, length: (column-count + 8) / 7
  • table_id (6) -- numeric table id

  • flags (2) -- flags

  • schema_name_length (1) -- length of the schema name

  • schema_name (string.var_len) -- [len=schema_name_length] schema name

  • table_name_length (1) -- length of the schema name

  • table_name (string.var_len) -- [len=table_name_length] table name

  • column_count (lenenc_int) -- number of columns in the table map

  • column_type_def (string.var_len) -- [len=column_count] array of column definitions, one byte per field type

  • column_meta_def (lenenc_str) -- array of metainfo per column, length is the overall length of the metainfo-array in bytes, the length of each metainfo field is dependent on the columns field type

  • null_bitmap (string.var_len) -- [len=(column_count + 8) / 7]


the column definitions. It is sent as length encoded string where the length of the string is the number of columns and each byte of it is the Protocol::ColumnType of the column.


type-specific metadata for each column


due to Bug37426 layout of the string metadata is a bit tightly packed:

1              byte0
1              byte1

The two bytes encode type and length


a bitmask contained a bit set for each column that can be NULL. The column-length is taken from the column-def

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.
  Posted by Florent Guiliani on October 25, 2013
NULL-bitmask, length: (column-count + 8) / 7
shall be read:
NULL-bitmask, length: (column-count + 7) / 8