diff options
author | Andrei <andrei.elkin@mariadb.com> | 2021-12-09 16:51:50 +0200 |
---|---|---|
committer | Andrei <andrei.elkin@mariadb.com> | 2021-12-15 22:44:23 +0200 |
commit | 5b74775eab2087682bd1bc5e420e7401e12f485b (patch) | |
tree | 9e563883ae6cd1c9125fedd374328e662696ec16 | |
parent | 1dc04f9c7ef939a2b56ee869769ac3a5f1770c5c (diff) | |
download | mariadb-git-5b74775eab2087682bd1bc5e420e7401e12f485b.tar.gz |
MDEV-11675. A cleanup commit renames and relocates of few class members
Also `--help` doc lines for @@binlog_alter_two_phase have been improved.
-rw-r--r-- | sql/log.cc | 14 | ||||
-rw-r--r-- | sql/log_event.cc | 13 | ||||
-rw-r--r-- | sql/log_event.h | 33 | ||||
-rw-r--r-- | sql/log_event_client.cc | 13 | ||||
-rw-r--r-- | sql/log_event_server.cc | 47 | ||||
-rw-r--r-- | sql/rpl_gtid.cc | 4 | ||||
-rw-r--r-- | sql/rpl_parallel.cc | 10 | ||||
-rw-r--r-- | sql/slave.cc | 4 | ||||
-rw-r--r-- | sql/sql_table.cc | 8 | ||||
-rw-r--r-- | sql/sys_vars.cc | 7 |
10 files changed, 76 insertions, 77 deletions
diff --git a/sql/log.cc b/sql/log.cc index 628d1c8a1d9..f048b1854b0 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -620,7 +620,7 @@ bool write_bin_log_start_alter(THD *thd, bool& partial_alter, thd->rgi_slave->start_alter_ev->update_pos(thd->rgi_slave); if (mysql_bin_log.is_open()) { - Write_log_with_flags wlwf (thd, Log_event::FL_START_ALTER_E1); + Write_log_with_flags wlwf (thd, Gtid_log_event::FL_START_ALTER_E1); if (write_bin_log(thd, true, thd->query(), thd->query_length())) { DBUG_ASSERT(thd->is_error()); @@ -642,12 +642,12 @@ bool write_bin_log_start_alter(THD *thd, bool& partial_alter, { /* slave applier can handle here only regular ALTER */ DBUG_ASSERT(!rgi || !(rgi->gtid_ev_flags_extra & - (Log_event::FL_START_ALTER_E1 | - Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1))); + (Gtid_log_event::FL_START_ALTER_E1 | + Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1))); // After logging binlog state stays flagged with SA flags3 an seq_no - thd->binlog_setup_trx_data()->gtid_flags3|= Log_event::FL_START_ALTER_E1; + thd->set_binlog_flags_for_alter(Gtid_log_event::FL_START_ALTER_E1); if(write_bin_log_with_if_exists(thd, false, true, if_exists, false)) { DBUG_ASSERT(thd->is_error()); @@ -658,7 +658,7 @@ bool write_bin_log_start_alter(THD *thd, bool& partial_alter, else if (rgi && rgi->direct_commit_alter) { DBUG_ASSERT(rgi->gtid_ev_flags_extra & - Log_event::FL_COMMIT_ALTER_E1); + Gtid_log_event::FL_COMMIT_ALTER_E1); partial_alter= true; } @@ -6374,7 +6374,7 @@ MYSQL_BIN_LOG::write_gtid_event(THD *thd, bool standalone, DBUG_RETURN(true); thd->set_last_commit_gtid(gtid); - if (thd->get_binlog_flags_for_alter() & Log_event::FL_START_ALTER_E1) + if (thd->get_binlog_flags_for_alter() & Gtid_log_event::FL_START_ALTER_E1) thd->set_binlog_start_alter_seq_no(gtid.seq_no); Gtid_log_event gtid_event(thd, seq_no, domain_id, standalone, diff --git a/sql/log_event.cc b/sql/log_event.cc index 68fa1f7bb20..d3d44e8dc30 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1424,7 +1424,7 @@ Query_log_event::Query_log_event(const uchar *buf, uint event_len, flags2_inited(0), sql_mode_inited(0), charset_inited(0), flags2(0), auto_increment_increment(1), auto_increment_offset(1), time_zone_len(0), lc_time_names_number(0), charset_database_number(0), - table_map_for_update(0), xid(0), master_data_written(0), gtid_extra_flags(0), + table_map_for_update(0), xid(0), master_data_written(0), gtid_flags_extra(0), sa_seq_no(0) { ulong data_len; @@ -1618,11 +1618,10 @@ Query_log_event::Query_log_event(const uchar *buf, uint event_len, } case Q_GTID_FLAGS3: { - CHECK_SPACE(pos, end, 2); - gtid_extra_flags = uint2korr(pos); - pos+= 2; - if (gtid_extra_flags & (Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + CHECK_SPACE(pos, end, 1); + gtid_flags_extra= *pos++; + if (gtid_flags_extra & (Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1)) { CHECK_SPACE(pos, end, 8); sa_seq_no = uint8korr(pos); @@ -2625,7 +2624,7 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, extra engines flags presence is identifed by non-zero byte value at this point */ - if (flags_extra & FL_EXTRA_MULTI_ENGINE) + if (flags_extra & FL_EXTRA_MULTI_ENGINE_E1) { DBUG_ASSERT(static_cast<uint>(buf - buf_0) < event_len); diff --git a/sql/log_event.h b/sql/log_event.h index 271cdc600e7..741e360efc5 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -1197,15 +1197,6 @@ public: }; /* - _E1 suffix below stands for Extra to infer the extra flags, - their "1st" generation (more *generations* can come when necessary). - Used in Gtid_log_event as well as Query_log_event - */ - static const uint16 FL_START_ALTER_E1= 2; - static const uint16 FL_COMMIT_ALTER_E1= 4; - static const uint16 FL_ROLLBACK_ALTER_E1= 8; - - /* The following type definition is to be used whenever data is placed and manipulated in a common buffer. Use this typedef for buffers that contain data containing binary and character data. @@ -2163,8 +2154,8 @@ public: A copy of Gtid event's extra flags that is relevant for two-phase logged ALTER. */ - uint16 gtid_extra_flags; - uint64 sa_seq_no; /* data part for CA/RA flags */ + uchar gtid_flags_extra; + decltype(rpl_gtid::seq_no) sa_seq_no; /* data part for CA/RA flags */ #ifdef MYSQL_SERVER @@ -3636,7 +3627,12 @@ public: event_mysql_xid_t xid; #endif uchar flags2; - uint flags_extra; // more flags area placed after the regular flags2's one + /* + More flags area placed after the regular flags2's area. The type + is declared to be in agreement with Query_log_event's member that + may copy the flags_extra value. + */ + decltype(Query_log_event::gtid_flags_extra) flags_extra; /* Number of engine participants in transaction minus 1. When zero the event does not contain that information. @@ -3674,14 +3670,19 @@ public: /* FL_"COMMITTED or ROLLED-BACK"_XA is set for XA transaction. */ static const uchar FL_COMPLETED_XA= 128; - /* Flags_extra. */ - /* - FL_EXTRA_MULTI_ENGINE is set for event group comprising a transaction + flags_extra 's bit values. + _E1 suffix below stands for Extra to infer the extra flags, + their "1st" generation (more *generations* can come when necessary). + + FL_EXTRA_MULTI_ENGINE_E1 is set for event group comprising a transaction involving multiple storage engines. No flag and extra data are added to the event when the transaction involves only one engine. */ - static const uchar FL_EXTRA_MULTI_ENGINE= 1; + static const uchar FL_EXTRA_MULTI_ENGINE_E1= 1; + static const uchar FL_START_ALTER_E1= 2; + static const uchar FL_COMMIT_ALTER_E1= 4; + static const uchar FL_ROLLBACK_ALTER_E1= 8; #ifdef MYSQL_SERVER Gtid_log_event(THD *thd_arg, uint64 seq_no, uint32 domain_id, bool standalone, diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index e1fa3d84bc0..a62ad9d619b 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -2034,17 +2034,18 @@ bool Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) goto err; if (!is_flashback) { - if (gtid_extra_flags & (Log_event::FL_START_ALTER_E1 | - Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + if (gtid_flags_extra & (Gtid_log_event::FL_START_ALTER_E1 | + Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1)) { bool do_print_encoded= print_event_info->base64_output_mode != BASE64_OUTPUT_NEVER && print_event_info->base64_output_mode != BASE64_OUTPUT_DECODE_ROWS && !print_event_info->short_form; - bool comment_mode= gtid_extra_flags & (Log_event::FL_START_ALTER_E1 | - Log_event :: FL_ROLLBACK_ALTER_E1) - && do_print_encoded; + bool comment_mode= do_print_encoded && + gtid_flags_extra & (Gtid_log_event::FL_START_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1); + if(comment_mode) my_b_printf(&cache, "/*!100600 "); if (do_print_encoded) diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 04f43265647..d346ef3628f 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -1304,14 +1304,13 @@ bool Query_log_event::write() start+= 8; } - if (gtid_extra_flags) + if (gtid_flags_extra) { *start++= Q_GTID_FLAGS3; - int2store(start, gtid_extra_flags); - start+= 2; - if (gtid_extra_flags & - (Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + buf[start++]= gtid_flags_extra; + if (gtid_flags_extra & + (Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1)) { int8store(start, sa_seq_no); start+= 8; @@ -1432,7 +1431,7 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, charset_database_number(0), table_map_for_update((ulonglong)thd_arg->table_map_for_update), master_data_written(0), - gtid_extra_flags(thd_arg->get_binlog_flags_for_alter()), + gtid_flags_extra(thd_arg->get_binlog_flags_for_alter()), sa_seq_no(0) { /* status_vars_len is set just before writing the event */ @@ -1569,13 +1568,13 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, use_cache= trx_cache= TRUE; break; default: - use_cache= (gtid_extra_flags) ? false : sqlcom_can_generate_row_events(thd); + use_cache= (gtid_flags_extra) ? false : sqlcom_can_generate_row_events(thd); break; } } - if (gtid_extra_flags & (Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + if (gtid_flags_extra & (Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1)) sa_seq_no= thd_arg->get_binlog_start_alter_seq_no(); if (!use_cache || direct) @@ -1686,8 +1685,8 @@ int Query_log_event::handle_split_alter_query_log_event(rpl_group_info *rgi, { int rc= 0; - rgi->gtid_ev_flags_extra= gtid_extra_flags; - if (gtid_extra_flags & Log_event::FL_START_ALTER_E1) + rgi->gtid_ev_flags_extra= gtid_flags_extra; + if (gtid_flags_extra & Gtid_log_event::FL_START_ALTER_E1) { //No Slave, Normal Slave, Start Alter under Worker 1 will simple binlog and exit if(!rgi->rpt || rgi->reserved_start_alter_thread) @@ -1698,7 +1697,7 @@ int Query_log_event::handle_split_alter_query_log_event(rpl_group_info *rgi, Alter will take care of actual work */ rgi->reserved_start_alter_thread= false; - Write_log_with_flags wlwf(thd, Log_event::FL_START_ALTER_E1); + Write_log_with_flags wlwf(thd, Gtid_log_event::FL_START_ALTER_E1); if (write_bin_log(thd, false, thd->query(), thd->query_length())) return -1; @@ -1719,7 +1718,7 @@ int Query_log_event::handle_split_alter_query_log_event(rpl_group_info *rgi, return rc; } - bool is_CA= (gtid_extra_flags & Log_event::FL_COMMIT_ALTER_E1) ? true : false; + bool is_CA= (gtid_flags_extra & Gtid_log_event::FL_COMMIT_ALTER_E1) ? true : false; if (is_CA) { DBUG_EXECUTE_IF("rpl_slave_stop_CA_before_binlog", @@ -1814,8 +1813,8 @@ write_binlog: } } { - Write_log_with_flags wlwf(thd, is_CA ? Log_event::FL_COMMIT_ALTER_E1 : - Log_event::FL_ROLLBACK_ALTER_E1); + Write_log_with_flags wlwf(thd, is_CA ? Gtid_log_event::FL_COMMIT_ALTER_E1 : + Gtid_log_event::FL_ROLLBACK_ALTER_E1); if (write_bin_log(thd, false, thd->query(), thd->query_length())) rc= -1; } @@ -1920,7 +1919,7 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, */ if (is_trans_keyword() || rpl_filter->db_ok(thd->db.str)) { - bool is_rb_alter= gtid_extra_flags & Log_event::FL_ROLLBACK_ALTER_E1; + bool is_rb_alter= gtid_flags_extra & Gtid_log_event::FL_ROLLBACK_ALTER_E1; thd->set_time(when, when_sec_part); thd->set_query_and_id((char*)query_arg, q_len_arg, @@ -2102,9 +2101,9 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi, } int sa_result= 0; - if (gtid_extra_flags & (Log_event::FL_START_ALTER_E1 | - Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + if (gtid_flags_extra & (Gtid_log_event::FL_START_ALTER_E1 | + Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1)) sa_result= handle_split_alter_query_log_event(rgi, skip_error_check); if (sa_result == 0) { @@ -3591,13 +3590,12 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, extra_engines= count > 1 ? 0 : UCHAR_MAX; } if (extra_engines > 0) - flags_extra|= FL_EXTRA_MULTI_ENGINE; + flags_extra|= FL_EXTRA_MULTI_ENGINE_E1; } if (thd->get_binlog_flags_for_alter()) { flags_extra |= thd->get_binlog_flags_for_alter(); - if (flags_extra & (Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1)) + if (flags_extra & (FL_COMMIT_ALTER_E1 | FL_ROLLBACK_ALTER_E1)) sa_seq_no= thd->get_binlog_start_alter_seq_no(); flags2|= FL_DDL; } @@ -3672,7 +3670,7 @@ Gtid_log_event::write() buf[write_len]= flags_extra; write_len++; } - if (flags_extra & FL_EXTRA_MULTI_ENGINE) + if (flags_extra & FL_EXTRA_MULTI_ENGINE_E1) { buf[write_len]= extra_engines; write_len++; @@ -3777,7 +3775,6 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi) rgi->gtid_ev_flags2= flags2; rgi->gtid_ev_flags_extra= flags_extra; - //OTODO ?? feels like repeated code. Does choose_worker really need it? When NO - remove rgi->gtid_ev_sa_seq_no= sa_seq_no; thd->reset_for_next_command(); diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index bea7e971ffc..5b54286b1e9 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -628,7 +628,7 @@ rpl_slave_state::record_gtid(THD *thd, const rpl_gtid *gtid, uint64 sub_id, thd->reset_for_next_command(); if (thd->rgi_slave && (thd->rgi_slave->gtid_ev_flags_extra & - Log_event::FL_START_ALTER_E1)) + Gtid_log_event::FL_START_ALTER_E1)) { /* store the open table table list in ptr, so that is close_thread_tables @@ -750,7 +750,7 @@ end: ha_rollback_trans(thd, FALSE); close_thread_tables(thd); if (!thd->rgi_slave || !(thd->rgi_slave->gtid_ev_flags_extra & - Log_event::FL_START_ALTER_E1)) + Gtid_log_event::FL_START_ALTER_E1)) { if (in_transaction) thd->mdl_context.release_statement_locks(); diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 927f26d6b20..0f86404c799 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -2238,7 +2238,7 @@ static bool handle_split_alter(rpl_parallel_entry *e, uint16 flags_extra= gtid_ev->flags_extra; bool thread_allocated= false; //Step 1 - if (flags_extra & Log_event::FL_START_ALTER_E1 || + if (flags_extra & Gtid_log_event::FL_START_ALTER_E1 || //This will arrange finding threads for CA/RA as well //as concurrent DDL e->pending_start_alters) @@ -2268,7 +2268,7 @@ idx_found: e->rpl_thread_idx= *idx; e->choose_thread_internal(*idx, did_enter_cond, rgi, old_stage); thread_allocated= true; - if (flags_extra & Log_event::FL_START_ALTER_E1) + if (flags_extra & Gtid_log_event::FL_START_ALTER_E1) { mysql_mutex_assert_owner(&e->rpl_threads[*idx]->LOCK_rpl_thread); e->rpl_threads[e->rpl_thread_idx]->current_start_alter_id= gtid_ev->seq_no; @@ -2295,8 +2295,8 @@ idx_found: mysql_mutex_unlock(&global_rpl_thread_pool.LOCK_rpl_thread_pool); } } - if(flags_extra & (Log_event::FL_COMMIT_ALTER_E1 | - Log_event::FL_ROLLBACK_ALTER_E1 )) + if(flags_extra & (Gtid_log_event::FL_COMMIT_ALTER_E1 | + Gtid_log_event::FL_ROLLBACK_ALTER_E1 )) { //Free the corrosponding rpt current_start_alter_id for(uint i= 0; i < e->rpl_thread_max; i++) @@ -2612,7 +2612,7 @@ rpl_parallel::wait_for_done(THD *thd, Relay_log_info *rli) And remaning SA will never recieve CA/RA so we have to manualy send it */ if (rpt->thd->rgi_slave && - (rpt->thd->rgi_slave->gtid_ev_flags_extra & Log_event::FL_START_ALTER_E1)) + (rpt->thd->rgi_slave->gtid_ev_flags_extra & Gtid_log_event::FL_START_ALTER_E1)) continue; mysql_mutex_lock(&rpt->LOCK_rpl_thread); while (rpt->current_owner == &e->rpl_threads[j]) diff --git a/sql/slave.cc b/sql/slave.cc index 8783a478c55..9e028ea04ee 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3931,7 +3931,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, if (exec_res == 0) { if (thd->rgi_slave && (thd->rgi_slave->gtid_ev_flags_extra & - Log_event::FL_START_ALTER_E1) && + Gtid_log_event::FL_START_ALTER_E1) && thd->rgi_slave->get_finish_event_group_called()) DBUG_RETURN(exec_res ? 1 : 0); int error= ev->update_pos(rgi); @@ -4059,7 +4059,7 @@ apply_event_and_update_pos_for_parallel(Log_event* ev, THD* thd, { int rc= 0; ulong retries= 0; - bool is_sa= rgi->gtid_ev_flags_extra == Log_event::FL_START_ALTER_E1; + bool is_sa= rgi->gtid_ev_flags_extra == Gtid_log_event::FL_START_ALTER_E1; bool is_sa_temp_err= false; mysql_mutex_assert_not_owner(&rgi->rli->data_lock); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 643000516d8..9490de15108 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1030,7 +1030,7 @@ int write_bin_log_with_if_exists(THD *thd, bool clear_error, if (add_if_exists) thd->variables.option_bits|= OPTION_IF_EXISTS; if (commit_alter) - thd->set_binlog_flags_for_alter(Log_event::FL_COMMIT_ALTER_E1); + thd->set_binlog_flags_for_alter(Gtid_log_event::FL_COMMIT_ALTER_E1); result= write_bin_log(thd, clear_error, thd->query(), thd->query_length(), is_trans); @@ -7340,7 +7340,7 @@ bool write_bin_log_start_alter_rollback(THD *thd, uint64 &start_alter_id, else if (partial_alter) // Write only if SA written { // Send the rollback message - Write_log_with_flags wlwf(thd, Log_event::FL_ROLLBACK_ALTER_E1); + Write_log_with_flags wlwf(thd, Gtid_log_event::FL_ROLLBACK_ALTER_E1); if(write_bin_log_with_if_exists(thd, false, false, if_exists, false)) return true; partial_alter= false; @@ -9577,11 +9577,11 @@ static uint64 get_start_alter_id(THD *thd) { DBUG_ASSERT(!(thd->rgi_slave && (thd->rgi_slave->gtid_ev_flags_extra & - Log_event::FL_START_ALTER_E1)) || + Gtid_log_event::FL_START_ALTER_E1)) || !thd->rgi_slave->direct_commit_alter); return thd->rgi_slave && - (thd->rgi_slave->gtid_ev_flags_extra & Log_event::FL_START_ALTER_E1) ? + (thd->rgi_slave->gtid_ev_flags_extra & Gtid_log_event::FL_START_ALTER_E1) ? thd->variables.gtid_seq_no : 0; } diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index c9da0033b1d..d414d9d50df 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2413,9 +2413,10 @@ static const char *binlog_alter_two_phase_enum[]= {"No","Yes", NullS}; static Sys_var_enum Sys_binlog_alter_two_phase( "binlog_alter_two_phase", - "If set split the alter into 2 statement START ALTER and COMMIT/ROLLBACK" - "ALTER", - SESSION_VAR(binlog_alter_two_phase), CMD_LINE(REQUIRED_ARG), binlog_alter_two_phase_enum, + "When set, split ALTER at binary logging into 2 statements: " + "START ALTER and COMMIT/ROLLBACK ALTER", + SESSION_VAR(binlog_alter_two_phase), CMD_LINE(REQUIRED_ARG), + binlog_alter_two_phase_enum, DEFAULT(0)); static bool |