MySQL 8.0.39
Source Code Documentation
binary_log::Rows_event Class Reference

Common base class for all row-containing binary log events. More...

#include <rows_event.h>

Inheritance diagram for binary_log::Rows_event:
[legend]

Classes

class  Extra_row_info
 

Public Types

enum  enum_flag { STMT_END_F = (1U << 0) , NO_FOREIGN_KEY_CHECKS_F = (1U << 1) , RELAXED_UNIQUE_CHECKS_F = (1U << 2) , COMPLETE_ROWS_F = (1U << 3) }
 These definitions allow to combine the flags into an appropriate flag set using the normal bitwise operators. More...
 
- Public Types inherited from binary_log::Binary_log_event
enum  enum_post_header_length {
  QUERY_HEADER_MINIMAL_LEN = (4 + 4 + 1 + 2) , QUERY_HEADER_LEN = (QUERY_HEADER_MINIMAL_LEN + 2) , STOP_HEADER_LEN = 0 , START_V3_HEADER_LEN = (2 + ST_SERVER_VER_LEN + 4) ,
  ROTATE_HEADER_LEN = 8 , INTVAR_HEADER_LEN = 0 , APPEND_BLOCK_HEADER_LEN = 4 , DELETE_FILE_HEADER_LEN = 4 ,
  RAND_HEADER_LEN = 0 , USER_VAR_HEADER_LEN = 0 , FORMAT_DESCRIPTION_HEADER_LEN = (START_V3_HEADER_LEN + 1 + LOG_EVENT_TYPES) , XID_HEADER_LEN = 0 ,
  BEGIN_LOAD_QUERY_HEADER_LEN = APPEND_BLOCK_HEADER_LEN , ROWS_HEADER_LEN_V1 = 8 , TABLE_MAP_HEADER_LEN = 8 , EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN = (4 + 4 + 4 + 1) ,
  EXECUTE_LOAD_QUERY_HEADER_LEN , INCIDENT_HEADER_LEN = 2 , HEARTBEAT_HEADER_LEN = 0 , IGNORABLE_HEADER_LEN = 0 ,
  ROWS_HEADER_LEN_V2 = 10 , TRANSACTION_CONTEXT_HEADER_LEN = 18 , VIEW_CHANGE_HEADER_LEN = 52 , XA_PREPARE_HEADER_LEN = 0 ,
  TRANSACTION_PAYLOAD_HEADER_LEN = 0
}
 The lengths for the fixed data part of each event. More...
 

Public Member Functions

 Rows_event (Log_event_type type_arg)
 Constructs an event directly. More...
 
 Rows_event (const char *buf, const Format_description_event *fde)
 The constructor is responsible for decoding the event contained in the buffer. More...
 
 ~Rows_event () override
 
unsigned long long get_table_id () const
 
enum_flag get_flags () const
 
uint32_t get_null_bits_len () const
 
unsigned long get_width () const
 
- Public Member Functions inherited from binary_log::Binary_log_event
virtual ~Binary_log_event ()=0
 
 Binary_log_event (const Binary_log_event &)=default
 
 Binary_log_event (Binary_log_event &&)=default
 
Binary_log_eventoperator= (const Binary_log_event &)=default
 
Binary_log_eventoperator= (Binary_log_event &&)=default
 
enum Log_event_type get_event_type () const
 Helper method. More...
 
const Log_event_headerheader () const
 Return a const pointer to the header of the log event. More...
 
Log_event_headerheader ()
 Return a non-const pointer to the header of the log event. More...
 
const Log_event_footerfooter () const
 Return a const pointer to the footer of the log event. More...
 
Log_event_footerfooter ()
 Return a non-const pointer to the footer of the log event. More...
 
Event_readerreader ()
 Returns a reference to the event Event_reader object. More...
 

Static Public Member Functions

static std::string get_flag_string (enum_flag flag)
 

Public Attributes

Extra_row_info m_extra_row_info
 

Protected Attributes

Log_event_type m_type
 
Table_id m_table_id
 Actual event type. More...
 
uint16_t m_flags
 
unsigned long m_width
 Flags for row-level events. More...
 
uint32_t n_bits_len
 The width of the columns bitmap. More...
 
