MySQL 9.1.0
Source Code Documentation
|
This is the abstract base class for binary log events. More...
#include <log_event.h>
Public Types | |
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... | |
enum | enum_mts_event_exec_mode { EVENT_EXEC_PARALLEL , EVENT_EXEC_ASYNC , EVENT_EXEC_SYNC , EVENT_EXEC_CAN_NOT } |
Public Member Functions | |
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... | |
virtual int | pack_info (Protocol *protocol) |
Stores a string representation of this event in the Protocol. More... | |
virtual const char * | get_db () |
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 bool | write_data_header (Basic_ostream *) |
virtual bool | write_data_body (Basic_ostream *) |
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... | |
virtual bool | is_rbr_logging_format () const |
Return true if the event has to be logged using RBR 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 void | claim_memory_ownership (bool claim) |
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed. More... | |
virtual | ~Log_event () |
void | register_temp_buf (char *buf, bool free_in_destructor=true) |
void | free_temp_buf () |
virtual size_t | get_data_size () |
const char * | get_type_str () const |
Returns the human readable name of this event's type. More... | |
bool | is_mts_sequential_exec () const |
Is called from get_mts_execution_mode() to. More... | |
virtual uint8 | get_mts_dbs (Mts_db_names *arg, Rpl_filter *rpl_filter) |
The method fills in pointers to event's database name c-strings to a supplied array. More... | |
bool | contains_partition_info (bool) |
virtual uint8 | mts_number_dbs () |
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 (Relay_log_info const *rli) |
Primitive to apply an event to the database. More... | |
virtual int | do_apply_event_worker (Slave_worker *w) |
Static Public Member Functions | |
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... | |
static bool | is_mts_sequential_exec (mysql::binlog::event::Log_event_type type_code) |
static enum enum_mts_event_exec_mode | get_mts_execution_mode (bool mts_in_group, mysql::binlog::event::Log_event_type type_code, uint32 server_id, uint32 log_pos) |
Public Attributes | |
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_header * | common_header |
The Log_event_header class contains the variable present in the common header. More... | |
mysql::binlog::event::Log_event_footer * | common_footer |
The Log_event_footer class contains the variable present in the common footer. More... | |
Relay_log_info * | worker |
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... | |
THD * | thd |
db_worker_hash_entry * | mts_assigned_partitions [MAX_DBS_IN_EVENT_MTS] |
Partition info associate with event to deliver to MTS event applier. More... | |
Protected Types | |
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 | |
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... | |
virtual int | do_update_pos (Relay_log_info *rli) |
Advance relay log coordinates. More... | |
virtual enum_skip_reason | do_shall_skip (Relay_log_info *rli) |
Decide if this event shall be skipped or not and the reason for skipping it. More... | |
Private Member Functions | |
enum enum_mts_event_exec_mode | get_mts_execution_mode (bool mts_in_group) |
MTS Coordinator finds out a way how to execute the current event. More... | |
Slave_worker * | get_slave_worker (Relay_log_info *rli) |
The method maps the event to a Worker and return a pointer to it. More... | |
virtual void | set_mts_isolate_group () |
This is the abstract base class for binary log events.
The format of the event is described here.
|
protected |
|
protected |
Enumeration of what kinds of skipping (and non-skipping) that can occur when the slave executes an event.
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.
For example in the server when we are shutting down or flushing logs after receiving a SIGHUP (then we must write a Rotate to the binlog but we have no THD, so we need this minimal constructor).
Log_event::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 | ||
) |
Log_event::Log_event | ( | mysql::binlog::event::Log_event_header * | header, |
mysql::binlog::event::Log_event_footer * | footer | ||
) |
|
inlinevirtual |
int Log_event::apply_event | ( | Relay_log_info * | rli | ) |
Apply the event to the database.
Scheduling event to execute in parallel or execute it directly.
This function represents the public interface for applying an event.
In MTS case the event gets associated with either Coordinator or a Worker. A special case of the association is NULL when the Worker can't be decided yet. In the single threaded sequential mode the event maps to SQL thread rli.
|
inline |
Apply the GTID event in curr_group_data to the database.
rli | Pointer to coordinato's relay log info. |
0 | success |
1 | error |
|
inlinevirtual |
Allow thread to CLAIM or DISCLAIM the ownership of this object depends on the parameter value passed.
claim | True - claim ownership of the memory False - disclaim ownership of the memory |
Reimplemented in Query_log_event, Format_description_log_event, Intvar_log_event, Rand_log_event, Xid_log_event, XA_prepare_log_event, User_var_log_event, Stop_log_event, Rotate_log_event, Append_block_log_event, Delete_file_log_event, Begin_load_query_log_event, Execute_load_query_log_event, Table_map_log_event, Write_rows_log_event, Update_rows_log_event, Delete_rows_log_event, Incident_log_event, Ignorable_log_event, Rows_query_log_event, Transaction_payload_log_event, Gtid_log_event, Previous_gtids_log_event, Transaction_context_log_event, and View_change_log_event.
bool Log_event::contains_partition_info | ( | bool | end_group_sets_max_dbs | ) |
end_group_sets_max_dbs | when true the group terminal event can carry partition info, see a note below. |
|
inlineprotected |
Helper function to ignore an event w.r.t.
the slave skip counter.
This function can be used inside do_shall_skip() for functions that cannot end a group. If the slave skip counter is 1 when seeing such an event, the event shall be ignored, the counter left intact, and processing continue with the next event.
A typical usage is:
|
inlinevirtual |
Primitive to apply an event to the database.
This is where the change to the database is made.
rli | Pointer to relay log info structure |
0 | Event applied successfully |
errno | Error code if event application failed |
Reimplemented in Previous_gtids_log_event, Transaction_context_log_event, Query_log_event, Format_description_log_event, Intvar_log_event, Rand_log_event, Xid_apply_log_event, User_var_log_event, Append_block_log_event, Delete_file_log_event, Execute_load_query_log_event, Table_map_log_event, Rows_log_event, Incident_log_event, Rows_query_log_event, Transaction_payload_log_event, Gtid_log_event, and View_change_log_event.
|
inlinevirtual |
Reimplemented in Xid_apply_log_event.
|
protectedvirtual |
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:
rli->replicate_same_server_id
is true, orrli->slave_skip_counter
is greater than zero.Log_event::EVENT_SKIP_NOT | The event shall not be skipped and should be applied. |
Log_event::EVENT_SKIP_IGNORE | The 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_COUNT | The event shall be skipped because the slave skip counter was non-zero. The caller shall decrease the counter by one. |
Reimplemented in Stop_log_event, Previous_gtids_log_event, Query_log_event, Format_description_log_event, Intvar_log_event, Rand_log_event, Xid_apply_log_event, User_var_log_event, Rotate_log_event, Begin_load_query_log_event, Table_map_log_event, Rows_log_event, Transaction_payload_log_event, and Gtid_log_event.
|
protectedvirtual |
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:
rli | Pointer to relay log info structure |
0 | Coordinates changed successfully |
errno | Error 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 in Query_log_event, Format_description_log_event, Intvar_log_event, Rand_log_event, User_var_log_event, Stop_log_event, Rotate_log_event, Table_map_log_event, Rows_log_event, Gtid_log_event, Previous_gtids_log_event, Transaction_context_log_event, and View_change_log_event.
|
inlinevirtual |
Reimplemented in Query_log_event, Xid_apply_log_event, Incident_log_event, and Transaction_payload_log_event.
|
inline |
|
inlinevirtual |
Reimplemented in Format_description_log_event, Intvar_log_event, Rand_log_event, Xid_log_event, XA_prepare_log_event, Rotate_log_event, Append_block_log_event, Delete_file_log_event, Table_map_log_event, Rows_log_event, Incident_log_event, Ignorable_log_event, Rows_query_log_event, Transaction_payload_log_event, Gtid_log_event, Previous_gtids_log_event, Transaction_context_log_event, and View_change_log_event.
|
virtual |
Reimplemented in Query_log_event, Append_block_log_event, Delete_file_log_event, Table_map_log_event, and Rows_log_event.
|
inlinevirtual |
The method fills in pointers to event's database name c-strings to a supplied array.
In other than Query-log-event case the returned array contains just one item.
[out] | arg | pointer to a struct containing char* array pointers to be filled in and the number of filled instances. |
rpl_filter | pointer to a replication filter. |
Reimplemented in Query_log_event, Table_map_log_event, and Transaction_payload_log_event.
|
inlineprivate |
MTS Coordinator finds out a way how to execute the current event.
Besides the parallelizable case, some events have to be applied by Coordinator concurrently with Workers and some to require synchronization with Workers (see
wait_for_workers_to_finish) before to apply them.
mts_in_group | the being group parsing status, true means inside the group |
EVENT_EXEC_PARALLEL | if event is executed by a Worker |
EVENT_EXEC_ASYNC | if event is executed by Coordinator |
EVENT_EXEC_SYNC | if event is executed by Coordinator with synchronization against the Workers |
|
inlinestatic |
|
private |
The method maps the event to a Worker and return a pointer to it.
Sending the event to the Worker is done by the caller.
Irrespective of the type of Group marking (DB partitioned or BGC) the following holds true:
When parallelization mode is BGC-based the partitioning info in the event is simply ignored. Thereby association with a Worker does not require Assigned Partition Hash of the partitioned method. This method is not interested in all the taxonomy of the event group property, what we care about is the boundaries of the group.
As a part of the group, an event belongs to one of the following types:
B - beginning of a group of events (BEGIN query_log_event) g - mini-group representative event containing the partition info (any Table_map, a Query_log_event) p - a mini-group internal event that *p*receding its g-parent (int_, rand_, user_ var:s) r - a mini-group internal "regular" event that follows its g-parent (Delete, Update, Write -rows) T - terminator of the group (XID, COMMIT, ROLLBACK, auto-commit query)
Only the first g-event computes the assigned Worker which once is determined remains to be for the rest of the group. That is the g-event solely carries partitioning info. For B-event the assigned Worker is NULL to indicate Coordinator has not yet decided. The same applies to p-event.
Notice, these is a special group consisting of optionally multiple p-events terminating with a g-event. Such case is caused by old master binlog and a few corner-cases of the current master version (todo: to fix).
In case of the event accesses more than OVER_MAX_DBS the method has to ensure sure previously assigned groups to all other workers are done.
map_db_to_worker
. There's few memory allocations commented where to be freed.time_t Log_event::get_time | ( | ) |
Prints a "session_var=value" string.
Used by mysqlbinlog to print some SET commands just before it prints a query.
|
inlinevirtual |
Reimplemented in XA_prepare_log_event, and Stop_log_event.
const char * Log_event::get_type_str | ( | ) | const |
Returns the human readable name of this event's type.
|
static |
Returns the human readable name of the given event type.
|
static |
Get the name of an event type, or "Unknown" if out of range.
type | The type as an int |
name | of an event type, if it is one |
Unknown | if the value is out of range |
|
static |
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.
|
inline |
|
inline |
|
inline |
|
inline |
Is called from get_mts_execution_mode() to.
todo: to mts-support Old master Load-data related events
|
inlinestatic |
|
inline |
|
inlinevirtual |
Return true if the event has to be logged using RBR for DMLs.
Reimplemented in Table_map_log_event, and Rows_log_event.
|
inline |
|
inlinevirtual |
Return true if the event has to be logged using SBR for DMLs.
Reimplemented in Query_log_event, Intvar_log_event, Rand_log_event, User_var_log_event, Append_block_log_event, Delete_file_log_event, and Execute_load_query_log_event.
|
inline |
|
inline |
|
inline |
bool Log_event::is_valid | ( | void | ) |
|
inlinevirtual |
Reimplemented in Query_log_event, Table_map_log_event, and Transaction_payload_log_event.
|
protected |
A decider of whether to trigger checksum computation or not.
To be invoked in Log_event::write() stack. The decision is positive
S,M) if it's been marked for checksumming with checksum_alg
M) otherwise, if @global.binlog_checksum is not NONE and the event is directly written to the binlog file. The to-be-cached event decides at write_cache()
time.
Otherwise the decision is negative.
Only called by SHOW BINLOG EVENTS.
|
inlinestatic |
|
inlinestatic |
void * Log_event::operator new | ( | size_t | size | ) |
|
inlinestatic |
|
virtual |
Stores a string representation of this event in the Protocol.
This is used by SHOW BINLOG EVENTS.
0 | success |
nonzero | error |
Reimplemented in Incident_log_event, Ignorable_log_event, Rows_query_log_event, Gtid_log_event, Previous_gtids_log_event, Query_log_event, Format_description_log_event, Intvar_log_event, Rand_log_event, Xid_log_event, XA_prepare_log_event, User_var_log_event, Rotate_log_event, Append_block_log_event, Delete_file_log_event, Execute_load_query_log_event, Table_map_log_event, Rows_log_event, Transaction_payload_log_event, Transaction_context_log_event, and View_change_log_event.
|
inline |
|
inline |
|
inlineprivatevirtual |
|
inline |
|
inline |
Decide if the event shall be skipped, and the reason for skipping it.
|
inlinevirtual |
Events of a certain type can start or end a group of events treated transactionally wrt binlog.
Public access is required by implementation of recovery + skip.
Reimplemented in Query_log_event.
|
inline |
Update the relay log position.
This function represents the public interface for "stepping over" the event and will update the relay log information.
bool Log_event::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.
ostream | The output stream to write to. |
buf | The buffer to write. |
data_length | The number of bytes to write. |
false | Success. |
true | Error. |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in Table_map_log_event, Rows_log_event, Incident_log_event, Gtid_log_event, Transaction_context_log_event, and View_change_log_event.
|
protected |
|
protected |
Writes the common-header of this event to the given output stream and updates the checksum.
ostream | The event will be written to this output stream. |
data_length | The length of the post-header section plus the length of the data section; i.e., the length of the event minus the common-header and the checksum. |
Writes the common header of this event to the given memory buffer.
This does not update the checksum.
+------—+------—+------—+---------—+--------—+----—+ |timestamp|type code|server_id|event_length|end_log_pos|flags | |4 bytes |1 byte |4 bytes |4 bytes |4 bytes |2 bytes| +------—+------—+------—+---------—+--------—+----—+
buf | Memory buffer to write to. This must be at least LOG_EVENT_HEADER_LEN bytes long. |
This assertion guarantees that these debug flags are not used at the same time (they would cancel each other).
mysql::binlog::event::Log_event_footer* Log_event::common_footer |
The Log_event_footer class contains the variable present in the common footer.
Currently, footer contains only the checksum_alg.
mysql::binlog::event::Log_event_header* Log_event::common_header |
The Log_event_header class contains the variable present in the common header.
ha_checksum Log_event::crc |
Placeholder for event checksum while writing to binlog.
enum_event_cache_type Log_event::event_cache_type |
Defines the type of the cache, if any, where the event will be stored before being flushed to disk.
enum_event_logging_type Log_event::event_logging_type |
Defines when information, i.e.
event or cache, will be flushed to disk.
ulong Log_event::exec_time |
ulonglong Log_event::future_event_relay_log_pos |
A copy of the main rli value stored into event to pass to MTS worker rli.
bool Log_event::m_free_temp_buf_in_destructor |
db_worker_hash_entry* Log_event::mts_assigned_partitions[MAX_DBS_IN_EVENT_MTS] |
Partition info associate with event to deliver to MTS event applier.
ulong Log_event::mts_group_idx |
Index in rli->gaq
array to indicate a group that this event is purging.
The index is set by Coordinator to a group terminator event is checked by Worker at the event execution. The indexed data represent the Worker progress status.
ulong Log_event::rbr_exec_mode |
A storage to cache the global system variable's value.
Handling of a separate event will be governed its member.
uint32 Log_event::server_id |
char* Log_event::temp_buf |
THD* Log_event::thd |
Relay_log_info* Log_event::worker |
MTS: associating the event with either an assigned Worker or Coordinator.
Additionally the member serves to tag deferred (IRU) events to avoid the event regular time destruction.