Common base class for all row-containing binary log events.
RESPONSIBILITIES
- Provide an interface for adding an individual row to the event.
Binary Format
The Post-Header has the following components:
Post-Header for Rows_event
Name | Format | Description
|
table_id | 6 bytes unsigned integer | The number that identifies the table
|
flags | 2 byte bitfield | Reserved for future use; currently always 0.
|
The Body has the following components:
Body for Rows_event
Name | Format | Description
|
width | packed integer | Represents the number of columns in the table
|
cols | Bitfield, variable sized | Indicates whether each column is used, one bit per column. For this field, the amount of storage required is INT((width + 7) / 8) bytes.
|
extra_row_info | An object of class Extra_row_info | The class Extra_row_info will be storing the information related to m_extra_row_ndb_info and partition info (partition_id and source_partition_id). At any given time a Rows_event can have both, one or none of ndb_info and partition_info present as part of Rows_event. In case both ndb_info and partition_info are present then below will be the order in which they will be stored.
+----------+--------------------------------------+
|type_code | extra_row_ndb_info |
+--- ------+--------------------------------------+
| NDB |Len of ndb_info |Format |ndb_data |
| 1 byte |1 byte |1 byte |len - 2 byte |
+----------+----------------+-------+-------------+
In case of INSERT/DELETE
+-----------+----------------+
| type_code | partition_info |
+-----------+----------------+
| PART | partition_id |
| (1 byte) | 2 byte |
+-----------+----------------+
In case of UPDATE
+-----------+------------------------------------+
| type_code | partition_info |
+-----------+--------------+---------------------+
| PART | partition_id | source_partition_id |
| (1 byte) | 2 byte | 2 byte |
+-----------+--------------+---------------------+
source_partition_id is used only in the case of Update_event
to log the partition_id of the source partition. This is the format for any information stored as extra_row_info. type_code is not a part of the class Extra_row_info as it is a constant values used at the time of serializing and decoding the event.
|
columns_before_image | vector of elements of type uint8_t | For DELETE and UPDATE only. Bit-field indicating whether each column is used one bit per column. For this field, the amount of storage required for N columns is INT((N + 7) / 8) bytes.
|
columns_after_image | vector of elements of type uint8_t | For WRITE and UPDATE only. Bit-field indicating whether each column is used in the UPDATE_ROWS_EVENT and WRITE_ROWS_EVENT after-image; one bit per column. For this field, the amount of storage required for N columns is INT((N + 7) / 8) bytes.
+-------------------------------------------------------+
| Event Type | Cols_before_image | Cols_after_image |
+-------------------------------------------------------+
| DELETE | Deleted row | NULL |
| INSERT | NULL | Inserted row |
| UPDATE | Old row | Updated row |
+-------------------------------------------------------+
|
row | vector of elements of type uint8_t | A sequence of zero or more rows. The end is determined by the size of the event. Each row has the following format:
- A Bit-field indicating whether each field in the row is NULL. Only columns that are "used" according to the second field in the variable data part are listed here. If the second field in the variable data part has N one-bits, the amount of storage required for this field is INT((N + 7) / 8) bytes.
- The row-image, containing values of all table fields. This only lists table fields that are used (according to the second field of the variable data part) and non-NULL (according to the previous field). In other words, the number of values listed here is equal to the number of zero bits in the previous field. (not counting padding bits in the last byte).
For example, if a INSERT statement inserts into 4 columns of a
table, N= 4 (in the formula above).
length of bitmask= (4 + 7) / 8 = 1
Number of fields in the row= 4.
+------------------------------------------------+
|Null_bit_mask(4)|field-1|field-2|field-3|field 4|
+------------------------------------------------+
|
The constructor is responsible for decoding the event contained in the buffer.
The buffer layout for fixed data part is as follows
+------------------------------------+
| table_id | reserved for future use |
+------------------------------------+
The buffer layout for variable data part is as follows
+------------------------------------------------------------------+
| var_header_len | column_before_image | columns_after_image | row |
+------------------------------------------------------------------+
- Parameters
-
buf | Contains the serialized event. |
fde | An FDE event (see Rotate_event constructor for more info). |