MySQL 9.0.0
Source Code Documentation
Table_map_log_event Class Reference

Table_map_log_event which maps a table definition to a number. More...

#include <log_event.h>

Inheritance diagram for Table_map_log_event:
[legend]

Public Types

enum  { TYPE_CODE = mysql::binlog::event::TABLE_MAP_EVENT }
 Constants. More...
 
enum  enum_error {
  ERR_OPEN_FAILURE = -1 , ERR_OK = 0 , ERR_TABLE_LIMIT_EXCEEDED = 1 , ERR_OUT_OF_MEM = 2 ,
  ERR_BAD_TABLE_DEF = 3 , ERR_RBR_TO_SBR = 4
}
 Enumeration of the errors that can be returned. More...
 
enum  enum_flag { ENUM_FLAG_COUNT }
 
enum  { TM_NO_FLAGS = 0U , TM_BIT_LEN_EXACT_F = (1U << 0) , TM_REFERRED_FK_DB_F = (1U << 1) , TM_GENERATED_INVISIBLE_PK_F = (1U << 2) }
 Special constants representing sets of flags. More...
 
- Public Types inherited from mysql::binlog::event::Table_map_event
enum  Table_map_event_offset { TM_MAPID_OFFSET = 0 , TM_FLAGS_OFFSET = 6 }
 Constants representing offsets. More...
 
enum  Optional_metadata_field_type {
  SIGNEDNESS = 1 , DEFAULT_CHARSET , COLUMN_CHARSET , COLUMN_NAME ,
  SET_STR_VALUE , ENUM_STR_VALUE , GEOMETRY_TYPE , SIMPLE_PRIMARY_KEY ,
  PRIMARY_KEY_WITH_PREFIX , ENUM_AND_SET_DEFAULT_CHARSET , ENUM_AND_SET_COLUMN_CHARSET , COLUMN_VISIBILITY ,
  VECTOR_DIMENSIONALITY
}
 DEFAULT_CHARSET and COLUMN_CHARSET don't appear together, and ENUM_AND_SET_DEFAULT_CHARSET and ENUM_AND_SET_COLUMN_CHARSET don't appear together. More...
 
typedef uint16_t flag_set
 
- Public Types inherited from mysql::binlog::event::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 Types inherited from Log_event
enum  enum_skip_reason { EVENT_SKIP_NOT , EVENT_SKIP_IGNORE , EVENT_SKIP_COUNT }
 Enumeration of what kinds of skipping (and non-skipping) that can occur when the slave executes an event. More...
 

Public Member Functions

 Table_map_log_event (Table_map_log_event &&) noexcept=delete
 
Table_map_log_eventoperator= (Table_map_log_event &&) noexcept=delete
 
 Table_map_log_event (const Table_map_log_event &)=delete
 
Table_map_log_eventoperator= (const Table_map_log_event &)=delete
 
flag_set get_flags (flag_set flag) const
 
 Table_map_log_event (THD *thd_arg, TABLE *tbl, const mysql::binlog::event::Table_id &tid, bool using_trans)
 
 Table_map_log_event (const char *buf, const mysql::binlog::event::Format_description_event *description_event)
 
void claim_memory_ownership (bool claim) override
 Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed. More...
 
 ~Table_map_log_event () override
 
const mysql::binlog::event::Table_idget_table_id () const
 
const char * get_table_name () const
 
const char * get_db_name () const
 
size_t get_data_size () override
 
virtual int save_field_metadata ()
 Save the field metadata based on the real_type of the field. More...
 
bool write_data_header (Basic_ostream *ostream) override
 
bool write_data_body (Basic_ostream *ostream) override
 
const char * get_db () override
 
uint8 mts_number_dbs () override
 
uint8 get_mts_dbs (Mts_db_names *arg, Rpl_filter *rpl_filter) override
 
int pack_info (Protocol *protocol) override
 Stores a string representation of this event in the Protocol. More...
 
bool has_generated_invisible_primary_key () const
 
bool is_rbr_logging_format () const override
 Return true if the event has to be logged using RBR for DMLs. More...
 
- Public Member Functions inherited from mysql::binlog::event::Table_map_event
 Table_map_event (const char *buf, const Format_description_event *fde)
 
 Table_map_event (const Table_id &tid, unsigned long colcnt, const char *dbnam, size_t dblen, const char *tblnam, size_t tbllen)
 
 ~Table_map_event () override
 
 Table_map_event ()
 
unsigned long long get_table_id ()
 
