diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-07-04 18:27:33 +0300 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2023-03-20 11:28:50 +0100 |
commit | 0d694e46ba3fe6e1a0def15ec74c98cc80f298cf (patch) | |
tree | e3509e447a0a3061b37ad6d49701581c8680f7a1 | |
parent | ec61a169189b5e70dfc4ac579dddaf96875c379b (diff) | |
download | mariadb-git-0d694e46ba3fe6e1a0def15ec74c98cc80f298cf.tar.gz |
Simplify rgi->get_table_data call
-rw-r--r-- | sql/rpl_record.cc | 17 | ||||
-rw-r--r-- | sql/rpl_rli.h | 31 |
2 files changed, 30 insertions, 18 deletions
diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 0ffe79287bf..d6e22474de5 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -223,12 +223,10 @@ int unpack_row(rpl_group_info *rgi, TABLE *table, uint const colcnt, // The "current" null bits unsigned int null_bits= *null_ptr++; uint i= 0; - table_def *tabledef= NULL; - TABLE *conv_table= NULL; - const Copy_field *copy_fields; - const Copy_field *copy_fields_end; - bool table_found= rgi && rgi->get_table_data(table, &tabledef, &conv_table, - ©_fields, ©_fields_end); + Rpl_table_data rpl_data{}; + bool table_found= rgi && rgi->get_table_data(table, &rpl_data); + const table_def *tabledef= rpl_data.tabledef; + const TABLE *conv_table= rpl_data.conv_table; DBUG_PRINT("debug", ("Table data: table_found: %d, tabldef: %p, conv_table: %p", table_found, tabledef, conv_table)); DBUG_ASSERT(table_found); @@ -350,7 +348,7 @@ int unpack_row(rpl_group_info *rgi, TABLE *table, uint const colcnt, If copy_fields is set, it means we are doing an online alter table, and will use copy_fields set up in copy_data_between_tables */ - if (conv_field && !copy_fields) + if (conv_field && !rpl_data.is_online_alter()) { Copy_field copy; #ifndef DBUG_OFF @@ -382,9 +380,10 @@ int unpack_row(rpl_group_info *rgi, TABLE *table, uint const colcnt, i++; } - if (copy_fields) + if (rpl_data.is_online_alter()) { - for (const auto *copy=copy_fields; copy != copy_fields_end; copy++) + for (const auto *copy=rpl_data.copy_fields; + copy != rpl_data.copy_fields_end; copy++) { copy->do_copy(copy); } diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index f548b9c1665..1de082daaf0 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -669,6 +669,23 @@ struct start_alter_info mysql_cond_t start_alter_cond; }; +struct Rpl_table_data +{ + const table_def *tabledef; + TABLE *conv_table; + const Copy_field *copy_fields; + const Copy_field *copy_fields_end; + Rpl_table_data& operator =(const RPL_TABLE_LIST &rpl_table_list) + { + tabledef= &rpl_table_list.m_tabledef; + conv_table= rpl_table_list.m_conv_table; + copy_fields= rpl_table_list.m_online_alter_copy_fields; + copy_fields_end= rpl_table_list.m_online_alter_copy_fields_end; + return *this; + } + bool is_online_alter() const { return copy_fields != NULL; } +}; + /* This is data for various state needed to be kept for the processing of one event group (transaction) during replication. @@ -941,24 +958,20 @@ struct rpl_group_info } } - bool get_table_data(TABLE *table_arg, table_def **tabledef_var, - TABLE **conv_table_var, - const Copy_field *copy[], const Copy_field **copy_end) const + bool get_table_data(const TABLE *table_arg, Rpl_table_data *table_data) const { - DBUG_ASSERT(tabledef_var && conv_table_var); + DBUG_ASSERT(table_data); for (TABLE_LIST *ptr= tables_to_lock ; ptr != NULL ; ptr= ptr->next_global) if (ptr->table == table_arg) { auto *rpl_table_list= static_cast<RPL_TABLE_LIST*>(ptr); DBUG_ASSERT(rpl_table_list->m_tabledef_valid); - *tabledef_var= &rpl_table_list->m_tabledef; - *conv_table_var= rpl_table_list->m_conv_table; - *copy= rpl_table_list->m_online_alter_copy_fields; - *copy_end= rpl_table_list->m_online_alter_copy_fields_end; + *table_data= *rpl_table_list; + DBUG_PRINT("debug", ("Fetching table data for table %s.%s:" " tabledef: %p, conv_table: %p", table_arg->s->db.str, table_arg->s->table_name.str, - *tabledef_var, *conv_table_var)); + table_data->tabledef, table_data->conv_table)); return true; } return false; |