Documentation Home
MySQL Internals Manual


14.10.2 ROWS_EVENT

Three basic kinds of ROWS_EVENT exist:

Event

SQL Command

rows Contents

WRITE_ROWS_EVENT

INSERT

the row data to insert

DELETE_ROWS_EVENT

DELETE

as much data as needed to identify a row

UPDATE_ROWS_EVENT

UPDATE

as much data as needed to identify a row + the data to change

The format of the events changed between releases which is why 3 diffent sets of ROWS_EVENT exist:

Version 0

written from MySQL 5.1.0 to 5.1.15

  • UPDATE_ROWS_EVENTv0

  • WRITE_ROWS_EVENTv0

  • DELETE_ROWS_EVENTv0

Version 1

written from MySQL 5.1.15 to 5.6.x

  • UPDATE_ROWS_EVENTv1

  • WRITE_ROWS_EVENTv1

  • DELETE_ROWS_EVENTv1

added the after-image for the UPDATE_ROWS_EVENT

Version 2

written from MySQL 5.6.x

  • UPDATE_ROWS_EVENTv2

  • WRITE_ROWS_EVENTv2

  • DELETE_ROWS_EVENTv2

added the extra-data fields

The format is pretty similar for all the events:

Binlog::RowsEvent:
Payload
header:
  if post_header_len == 6 {
4                    table id
  } else {
6                    table id
  }
2                    flags
  if version == 2 {
2                    extra-data-length
string.var_len       extra-data
  }

body:
lenenc_int           number of columns
string.var_len       columns-present-bitmap1, length: (num of columns+7)/8
  if UPDATE_ROWS_EVENTv1 or v2 {
string.var_len       columns-present-bitmap2, length: (num of columns+7)/8
  }

rows:
string.var_len       nul-bitmap, length (bits set in 'columns-present-bitmap1'+7)/8
string.var_len       value of each field as defined in table-map
  if UPDATE_ROWS_EVENTv1 or v2 {
string.var_len       nul-bitmap, length (bits set in 'columns-present-bitmap2'+7)/8
string.var_len       value of each field as defined in table-map
  }
  ... repeat rows until event-end
Fields
  • table_id (6) -- If the table id is 0x00ffffff it is a dummy event that should have the end of statement flag set that declares that all table maps can be freed. Otherwise it refers to a table defined by TABLE_MAP_EVENT.

    Note

    if the post_header_length in the Binlog::FORMAT_DESCRIPTION_EVENT is 6 (instead of 8 or 10) the table_id is only 4 bytes long.

  • flags (2) --

    Hex

    Name

    0x0001

    end of statement

    0x0002

    no foreign key checks

    0x0004

    no unique key checks

    0x0008

    row has a columns

  • extra_data_len (2) -- length of extra_data (has to be ≥ 2)

  • extra_data (string.var_len) -- extra_data [length=extra_data_len - 2], zero or more Binlog::RowsEventExtraData

Binlog::RowsEventExtraData:
Payload
1              type
string.len     type-specific data
Fields

type (1) --

Nex

Name

0x00

RW_V_EXTRAINFO_TAG

Binlog::RowsEventExtraDataExtraInfo:
Payload
1              length
1              format
string.len     payload [length=length]
Fields
  • length (1) -- length of the payload

  • format (1) -- format of the payload

    Hex

    Format

    0x00

    NDB

    0x40

    OPEN1

    0x41

    OPEN2

    0xFF

    MULTI

  • payload (string.var_len) -- payload [length=length]

Binlog::RowsEventExtraDataExtraInfoFormat:

not used in 5.6.6 yet


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.