std::string get_table_name ()
 
std::string get_db_name ()
 
- Public Member Functions inherited from mysql::binlog::event::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...
 
- Public Member Functions inherited from Log_event
 Log_event (mysql::binlog::event::Log_event_header *header, mysql::binlog::event::Log_event_footer *footer, enum_event_cache_type cache_type_arg, enum_event_logging_type logging_type_arg)
 This minimal constructor is for when you are not even sure that there is a valid THD. More...
 
 Log_event (THD *thd_arg, uint16 flags_arg, enum_event_cache_type cache_type_arg, enum_event_logging_type logging_type_arg, mysql::binlog::event::Log_event_header *header, mysql::binlog::event::Log_event_footer *footer)
 
int net_send (Protocol *protocol, const char *log_name, my_off_t pos)
 Only called by SHOW BINLOG EVENTS. More...
 
void * operator new (size_t size)
 
bool wrapper_my_b_safe_write (Basic_ostream *ostream, const uchar *buf, size_t data_length)
 Write the given buffer to the given output stream, updating the checksum if checksums are enabled. More...
 
virtual bool write (Basic_ostream *ostream)
 
time_t get_time ()
 Prints a "session_var=value" string. More...
 
virtual mysql::binlog::event::Log_event_type get_type_code () const
 
virtual bool is_sbr_logging_format () const
 Return true if the event has to be logged using SBR for DMLs. More...
 
bool is_valid ()
 
void set_artificial_event ()
 
void set_relay_log_event ()
 
bool is_artificial_event () const
 
bool is_relay_log_event () const
 
bool is_ignorable_event () const
 
bool is_no_filter_event () const
 
bool is_using_trans_cache () const
 
bool is_using_stmt_cache () const
 
bool is_using_immediate_logging () const
 
 Log_event (mysql::binlog::event::Log_event_header *header, mysql::binlog::event::Log_event_footer *footer)
 
virtual ~Log_event ()
 
void register_temp_buf (char *buf, bool free_in_destructor=true)
 
void free_temp_buf ()
 
const char * get_type_str () const
 Returns the human readable name of this event's type. More...
 
bool is_mts_sequential_exec ()
 Is called from get_mts_execution_mode() to. More...
 
bool contains_partition_info (bool)
 
bool is_mts_group_isolated ()
 
virtual bool starts_group () const
 Events of a certain type can start or end a group of events treated transactionally wrt binlog. More...
 
virtual bool ends_group () const
 
int apply_event (Relay_log_info *rli)
 Apply the event to the database. More...
 
int apply_gtid_event (Relay_log_info *rli)
 Apply the GTID event in curr_group_data to the database. More...
 
int update_pos (Relay_log_info *rli)
 Update the relay log position. More...
 
enum_skip_reason shall_skip (Relay_log_info *rli)
 Decide if the event shall be skipped, and the reason for skipping it. More...
 
virtual int do_apply_event_worker (Slave_worker *w)
 

Private Member Functions

int do_apply_event (Relay_log_info const *rli) override
 Primitive to apply an event to the database. More...
 
int do_update_pos (Relay_log_info *rli) override
 Advance relay log coordinates. More...
 
enum_skip_reason do_shall_skip (Relay_log_info *rli) override
 Decide if this event shall be skipped or not and the reason for skipping it. More...
 
void init_metadata_fields ()
 Capture the optional metadata fields which should be logged into table_map_log_event and serialize them into m_metadata_buf. More...
 
bool init_signedness_field ()
 
bool init_charset_field (std::function< bool(const Field *)> include_type, Optional_metadata_field_type default_charset_type, Optional_metadata_field_type column_charset_type)
 Capture and serialize character sets. More...
 
bool init_column_name_field ()
 
bool init_set_str_value_field ()
 
bool init_enum_str_value_field ()
 
bool init_geometry_type_field ()
 
bool init_primary_key_field ()
 
bool init_column_visibility_field ()
 
bool init_vector_dimensionality_field ()
 

Private Attributes

TABLEm_table
 
StringBuffer< 1024 > m_metadata_buf
 
ColumnViewPtr m_column_view {nullptr}
 Wrapper around TABLE *m_table that abstracts the table field set iteration logic, since it is not mandatory that all table fields are to be replicated. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Log_event
static void init_show_field_list (mem_root_deque< Item * > *field_list)
 init_show_field_list() prepares the column names and types for the output of SHOW BINLOG EVENTS; it is used only by SHOW BINLOG EVENTS. More...
 