uint16_t var_header_len
 value determined by (m_width + 7) / 8 More...
 
std::vector< uint8_t > columns_before_image
 
std::vector< uint8_t > columns_after_image
 
std::vector< uint8_t > row
 

Friends

template<class Iterator_value_type >
class Row_event_iterator
 

Additional Inherited Members

- Static Public Attributes inherited from binary_log::Binary_log_event
static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 
- Protected Member Functions inherited from binary_log::Binary_log_event
 Binary_log_event (Log_event_type type_code)
 This constructor is used to initialize the type_code of header object m_header. More...
 
 Binary_log_event (const char **buf, const Format_description_event *fde)
 This constructor will create a new object of Log_event_header and initialize the variable m_header, which in turn will be used to initialize Log_event's member common_header. More...
 

Detailed Description

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

Member Enumeration Documentation

◆ enum_flag

These definitions allow to combine the flags into an appropriate flag set using the normal bitwise operators.

The implicit conversion from an enum-constant to an integer is accepted by the compiler, which is then used to set the real set of flags.

Enumerator
STMT_END_F 

Last event of a statement.

NO_FOREIGN_KEY_CHECKS_F 

Value of the OPTION_NO_FOREIGN_KEY_CHECKS flag in thd->options.

RELAXED_UNIQUE_CHECKS_F 

Value of the OPTION_RELAXED_UNIQUE_CHECKS flag in thd->options.

COMPLETE_ROWS_F 

Indicates that rows in this event are complete, that is contain values for all columns of the table.

Constructor & Destructor Documentation

◆ Rows_event() [1/2]

binary_log::Rows_event::Rows_event ( Log_event_type  type_arg)
inlineexplicit

Constructs an event directly.

The members are assigned default values.

Parameters
type_argType of ROW_EVENT. Expected types are:
  • WRITE_ROWS_EVENT, WRITE_ROWS_EVENT_V1
  • UPDATE_ROWS_EVENT, UPDATE_ROWS_EVENT_V1, PARTIAL_UPDATE_ROWS_EVENT
  • DELETE_ROWS_EVENT, DELETE_ROWS_EVENT_V1

◆ Rows_event() [2/2]

binary_log::Rows_event::Rows_event ( const char *  buf,
const Format_description_event fde 
)

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
bufContains the serialized event.
fdeAn FDE event (see Rotate_event constructor for more info).

◆ ~Rows_event()

binary_log::Rows_event::~Rows_event ( )
overridedefault

Member Function Documentation

◆ get_flag_string()

static std::string binary_log::Rows_event::get_flag_string ( enum_flag  flag)
inlinestatic

◆ get_flags()

enum_flag binary_log::Rows_event::get_flags ( ) const
inline

◆ get_null_bits_len()

uint32_t binary_log::Rows_event::get_null_bits_len ( ) const
inline

◆ get_table_id()

unsigned long long binary_log::Rows_event::get_table_id ( ) const
inline

◆ get_width()

unsigned long binary_log::Rows_event::get_width ( ) const
inline

Friends And Related Function Documentation

◆ Row_event_iterator

template<class Iterator_value_type >
friend class Row_event_iterator
friend

Member Data Documentation

◆ columns_after_image

std::vector<uint8_t> binary_log::Rows_event::columns_after_image
protected

◆ columns_before_image

std::vector<uint8_t> binary_log::Rows_event::columns_before_image
protected

◆ m_extra_row_info

Extra_row_info binary_log::Rows_event::m_extra_row_info

◆ m_flags

uint16_t binary_log::Rows_event::m_flags
protected

◆ m_table_id

Table_id binary_log::Rows_event::m_table_id
protected

Actual event type.

Post header content

◆ m_type

Log_event_type binary_log::Rows_event::m_type
protected

◆ m_width

unsigned long binary_log::Rows_event::m_width
protected

Flags for row-level events.

◆ n_bits_len

uint32_t binary_log::Rows_event::n_bits_len
protected

The width of the columns bitmap.

◆ row

std::vector<uint8_t> binary_log::Rows_event::row
protected

◆ var_header_len

uint16_t binary_log::Rows_event::var_header_len
protected

value determined by (m_width + 7) / 8


The documentation for this class was generated from the following files: