static online_alter_cache_data* get_cache_data(THD *thd, TABLE *table)
{ auto &cache_list= get_or_create_cache_list(thd); /* we assume it's very rare to have more than one online ALTER running */ for (auto &cache: cache_list)
{ if (cache.sink_log == table->s->online_alter_binlog) return &cache;
}
MEM_ROOT *root= &thd->transaction->mem_root; auto *new_cache_data= setup_cache_data(root, table->s);
cache_list.push_back(*new_cache_data);
if (!table->online_alter_cache)
{
table->online_alter_cache= get_cache_data(thd, table);
DBUG_ASSERT(table->online_alter_cache->cache_log.type == WRITE_CACHE);
trans_register_ha(thd, false, &online_alter_tp, 0); if (thd->in_multi_stmt_transaction_mode())
trans_register_ha(thd, true, &online_alter_tp, 0);
}
// We need to log all columns for the case if alter table changes primary key
DBUG_ASSERT(!before_record || bitmap_is_set_all(table->read_set));
MY_BITMAP *old_rpl_write_set= table->rpl_write_set;
table->rpl_write_set= &table->s->all_set;
if (commit || non_trans)
{ // Do not set STMT_END for last event to leave table open in altering thd
error= binlog_flush_pending_rows_event(thd, false, true, binlog, &cache); if (error)
do_commit= commit= 0;
}
static int online_alter_savepoint_set(THD *thd, sv_id_t sv_id)
{
DBUG_ENTER("binlog_online_alter_savepoint"); auto &cache_list= get_cache_list(&online_alter_tp, thd); if (cache_list.empty())
DBUG_RETURN(0);
for (auto &cache: cache_list)
{ if (cache.hton->savepoint_set == NULL) continue;
auto *sv= new table_savepoint(sv_id, cache.get_byte_position()); if(unlikely(sv == NULL))
DBUG_RETURN(1);
cache.sv_list.push_front(*sv);
}
DBUG_RETURN(0);
}
static int online_alter_savepoint_rollback(THD *thd, sv_id_t sv_id)
{
DBUG_ENTER("online_alter_savepoint_rollback");
auto &cache_list= get_cache_list(&online_alter_tp, thd); for (auto &cache: cache_list)
{ if (cache.hton->savepoint_set == NULL) continue;
// There's no savepoint if it was set up before online table was modified. // In that case, restore to 0.
my_off_t pos= cache.pop_sv_until(sv_id);
cache.restore_savepoint(pos);
}
DBUG_RETURN(0);
}
staticint online_alter_commit_by_xid(XID *x)
{ auto *xid= static_cast<XA_data*>(x); if (likely(xid->online_alter_cache == NULL)) return1; int res= online_alter_end_trans(*xid->online_alter_cache, current_thd, true, true); delete xid->online_alter_cache;
xid->online_alter_cache= NULL; return res;
};
staticint online_alter_rollback_by_xid(XID *x)
{ auto *xid= static_cast<XA_data*>(x); if (likely(xid->online_alter_cache == NULL)) return1; int res= online_alter_end_trans(*xid->online_alter_cache, current_thd, true, false); delete xid->online_alter_cache;
xid->online_alter_cache= NULL; return res;
};
maria_declare_plugin(online_alter_log)
{
MYSQL_DAEMON_PLUGIN,
&online_alter_plugin, "online_alter_log", "MariaDB PLC", "This is a plugin to represent the online alter log in a transaction",
PLUGIN_LICENSE_GPL,
online_alter_log_init,
NULL, 0x0200, // 2.0
NULL, // no status vars
NULL, // no sysvars "2.0",
MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.11Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.