static void operator delete (void *ptr, size_t)
 
static void * operator new (size_t, void *ptr)
 
static void operator delete (void *, void *)
 
static const char * get_type_str (mysql::binlog::event::Log_event_type type)
 Returns the human readable name of the given event type. More...
 
static const char * get_type_str (uint type)
 Get the name of an event type, or "Unknown" if out of range. More...
 
- Public Attributes inherited from mysql::binlog::event::Table_map_event
Table_id m_table_id
 Event post header contents. More...
 
flag_set m_flags
 
size_t m_data_size
 
std::string m_dbnam
 event data size More...
 
unsigned long long int m_dblen
 
std::string m_tblnam
 
unsigned long long int m_tbllen
 
unsigned long m_colcnt
 
unsigned char * m_coltype
 
unsigned long m_field_metadata_size
 The size of field metadata buffer set by calling save_field_metadata() More...
 
unsigned char * m_field_metadata
 
unsigned char * m_null_bits
 field metadata More...
 
unsigned int m_optional_metadata_len
 
unsigned char * m_optional_metadata
 
- Public Attributes inherited from Log_event
char * temp_buf
 
bool m_free_temp_buf_in_destructor
 
ulong exec_time
 
uint32 server_id
 
ulong rbr_exec_mode
 A storage to cache the global system variable's value. More...
 
enum_event_cache_type event_cache_type
 Defines the type of the cache, if any, where the event will be stored before being flushed to disk. More...
 
enum_event_logging_type event_logging_type
 Defines when information, i.e. More...
 
ha_checksum crc
 Placeholder for event checksum while writing to binlog. More...
 
ulong mts_group_idx
 Index in rli->gaq array to indicate a group that this event is purging. More...
 
mysql::binlog::event::Log_event_headercommon_header
 The Log_event_header class contains the variable present in the common header. More...
 
mysql::binlog::event::Log_event_footercommon_footer
 The Log_event_footer class contains the variable present in the common footer. More...
 
Relay_log_infoworker
 MTS: associating the event with either an assigned Worker or Coordinator. More...
 
ulonglong future_event_relay_log_pos
 A copy of the main rli value stored into event to pass to MTS worker rli. More...
 
THDthd
 
db_worker_hash_entrymts_assigned_partitions [MAX_DBS_IN_EVENT_MTS]
 Partition info associate with event to deliver to MTS event applier. More...
 
- Static Public Attributes inherited from mysql::binlog::event::Binary_log_event
static const int LOG_EVENT_TYPES = (ENUM_END_EVENT - 1)
 
- Protected Types inherited from Log_event
enum  enum_event_cache_type {
  EVENT_INVALID_CACHE = 0 , EVENT_STMT_CACHE , EVENT_TRANSACTIONAL_CACHE , EVENT_NO_CACHE ,
  EVENT_CACHE_COUNT
}
 
enum  enum_event_logging_type { EVENT_INVALID_LOGGING = 0 , EVENT_NORMAL_LOGGING , EVENT_IMMEDIATE_LOGGING , EVENT_CACHE_LOGGING_COUNT }
 
- Protected Member Functions inherited from mysql::binlog::event::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...
 
- Protected Member Functions inherited from Log_event
uint32 write_header_to_memory (uchar *buf)
 Writes the common header of this event to the given memory buffer. More...
 
bool write_header (Basic_ostream *ostream, size_t data_length)
 Writes the common-header of this event to the given output stream and updates the checksum. More...
 
bool write_footer (Basic_ostream *ostream)
 
bool need_checksum ()
 A decider of whether to trigger checksum computation or not. More...
 
enum_skip_reason continue_group (Relay_log_info *rli)
 Helper function to ignore an event w.r.t. More...
 

Detailed Description

Table_map_log_event which maps a table definition to a number.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Constants.

Enumerator
TYPE_CODE 

◆ anonymous enum

anonymous enum

Special constants representing sets of flags.

Enumerator
TM_NO_FLAGS 
TM_BIT_LEN_EXACT_F 
TM_REFERRED_FK_DB_F 
TM_GENERATED_INVISIBLE_PK_F 

Table has generated invisible primary key.

MySQL generates primary key while creating a table if sql_generate_invisible_primary_key is "ON" and table is PK-less.

◆ enum_error

Enumeration of the errors that can be returned.

Enumerator
ERR_OPEN_FAILURE 

Failure to open table.

ERR_OK 

No error.

ERR_TABLE_LIMIT_EXCEEDED 

No more room for tables.

