![]() |
MySQL 9.2.0
Source Code Documentation
|
A Query event is written to the binary log whenever the database is modified on the master, unless row based logging is used. More...
#include <log_event.h>
Public Member Functions | |
Query_log_event (Query_log_event &&) noexcept=delete | |
Query_log_event & | operator= (Query_log_event &&) noexcept=delete |
Query_log_event (const Query_log_event &)=delete | |
Query_log_event & | operator= (const Query_log_event &)=delete |
void | set_skip_temp_tables_handling_by_worker () |
bool | is_skip_temp_tables_handling_by_worker () |
Query_log_event (THD *thd_arg, const char *query_arg, size_t query_length, bool using_trans, bool immediate, bool suppress_use, int error, bool ignore_command=false) | |
Creates a Query Log Event. More... | |
const char * | get_db () override |
uint8 | get_mts_dbs (Mts_db_names *arg, Rpl_filter *rpl_filter) override |
void | attach_temp_tables_worker (THD *, const Relay_log_info *) |
Associating slave Worker thread to a subset of temporary tables. More... | |
void | detach_temp_tables_worker (THD *, const Relay_log_info *) |
Dissociating slave Worker thread from its thd->temporary_tables to possibly update the involved entries of db-to-worker hash with new values of temporary_tables. More... | |
uchar | mts_number_dbs () override |
int | pack_info (Protocol *protocol) override |
This (which is used only for SHOW BINLOG EVENTS) could be updated to print SET @session_var=. More... | |
Query_log_event () | |
The simplest constructor that could possibly work. More... | |
Query_log_event (const char *buf, const mysql::binlog::event::Format_description_event *description_event, mysql::binlog::event::Log_event_type event_type) | |
This is used by the SQL slave thread to prepare the event before execution. More... | |
~Query_log_event () override | |
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... | |
bool | write (Basic_ostream *ostream) override |
Query_log_event::write(). More... | |
virtual bool | write_post_header_for_derived (Basic_ostream *) |
virtual ulong | get_post_header_size_for_derived () |
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... | |
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... | |
int | do_apply_event (Relay_log_info const *rli, const char *query_arg, size_t q_len_arg) |
bool | is_trans_keyword () const |
bool | is_sbr_logging_format () const override |
When a query log event contains a non-transaction control statement, we assume that it is changing database content (DML) and was logged using binlog_format=statement. More... | |
bool | starts_group () const override |
Notice, DDL queries are logged without BEGIN/COMMIT parentheses and identification of such single-query group occurs within logics of get_slave_worker() . More... | |
bool | ends_group () const override |
bool | is_query_prefix_match (const char *pattern, uint p_len) |
![]() | |
Query_event (const char *query_arg, const char *catalog_arg, const char *db_arg, uint32_t query_length, unsigned long thread_id_arg, unsigned long long sql_mode_arg, unsigned long auto_increment_increment_arg, unsigned long auto_increment_offset_arg, unsigned int number, unsigned long long table_map_for_update_arg, int errcode) | |
The constructor will be used while creating a Query_event, to be written to the binary log. More... | |
Query_event (const char *buf, const Format_description_event *fde, Log_event_type event_type) | |
The constructor receives a buffer and instantiates a Query_event filled in with the data from the buffer. More... | |
Query_event (Log_event_type type_arg=QUERY_EVENT) | |
The simplest constructor that could possibly work. More... | |
~Query_event () override=default | |
![]() | |
virtual | ~Binary_log_event ()=0 |
Binary_log_event (const Binary_log_event &)=default | |
Binary_log_event (Binary_log_event &&)=default | |
Binary_log_event & | operator= (const Binary_log_event &)=default |
Binary_log_event & | operator= (Binary_log_event &&)=default |
enum Log_event_type | get_event_type () const |
Helper method. More... | |
const Log_event_header * | header () const |
Return a const pointer to the header of the log event. More... | |
Log_event_header * | header () |
Return a non-const pointer to the header of the log event. More... | |
const Log_event_footer * | footer () const |
Return a const pointer to the footer of the log event. More... | |
Log_event_footer * | footer () |
Return a non-const pointer to the footer of the log event. More... | |
Event_reader & | reader () |
Returns a reference to the event Event_reader object. More... | |
![]() | |
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... | |
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_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 | ~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... | |
bool | contains_partition_info (bool) |
bool | is_mts_group_isolated () |
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) |
Static Public Member Functions | |
static size_t | get_query (const char *buf, size_t length, const mysql::binlog::event::Format_description_event *fd_event, const char **query_arg) |
Return the query string pointer (and its size) from a Query log event using only the event buffer (we don't instantiate a Query_log_event object for this). More... | |
![]() | |
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 | |
my_thread_id | slave_proxy_id |
bool | rollback_injected_by_coord = false |
True if this is a ROLLBACK event injected by the mts coordinator to finish a group corresponding to a partial transaction in the relay log. More... | |
bool | has_ddl_committed |
The flag indicates whether the DDL query has been (already) committed or not. More... | |
bool | m_skip_temp_tables_handling_by_worker {false} |
Instructs the applier to skip temporary tables handling. More... | |
bool | need_sql_require_primary_key {false} |
Whether or not the statement represented by this event requires Q_SQL_REQUIRE_PRIMARY_KEY to be logged along aside. More... | |
bool | needs_default_table_encryption {false} |
Whether or not the statement represented by this event requires Q_DEFAULT_TABLE_ENCRYPTION to be logged along aside. More... | |
![]() | |
const char * | query |
const char * | db |
const char * | catalog |
const char * | time_zone_str |
uint32_t | thread_id |
uint32_t | query_exec_time |
size_t | db_len |
uint16_t | error_code |
uint16_t | status_vars_len |
size_t | q_len |
bool | flags2_inited |
bool | sql_mode_inited |
bool | charset_inited |
uint32_t | flags2 |
uint64_t | sql_mode |
uint16_t | auto_increment_increment |
uint16_t | auto_increment_offset |
char | charset [6] |
size_t | time_zone_len |
size_t | catalog_len |
uint16_t | lc_time_names_number |
uint16_t | charset_database_number |
uint64_t | table_map_for_update |
enum mysql::binlog::event::Query_event::enum_ternary | explicit_defaults_ts |
unsigned char | mts_accessed_dbs |
char | mts_accessed_db_names [MAX_DBS_IN_EVENT_MTS][NAME_LEN] |
uint64_t | ddl_xid |
uint16_t | default_collation_for_utf8mb4_number |
uint8_t | sql_require_primary_key |
uint8_t | default_table_encryption |
![]() | |
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 Attributes | |
mysql::binlog::event::Log_event_header::Byte * | data_buf |
![]() | |
const char * | user |
size_t | user_len |
const char * | host |
size_t | host_len |
unsigned long | data_len |
A Query event is written to the binary log whenever the database is modified on the master, unless row based logging is used.
Query_log_event is created for logging, and is called after an update to the database is done. It is used when the server acts as the master.
Virtual inheritance is required here to handle the diamond problem in the class Execute_load_query_log_event
. The diamond structure is explained in Excecute_load_query_log_event
|
deletenoexcept |
|
delete |
Query_log_event::Query_log_event | ( | THD * | thd_arg, |
const char * | query_arg, | ||
size_t | query_length, | ||
bool | using_trans, | ||
bool | immediate, | ||
bool | suppress_use, | ||
int | errcode, | ||
bool | ignore_cmd_internals = false |
||
) |
Creates a Query Log Event.
thd_arg | Thread handle |
query_arg | Array of char representing the query |
query_length | Size of the 'query_arg' array |
using_trans | Indicates that there are transactional changes. |
immediate | After being written to the binary log, the event must be flushed immediately. This indirectly implies the stmt-cache. |
suppress_use | Suppress the generation of 'USE' statements |
errcode | The error code of the query |
ignore_cmd_internals | Ignore user's statement, i.e. lex information, while deciding which cache must be used. |
Query_log_event::Query_log_event | ( | ) |
The simplest constructor that could possibly work.
This is used for creating static objects that have a special meaning and are invisible to the log.
Query_log_event::Query_log_event | ( | const char * | buf, |
const mysql::binlog::event::Format_description_event * | description_event, | ||
mysql::binlog::event::Log_event_type | event_type | ||
) |
This is used by the SQL slave thread to prepare the event before execution.
|
inlineoverride |
void Query_log_event::attach_temp_tables_worker | ( | THD * | thd_arg, |
const Relay_log_info * | rli | ||
) |
Associating slave Worker thread to a subset of temporary tables.
thd_arg | THD instance pointer |
rli | Relay_log_info of the worker |
|
overridevirtual |
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 from Log_event.
Reimplemented in Execute_load_query_log_event.
void Query_log_event::detach_temp_tables_worker | ( | THD * | thd_arg, |
const Relay_log_info * | rli | ||
) |
Dissociating slave Worker thread from its thd->temporary_tables to possibly update the involved entries of db-to-worker hash with new values of temporary_tables.
thd_arg | THD instance pointer |
rli | relay log info of the worker thread |
|
overridevirtual |
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 from Log_event.
Reimplemented in Execute_load_query_log_event.
int Query_log_event::do_apply_event | ( | Relay_log_info const * | rli, |
const char * | query_arg, | ||
size_t | q_len_arg | ||
) |
We may also want an option to tell the slave to ignore "affected" mismatch. This mismatch could be implemented with a new ER_ code, and to ignore it you would use –replica-skip-errors...
The following failure injection works in cooperation with tests setting @global.debug= 'd,stop_replica_middle_group'. The sql thread receives the killed status and will proceed to shutdown trying to finish incomplete events group.
|
overridevirtual |
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 from Log_event.
|
overridevirtual |
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 from Log_event.
|
inlineoverridevirtual |
Reimplemented from Log_event.
|
inlineoverridevirtual |
Reimplemented from Log_event.
|
inlineoverridevirtual |
[out] | arg | pointer to a struct containing char* array pointers be filled in and the number of filled instances. In case the number exceeds MAX_DBS_IN_EVENT_MTS, the overfill is indicated with assigning the number to OVER_MAX_DBS_IN_EVENT_MTS. |
rpl_filter | pointer to a replication filter. |
Reimplemented from Log_event.
|
inlinevirtual |
Reimplemented in Execute_load_query_log_event.
|
static |
Return the query string pointer (and its size) from a Query log event using only the event buffer (we don't instantiate a Query_log_event object for this).
buf | Pointer to the event buffer. | |
length | The size of the event buffer. | |
fd_event | The description event of the master which logged the event. | |
[out] | query_arg | The pointer to receive the query pointer. |
|
inline |
|
inlineoverridevirtual |
When a query log event contains a non-transaction control statement, we assume that it is changing database content (DML) and was logged using binlog_format=statement.
Reimplemented from Log_event.
Reimplemented in Execute_load_query_log_event.
|
inline |
|
inline |
|
delete |
|
deletenoexcept |
|
overridevirtual |
This (which is used only for SHOW BINLOG EVENTS) could be updated to print SET @session_var=.
But this is not urgent, as SHOW BINLOG EVENTS is only an information, it does not produce suitable queries to replay (for example it does not print LOAD DATA INFILE).
Reimplemented from Log_event.
Reimplemented in Execute_load_query_log_event.
|
inline |
|
inlineoverridevirtual |
Notice, DDL queries are logged without BEGIN/COMMIT parentheses and identification of such single-query group occurs within logics of get_slave_worker()
.
Reimplemented from Log_event.
|
overridevirtual |
Query_log_event::write().
Reimplemented from Log_event.
|
inlinevirtual |
Reimplemented in Execute_load_query_log_event.
|
protected |
bool Query_log_event::has_ddl_committed |
The flag indicates whether the DDL query has been (already) committed or not.
It's initialized as OFF at the event instantiation, flips ON when the DDL transaction has been committed with all its possible extra statement due to replication or GTID.
The flag status is also checked in few places to catch uncommitted transactions which can normally happen due to filtering out. In such a case the commit is deferred to Log_event::do_update_pos()
.
bool Query_log_event::m_skip_temp_tables_handling_by_worker {false} |
Instructs the applier to skip temporary tables handling.
bool Query_log_event::need_sql_require_primary_key {false} |
Whether or not the statement represented by this event requires Q_SQL_REQUIRE_PRIMARY_KEY
to be logged along aside.
bool Query_log_event::needs_default_table_encryption {false} |
Whether or not the statement represented by this event requires Q_DEFAULT_TABLE_ENCRYPTION
to be logged along aside.
bool Query_log_event::rollback_injected_by_coord = false |
True if this is a ROLLBACK event injected by the mts coordinator to finish a group corresponding to a partial transaction in the relay log.
False otherwise and by default, as it must be explicitly set to true by the coordinator.
my_thread_id Query_log_event::slave_proxy_id |