ERR_OUT_OF_MEM 

Out of memory.

ERR_BAD_TABLE_DEF 

Table definition does not match.

ERR_RBR_TO_SBR 

daisy-chanining RBR to SBR not allowed

◆ enum_flag

Enumerator
ENUM_FLAG_COUNT 

Nothing here right now, but the flags support is there in preparation for changes that are coming.

Need to add a constant to make it compile under HP-UX: aCC does not like empty enumerations.

Constructor & Destructor Documentation

◆ Table_map_log_event() [1/4]

Table_map_log_event::Table_map_log_event ( Table_map_log_event &&  )
deletenoexcept

◆ Table_map_log_event() [2/4]

Table_map_log_event::Table_map_log_event ( const Table_map_log_event )
delete

◆ Table_map_log_event() [3/4]

Table_map_log_event::Table_map_log_event ( THD thd_arg,
TABLE tbl,
const mysql::binlog::event::Table_id tid,
bool  using_trans 
)

◆ Table_map_log_event() [4/4]

Table_map_log_event::Table_map_log_event ( const char *  buf,
const mysql::binlog::event::Format_description_event description_event 
)

◆ ~Table_map_log_event()

Table_map_log_event::~Table_map_log_event ( )
overridedefault

Member Function Documentation

◆ claim_memory_ownership()

void Table_map_log_event::claim_memory_ownership ( bool  claim)
overridevirtual

Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.

Parameters
claimTrue - claim ownership of the memory False - disclaim ownership of the memory

Reimplemented from Log_event.

◆ do_apply_event()

int Table_map_log_event::do_apply_event ( Relay_log_info const *  rli)
overrideprivatevirtual

Primitive to apply an event to the database.

This is where the change to the database is made.

Note
The primitive is protected instead of private, since there is a hierarchy of actions to be performed in some cases.
See also
Format_description_log_event::do_apply_event()
Parameters
rliPointer to relay log info structure
Return values
0Event applied successfully
errnoError code if event application failed

Reimplemented from Log_event.

◆ do_shall_skip()

Log_event::enum_skip_reason Table_map_log_event::do_shall_skip ( Relay_log_info rli)
overrideprivatevirtual

Decide if this event shall be skipped or not and the reason for skipping it.

The default implementation decide that the event shall be skipped if either:

  • the server id of the event is the same as the server id of the server and rli->replicate_same_server_id is true, or
  • if rli->slave_skip_counter is greater than zero.
See also
do_apply_event
do_update_pos
Return values
Log_event::EVENT_SKIP_NOTThe event shall not be skipped and should be applied.
Log_event::EVENT_SKIP_IGNOREThe event shall be skipped by just ignoring it, i.e., the slave skip counter shall not be changed. This happends if, for example, the originating server id of the event is the same as the server id of the slave.
Log_event::EVENT_SKIP_COUNTThe event shall be skipped because the slave skip counter was non-zero. The caller shall decrease the counter by one.

Reimplemented from Log_event.

◆ do_update_pos()

int Table_map_log_event::do_update_pos ( Relay_log_info rli)
overrideprivatevirtual

Advance relay log coordinates.

This function is called to advance the relay log coordinates to just after the event. It is essential that both the relay log coordinate and the group log position is updated correctly, since this function is used also for skipping events.

Normally, each implementation of do_update_pos() shall:

  • Update the event position to refer to the position just after the event.
  • Update the group log position to refer to the position just after the event if the event is last in a group
Parameters
rliPointer to relay log info structure
Return values
0Coordinates changed successfully
errnoError code if advancing failed (usually just 1). Observe that handler errors are returned by the do_apply_event() function, and not by this one.

Reimplemented from Log_event.

◆ get_data_size()

size_t Table_map_log_event::get_data_size ( )
inlineoverridevirtual

Reimplemented from Log_event.

◆ get_db()

const char * Table_map_log_event::get_db ( )
inlineoverridevirtual

Reimplemented from Log_event.

◆ get_db_name()

const char * Table_map_log_event::get_db_name ( ) const
inline

◆ get_flags()

flag_set Table_map_log_event::get_flags ( flag_set  flag) const
inline

◆ get_mts_dbs()

uint8 Table_map_log_event::get_mts_dbs ( Mts_db_names arg,
Rpl_filter rpl_filter 
)
inlineoverridevirtual
Parameters
[out]argpointer to a struct containing char* array pointers be filled in and the number of filled instances.
rpl_filterpointer to a replication filter.
Returns
number of databases in the array: either one or OVER_MAX_DBS_IN_EVENT_MTS, when the Table map event reports foreign keys constraint.

Reimplemented from Log_event.

◆ get_table_id()

const mysql::binlog::event::Table_id & Table_map_log_event::get_table_id ( ) const
inline

◆ get_table_name()

const char * Table_map_log_event::get_table_name ( ) const
inline

◆ has_generated_invisible_primary_key()

bool Table_map_log_event::has_generated_invisible_primary_key ( ) const

◆ init_charset_field()

bool Table_map_log_event::init_charset_field ( std::function< bool(const Field *)>  include_type,
Optional_metadata_field_type  default_charset_type,
Optional_metadata_field_type  column_charset_type 
)
private

Capture and serialize character sets.

Character sets for character columns (TEXT etc) and character sets for ENUM and SET columns are stored in different metadata fields. The reason is that TEXT character sets are included even when binlog_row_metadata=MINIMAL, whereas ENUM and SET character sets are included only when binlog_row_metadata=FULL.

Parameters
include_typePredicate to determine if a given Field object is to be included in the metadata field.
default_charset_typeType code when storing in "default charset" format. (See comment above Table_maps_log_event in mysql/binlog/event/rows_event.h)
column_charset_typeType code when storing in "column charset" format. (See comment above Table_maps_log_event in mysql/binlog/event/rows_event.h)

◆ init_column_name_field()

bool Table_map_log_event::init_column_name_field ( )
private

◆ init_column_visibility_field()

bool Table_map_log_event::init_column_visibility_field ( )
private

◆ init_enum_str_value_field()

bool Table_map_log_event::init_enum_str_value_field ( )
private

◆ init_geometry_type_field()

bool Table_map_log_event::init_geometry_type_field ( )
private

◆ init_metadata_fields()

void Table_map_log_event::init_metadata_fields ( )
private

Capture the optional metadata fields which should be logged into table_map_log_event and serialize them into m_metadata_buf.

◆ init_primary_key_field()

bool Table_map_log_event::init_primary_key_field ( )
private

◆ init_set_str_value_field()

bool Table_map_log_event::init_set_str_value_field ( )
private

◆ init_signedness_field()

bool Table_map_log_event::init_signedness_field ( )
private

◆ init_vector_dimensionality_field()

bool Table_map_log_event::init_vector_dimensionality_field ( )
private

◆ is_rbr_logging_format()

bool Table_map_log_event::is_rbr_logging_format ( ) const
inlineoverridevirtual

Return true if the event has to be logged using RBR for DMLs.

Reimplemented from Log_event.

◆ mts_number_dbs()

uint8 Table_map_log_event::mts_number_dbs ( )
inlineoverridevirtual

Reimplemented from Log_event.

◆ operator=() [1/2]

Table_map_log_event & Table_map_log_event::operator= ( const Table_map_log_event )
delete

◆ operator=() [2/2]

Table_map_log_event & Table_map_log_event::operator= ( Table_map_log_event &&  )
deletenoexcept

◆ pack_info()

int Table_map_log_event::pack_info ( Protocol protocol)
overridevirtual

Stores a string representation of this event in the Protocol.

This is used by SHOW BINLOG EVENTS.

Return values
0success
nonzeroerror

Reimplemented from Log_event.

◆ save_field_metadata()

int Table_map_log_event::save_field_metadata ( )
virtual

Save the field metadata based on the real_type of the field.

The metadata saved depends on the type of the field. Some fields store a single byte for pack_length() while others store two bytes for field_length (max length).

Return values
0Ok.

◆ write_data_body()

bool Table_map_log_event::write_data_body ( Basic_ostream ostream)
overridevirtual

Reimplemented from Log_event.

◆ write_data_header()

bool Table_map_log_event::write_data_header ( Basic_ostream ostream)
overridevirtual

Reimplemented from Log_event.

Member Data Documentation

◆ m_column_view

ColumnViewPtr Table_map_log_event::m_column_view {nullptr}
private

Wrapper around TABLE *m_table that abstracts the table field set iteration logic, since it is not mandatory that all table fields are to be replicated.

For details,

See also
ReplicatedColumnsView class documentation.

A smart pointer is used here as the developer might want to instantiate the view using different classes in runtime depending on the given context. As of now the column view is only used on outbound scenarios

◆ m_metadata_buf

StringBuffer<1024> Table_map_log_event::m_metadata_buf
private

◆ m_table

TABLE* Table_map_log_event::m_table
private

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