Commit dbd996e9 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: extract transaction-related part of handlerton

into a separate transaction_participant structure

handlerton inherits it, so handlerton itself doesn't change.
but entities that only need to participate in a transaction,
like binlog or online alter log, use a transaction_participant
and no longer need to pretend to be a full-blown but invisible
storage engine which doesn't support create table.
parent cb135edc
......@@ -645,7 +645,7 @@ struct st_mysql_storage_engine
int interface_version;
};
struct handlerton;
struct transaction_participant;
/*
......@@ -748,7 +748,7 @@ void mysql_query_cache_invalidate4(MYSQL_THD thd,
/**
Provide a handler data getter to simplify coding
*/
void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
void *thd_get_ha_data(const MYSQL_THD thd, const struct transaction_participant *hton);
/**
......@@ -769,10 +769,10 @@ void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
thd_set_ha_data() in this connection before, storage engine
plugin lock gets released.
If handlerton::close_connection() didn't reset ha_data, server does
it immediately after calling handlerton::close_connection().
If transaction_participant::close_connection() didn't reset ha_data, server
does it immediately after calling transaction_participant::close_connection()
*/
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
void thd_set_ha_data(MYSQL_THD thd, const struct transaction_participant *hton,
const void *ha_data);
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -595,7 +595,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -623,8 +623,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
......@@ -643,7 +643,7 @@ struct st_mysql_storage_engine
{
int interface_version;
};
struct handlerton;
struct transaction_participant;
struct Mysql_replication {
int interface_version;
};
......@@ -671,8 +671,8 @@ void thd_get_xid(const THD* thd, MYSQL_XID *xid);
void mysql_query_cache_invalidate4(THD* thd,
const char *key, unsigned int key_length,
int using_trx);
void *thd_get_ha_data(const THD* thd, const struct handlerton *hton);
void thd_set_ha_data(THD* thd, const struct handlerton *hton,
void *thd_get_ha_data(const THD* thd, const struct transaction_participant *hton);
void thd_set_ha_data(THD* thd, const struct transaction_participant *hton,
const void *ha_data);
void thd_wakeup_subsequent_commits(THD* thd, int wakeup_error);
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1397,7 +1397,7 @@ binlog_cache_data* binlog_get_cache_data(binlog_cache_mngr *cache_mngr,
bool use_trans_cache);
extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log;
extern handlerton *binlog_hton;
extern transaction_participant binlog_tp;
extern LOGGER logger;
extern const char *log_bin_index;
......@@ -1483,8 +1483,8 @@ const char *
get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list);
int binlog_commit(THD *thd, bool all, bool is_ro_1pc= false);
int binlog_commit_by_xid(handlerton *hton, XID *xid);
int binlog_rollback_by_xid(handlerton *hton, XID *xid);
int binlog_commit_by_xid(XID *xid);
int binlog_rollback_by_xid(XID *xid);
bool write_bin_log_start_alter(THD *thd, bool& partial_alter,
uint64 start_alter_id, bool log_if_exists);
#endif /* LOG_H */
......@@ -21,10 +21,31 @@
#include "sql_class.h"
#include "log_cache.h"
typedef void *sv_id_t;
static handlerton *online_alter_hton;
static int online_alter_close_connection(THD *thd);
static int online_alter_savepoint_set(THD *thd, sv_id_t sv_id);
static int online_alter_savepoint_rollback(THD *thd, sv_id_t sv_id);
static int online_alter_commit(THD *thd, bool all);
static int online_alter_rollback(THD *thd, bool all);
static int online_alter_prepare(THD *thd, bool all);
static int online_alter_commit_by_xid(XID *x);
static int online_alter_rollback_by_xid(XID *x);
typedef void *sv_id_t;
static transaction_participant online_alter_tp=
{
0, 0, HTON_NO_ROLLBACK,
online_alter_close_connection,
online_alter_savepoint_set, online_alter_savepoint_rollback,
[](THD *thd){ return true; }, /*savepoint_rollback_can_release_mdl*/
NULL, /*savepoint_release*/
online_alter_commit, online_alter_rollback, online_alter_prepare,
[](XID*, uint){ return 0; }, /*recover*/
online_alter_commit_by_xid,
online_alter_rollback_by_xid,
NULL, NULL,
NULL, NULL, NULL, NULL, NULL /* snapshot, *_ordered, checkpoint, versioned*/
};
struct Online_alter_cache_list: ilist<online_alter_cache_data>
{
......@@ -108,7 +129,8 @@ online_alter_cache_data *setup_cache_data(MEM_ROOT *root, TABLE_SHARE *share)
}
static Online_alter_cache_list &get_cache_list(handlerton *ht, THD *thd)
static Online_alter_cache_list &get_cache_list(transaction_participant *ht,
THD *thd)
{
void *data= thd_get_ha_data(thd, ht);
DBUG_ASSERT(data);
......@@ -118,11 +140,11 @@ static Online_alter_cache_list &get_cache_list(handlerton *ht, THD *thd)
static Online_alter_cache_list &get_or_create_cache_list(THD *thd)
{
void *data= thd_get_ha_data(thd, online_alter_hton);
void *data= thd_get_ha_data(thd, &online_alter_tp);
if (!data)
{
data= new Online_alter_cache_list();
thd_set_ha_data(thd, online_alter_hton, data);
thd_set_ha_data(thd, &online_alter_tp, data);
}
return *(Online_alter_cache_list*)data;
}
......@@ -155,9 +177,9 @@ int online_alter_log_row(TABLE* table, const uchar *before_record,
{
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_hton, 0);
trans_register_ha(thd, false, &online_alter_tp, 0);
if (thd->in_multi_stmt_transaction_mode())
trans_register_ha(thd, true, online_alter_hton, 0);
trans_register_ha(thd, true, &online_alter_tp, 0);
}
// We need to log all columns for the case if alter table changes primary key
......@@ -275,10 +297,10 @@ void cleanup_tables(THD *thd)
}
static
int online_alter_savepoint_set(handlerton *hton, THD *thd, sv_id_t sv_id)
int online_alter_savepoint_set(THD *thd, sv_id_t sv_id)
{
DBUG_ENTER("binlog_online_alter_savepoint");
auto &cache_list= get_cache_list(hton, thd);
auto &cache_list= get_cache_list(&online_alter_tp, thd);
if (cache_list.empty())
DBUG_RETURN(0);
......@@ -296,11 +318,11 @@ int online_alter_savepoint_set(handlerton *hton, THD *thd, sv_id_t sv_id)
}
static
int online_alter_savepoint_rollback(handlerton *hton, THD *thd, sv_id_t sv_id)
int online_alter_savepoint_rollback(THD *thd, sv_id_t sv_id)
{
DBUG_ENTER("online_alter_savepoint_rollback");
auto &cache_list= get_cache_list(hton, thd);
auto &cache_list= get_cache_list(&online_alter_tp, thd);
for (auto &cache: cache_list)
{
if (cache.hton->savepoint_set == NULL)
......@@ -316,52 +338,76 @@ int online_alter_savepoint_rollback(handlerton *hton, THD *thd, sv_id_t sv_id)
DBUG_RETURN(0);
}
static int online_alter_commit(handlerton *hton, THD *thd, bool all)
static int online_alter_commit_by_xid(XID *x)
{
auto *xid= static_cast<XA_data*>(x);
if (likely(xid->online_alter_cache == NULL))
return 1;
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;
};
static int online_alter_rollback_by_xid(XID *x)
{
auto *xid= static_cast<XA_data*>(x);
if (likely(xid->online_alter_cache == NULL))
return 1;
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;
};
static int online_alter_commit(THD *thd, bool all)
{
int res;
bool is_ending_transaction= ending_trans(thd, all);
if (is_ending_transaction
&& thd->transaction->xid_state.get_state_code() == XA_PREPARED)
{
res= hton->commit_by_xid(hton, thd->transaction->xid_state.get_xid());
res= online_alter_commit_by_xid(thd->transaction->xid_state.get_xid());
// cleanup was already done by prepare()
}
else
{
res= online_alter_end_trans(get_cache_list(hton, thd), thd,
res= online_alter_end_trans(get_cache_list(&online_alter_tp, thd), thd,
is_ending_transaction, true);
cleanup_tables(thd);
}
return res;
};
static int online_alter_rollback(handlerton *hton, THD *thd, bool all)
static int online_alter_rollback(THD *thd, bool all)
{
int res;
bool is_ending_transaction= ending_trans(thd, all);
if (is_ending_transaction
&& thd->transaction->xid_state.get_state_code() == XA_PREPARED)
{
res= hton->rollback_by_xid(hton, thd->transaction->xid_state.get_xid());
res= online_alter_rollback_by_xid(thd->transaction->xid_state.get_xid());
// cleanup was already done by prepare()
}
else
{
res= online_alter_end_trans(get_cache_list(hton, thd), thd,
res= online_alter_end_trans(get_cache_list(&online_alter_tp, thd), thd,
is_ending_transaction, false);
cleanup_tables(thd);
}
return res;
};
static int online_alter_prepare(handlerton *hton, THD *thd, bool all)
static int online_alter_prepare(THD *thd, bool all)
{
auto &cache_list= get_cache_list(hton, thd);
auto &cache_list= get_cache_list(&online_alter_tp, thd);
int res= 0;
if (ending_trans(thd, all))
{
thd->transaction->xid_state.set_online_alter_cache(&cache_list);
thd_set_ha_data(thd, hton, NULL);
thd_set_ha_data(thd, &online_alter_tp, NULL);
}
else
{
......@@ -372,85 +418,41 @@ static int online_alter_prepare(handlerton *hton, THD *thd, bool all)
return res;
};
static int online_alter_commit_by_xid(handlerton *hton, XID *x)
{
auto *xid= static_cast<XA_data*>(x);
if (likely(xid->online_alter_cache == NULL))
return 1;
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;
};
static int online_alter_rollback_by_xid(handlerton *hton, XID *x)
static int online_alter_close_connection(THD *thd)
{
auto *xid= static_cast<XA_data*>(x);
if (likely(xid->online_alter_cache == NULL))
return 1;
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;
};
static int online_alter_close_connection(handlerton *hton, THD *thd)
{
auto *cache_list= (Online_alter_cache_list*)thd_get_ha_data(thd, hton);
auto *cache_list= (Online_alter_cache_list*)thd_get_ha_data(thd, &online_alter_tp);
DBUG_ASSERT(!cache_list || cache_list->empty());
delete cache_list;
thd_set_ha_data(thd, hton, NULL);
thd_set_ha_data(thd, &online_alter_tp, NULL);
return 0;
}
static int online_alter_log_init(void *p)
{
online_alter_hton= (handlerton *)p;
online_alter_hton->db_type= DB_TYPE_ONLINE_ALTER;
online_alter_hton->savepoint_offset= 0;
online_alter_hton->close_connection= online_alter_close_connection;
online_alter_hton->savepoint_set= online_alter_savepoint_set;
online_alter_hton->savepoint_rollback= online_alter_savepoint_rollback;
online_alter_hton->savepoint_rollback_can_release_mdl=
[](handlerton *hton, THD *thd){ return true; };
online_alter_hton->commit= online_alter_commit;
online_alter_hton->rollback= online_alter_rollback;
online_alter_hton->recover= [](handlerton*, XID*, uint){ return 0; };
online_alter_hton->prepare= online_alter_prepare;
online_alter_hton->commit_by_xid= online_alter_commit_by_xid;
online_alter_hton->rollback_by_xid= online_alter_rollback_by_xid;
online_alter_hton->drop_table= [](handlerton *, const char*) { return -1; };
online_alter_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN
| HTON_NO_ROLLBACK;
return 0;
auto plugin= (st_plugin_int*)p;
plugin->data= &online_alter_tp;
return setup_transaction_participant(plugin);
}
struct st_mysql_storage_engine online_alter_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
struct st_mysql_daemon online_alter_plugin=
{ MYSQL_DAEMON_INTERFACE_VERSION };
maria_declare_plugin(online_alter_log)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&online_alter_storage_engine,
MYSQL_DAEMON_PLUGIN,
&online_alter_plugin,
"online_alter_log",
"MariaDB PLC",
"A pseudo storage engine for the online alter log",
"This is a plugin to represent the online alter log in a transaction",
PLUGIN_LICENSE_GPL,
online_alter_log_init,
NULL,
0x0100, // 1.0
0x0200, // 2.0
NULL, // no status vars
NULL, // no sysvars
"1.0",
"2.0",
MariaDB_PLUGIN_MATURITY_STABLE
}
maria_declare_plugin_end;
......@@ -530,7 +530,7 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_CSTRING *out_tablename)
void *trx_hton= ha_info->ht();
auto table_entry= list;
if (!ha_info->is_trx_read_write() || trx_hton == binlog_hton)
if (!ha_info->is_trx_read_write() || trx_hton == &binlog_tp)
continue;
while (table_entry)
{
......@@ -552,7 +552,7 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_CSTRING *out_tablename)
ha_info= ha_info->next();
if (!ha_info)
break;
if (ha_info->is_trx_read_write() && ha_info->ht() != binlog_hton)
if (ha_info->is_trx_read_write() && ha_info->ht() != &binlog_tp)
{
statistic_increment(rpl_transactions_multi_engine, LOCK_status);
break;
......
......@@ -441,7 +441,7 @@ void thd_storage_lock_wait(THD *thd, long long value)
Provide a handler data getter to simplify coding
*/
extern "C"
void *thd_get_ha_data(const THD *thd, const struct handlerton *hton)
void *thd_get_ha_data(const THD *thd, const struct transaction_participant *hton)
{
DBUG_ASSERT(thd == current_thd || mysql_mutex_is_owner(&thd->LOCK_thd_data));
return thd->ha_data[hton->slot].ha_ptr;
......@@ -453,7 +453,7 @@ void *thd_get_ha_data(const THD *thd, const struct handlerton *hton)
@see thd_set_ha_data() definition in plugin.h
*/
extern "C"
void thd_set_ha_data(THD *thd, const struct handlerton *hton,
void thd_set_ha_data(THD *thd, const struct transaction_participant *hton,
const void *ha_data)
{
plugin_ref *lock= &thd->ha_data[hton->slot].lock;
......
......@@ -119,6 +119,7 @@ enum enum_sql_command {
};
struct TABLE_LIST;
struct handlerton;
class Storage_engine_name
{
......@@ -133,8 +134,7 @@ class Storage_engine_name
Storage_engine_name(const LEX_CSTRING &name)
:m_storage_engine_name(name)
{ }
bool resolve_storage_engine_with_error(THD *thd,
handlerton **ha,
bool resolve_storage_engine_with_error(THD *thd, handlerton **ha,
bool tmp_table);
bool is_set() { return m_storage_engine_name.str != NULL; }
};
......
......@@ -442,21 +442,21 @@ class MHNSW_Trx : public MHNSW_Context
db_type= DB_TYPE_HLINDEX_HELPER;
flags = HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;
savepoint_offset= 0;
savepoint_set= [](handlerton *, THD *, void *){ return 0; };
savepoint_rollback_can_release_mdl= [](handlerton *, THD *){ return true; };
savepoint_set= [](THD *, void *){ return 0; };
savepoint_rollback_can_release_mdl= [](THD *){ return true; };
savepoint_rollback= do_savepoint_rollback;
commit= do_commit;
rollback= do_rollback;
}
static int do_commit(handlerton *, THD *thd, bool);
static int do_rollback(handlerton *, THD *thd, bool);
static int do_savepoint_rollback(handlerton *, THD *thd, void *);
static int do_commit(THD *thd, bool);
static int do_rollback(THD *thd, bool);
static int do_savepoint_rollback(THD *thd, void *);
} hton;
};
MHNSW_Trx::MHNSW_hton MHNSW_Trx::hton;
int MHNSW_Trx::MHNSW_hton::do_savepoint_rollback(handlerton *, THD *thd, void *)
int MHNSW_Trx::MHNSW_hton::do_savepoint_rollback(THD *thd, void *)
{
for (auto trx= static_cast<MHNSW_Trx*>(thd_get_ha_data(thd, &hton));
trx; trx= trx->next)
......@@ -464,7 +464,7 @@ int MHNSW_Trx::MHNSW_hton::do_savepoint_rollback(handlerton *, THD *thd, void *)
return 0;
}
int MHNSW_Trx::MHNSW_hton::do_rollback(handlerton *, THD *thd, bool)
int MHNSW_Trx::MHNSW_hton::do_rollback(THD *thd, bool)
{
MHNSW_Trx *trx_next;
for (auto trx= static_cast<MHNSW_Trx*>(thd_get_ha_data(thd, &hton));
......@@ -477,7 +477,7 @@ int MHNSW_Trx::MHNSW_hton::do_rollback(handlerton *, THD *thd, bool)
return 0;
}
int MHNSW_Trx::MHNSW_hton::do_commit(handlerton *, THD *thd, bool)
int MHNSW_Trx::MHNSW_hton::do_commit(THD *thd, bool)
{
MHNSW_Trx *trx_next;
for (auto trx= static_cast<MHNSW_Trx*>(thd_get_ha_data(thd, &hton));
......
Subproject commit 2acda95e0bcf3cd9ecb64c5933d6c0429df016b7
Subproject commit 44dd2a4848d4cb7e174ac30b213d834962b94c04
......@@ -393,6 +393,8 @@
#define MIN_PORT 0
#endif
static handlerton *federated_hton;
/* Variables for federated share methods */
static HASH federated_open_tables; // To track open tables
mysql_mutex_t federated_mutex; // To init the hash
......@@ -411,8 +413,8 @@ static const uint sizeof_trailing_where= sizeof(" WHERE ") - 1;
static handler *federated_create_handler(handlerton *hton,
TABLE_SHARE *table,
MEM_ROOT *mem_root);
static int federated_commit(handlerton *hton, THD *thd, bool all);
static int federated_rollback(handlerton *hton, THD *thd, bool all);
static int federated_commit(THD *thd, bool all);
static int federated_rollback(THD *thd, bool all);
/* Federated storage engine handlerton */
......@@ -489,7 +491,7 @@ int federated_db_init(void *p)
init_federated_psi_keys();
#endif /* HAVE_PSI_INTERFACE */
handlerton *federated_hton= (handlerton *)p;
federated_hton= (handlerton *)p;
federated_hton->db_type= DB_TYPE_FEDERATED_DB;
federated_hton->commit= federated_commit;
federated_hton->rollback= federated_rollback;
......@@ -3307,10 +3309,10 @@ int ha_federated::external_lock(THD *thd, int lock_type)
}
static int federated_commit(handlerton *hton, THD *thd, bool all)
static int federated_commit(THD *thd, bool all)
{
int return_val= 0;
ha_federated *trx= (ha_federated *) thd_get_ha_data(thd, hton);
ha_federated *trx= (ha_federated *) thd_get_ha_data(thd, federated_hton);
DBUG_ENTER("federated_commit");
if (all)
......@@ -3325,7 +3327,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
if (error && !return_val)
return_val= error;
}
thd_set_ha_data(thd, hton, NULL);
thd_set_ha_data(thd, federated_hton, NULL);
}
DBUG_PRINT("info", ("error val: %d", return_val));
......@@ -3333,10 +3335,10 @@ static int federated_commit(handlerton *hton, THD *thd, bool all)
}
static int federated_rollback(handlerton *hton, THD *thd, bool all)
static int federated_rollback(THD *thd, bool all)
{
int return_val= 0;
ha_federated *trx= (ha_federated *)thd_get_ha_data(thd, hton);
ha_federated *trx= (ha_federated *)thd_get_ha_data(thd, federated_hton);
DBUG_ENTER("federated_rollback");
if (all)
......@@ -3351,7 +3353,7 @@ static int federated_rollback(handlerton *hton, THD *thd, bool all)
if (error && !return_val)
return_val= error;
}
thd_set_ha_data(thd, hton, NULL);
thd_set_ha_data(thd, federated_hton, NULL);
}
DBUG_PRINT("info", ("error val: %d", return_val));
......
......@@ -1772,9 +1772,9 @@ federatedx_txn *ha_federatedx::get_txn(THD *thd, bool no_create)
}
int ha_federatedx::disconnect(handlerton *hton, MYSQL_THD thd)
int ha_federatedx::disconnect(MYSQL_THD thd)
{
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
delete txn;
return 0;
}
......@@ -3541,16 +3541,16 @@ int ha_federatedx::external_lock(MYSQL_THD thd, int lock_type)
}
int ha_federatedx::savepoint_set(handlerton *hton, MYSQL_THD thd, void *sv)
int ha_federatedx::savepoint_set(MYSQL_THD thd, void *sv)
{
int error= 0;
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
DBUG_ENTER("ha_federatedx::savepoint_set");
if (txn && txn->has_connections())
{
if (txn->txn_begin())
trans_register_ha(thd, TRUE, hton, 0);
trans_register_ha(thd, TRUE, federatedx_hton, 0);
txn->sp_acquire((ulong *) sv);
......@@ -3561,10 +3561,10 @@ int ha_federatedx::savepoint_set(handlerton *hton, MYSQL_THD thd, void *sv)
}
int ha_federatedx::savepoint_rollback(handlerton *hton, MYSQL_THD thd, void *sv)
int ha_federatedx::savepoint_rollback(MYSQL_THD thd, void *sv)
{
int error= 0;
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
DBUG_ENTER("ha_federatedx::savepoint_rollback");
if (txn)
......@@ -3574,10 +3574,10 @@ int ha_federatedx::savepoint_rollback(handlerton *hton, MYSQL_THD thd, void *sv)
}
int ha_federatedx::savepoint_release(handlerton *hton, MYSQL_THD thd, void *sv)
int ha_federatedx::savepoint_release(MYSQL_THD thd, void *sv)
{
int error= 0;
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
DBUG_ENTER("ha_federatedx::savepoint_release");
if (txn)
......@@ -3587,10 +3587,10 @@ int ha_federatedx::savepoint_release(handlerton *hton, MYSQL_THD thd, void *sv)
}
int ha_federatedx::commit(handlerton *hton, MYSQL_THD thd, bool all)
int ha_federatedx::commit(MYSQL_THD thd, bool all)
{
int return_val;
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
DBUG_ENTER("ha_federatedx::commit");
if (all)
......@@ -3603,10 +3603,10 @@ int ha_federatedx::commit(handlerton *hton, MYSQL_THD thd, bool all)
}
int ha_federatedx::rollback(handlerton *hton, MYSQL_THD thd, bool all)
int ha_federatedx::rollback(MYSQL_THD thd, bool all)
{
int return_val;
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, hton);
federatedx_txn *txn= (federatedx_txn *) thd_get_ha_data(thd, federatedx_hton);
DBUG_ENTER("ha_federatedx::rollback");
if (all)
......
......@@ -289,12 +289,12 @@ class ha_federatedx final : public handler
int stash_remote_error();
static federatedx_txn *get_txn(THD *thd, bool no_create= FALSE);
static int disconnect(handlerton *hton, MYSQL_THD thd);
static int savepoint_set(handlerton *hton, MYSQL_THD thd, void *sv);
static int savepoint_rollback(handlerton *hton, MYSQL_THD thd, void *sv);
static int savepoint_release(handlerton *hton, MYSQL_THD thd, void *sv);
static int commit(handlerton *hton, MYSQL_THD thd, bool all);
static int rollback(handlerton *hton, MYSQL_THD thd, bool all);
static int disconnect(MYSQL_THD thd);
static int savepoint_set(MYSQL_THD thd, void *sv);
static int savepoint_rollback(MYSQL_THD thd, void *sv);
static int savepoint_release(MYSQL_THD thd, void *sv);
static int commit(MYSQL_THD thd, bool all);
static int rollback(MYSQL_THD thd, bool all);
static int discover_assisted(handlerton *, THD*, TABLE_SHARE *,
HA_CREATE_INFO *);
......
This diff is collapsed.
......@@ -934,33 +934,3 @@ ib_push_frm_error(
@return true if index column length exceeds limit */
MY_ATTRIBUTE((warn_unused_result))
bool too_big_key_part_length(size_t max_field_len, const KEY& key);
/** This function is used to rollback one X/Open XA distributed transaction
which is in the prepared state
@param[in] hton InnoDB handlerton
@param[in] xid X/Open XA transaction identification
@return 0 or error number */
int innobase_rollback_by_xid(handlerton* hton, XID* xid);
/**
This function is used to rollback one X/Open XA distributed transaction
which is in the prepared state asynchronously.
It only set the transaction's status to ACTIVE and persist the status.
The transaction will be rolled back by background rollback thread.
@param xid X/Open XA transaction identification
@return 0 or error number
*/
int innobase_recover_rollback_by_xid(const XID *xid);
/**
This function is called after tc log is opened(typically binlog recovery)
has done. It starts rollback thread to rollback the transactions
have been changed from PREPARED to ACTIVE.
@return 0 or error number
*/
void innobase_tc_log_recovery_done();
......@@ -3587,8 +3587,7 @@ static int maria_hton_panic(handlerton *hton, ha_panic_function flag)
}
static int maria_commit(handlerton *hton __attribute__ ((unused)),
THD *thd, bool all)
static int maria_commit(THD *thd, bool all)
{
TRN *trn= THD_TRN;
int res= 0;
......@@ -3618,7 +3617,7 @@ static int maria_commit(handlerton *hton __attribute__ ((unused)),
}
#ifdef MARIA_CANNOT_ROLLBACK
static int maria_rollback(handlerton *hton, THD *thd, bool all)
static int maria_rollback(THD *thd, bool all)
{
TRN *trn= THD_TRN;
DBUG_ENTER("maria_rollback");
......@@ -3630,15 +3629,14 @@ static int maria_rollback(handlerton *hton, THD *thd, bool all)
ER_THD(thd, ER_DATA_WAS_COMMITED_UNDER_ROLLBACK),
"Aria");
if (all)
DBUG_RETURN(maria_commit(hton, thd, all));
DBUG_RETURN(maria_commit(thd, all));
/* Statement rollbacks are ignored. Commit will happen in external_lock */
DBUG_RETURN(0);
}
#else
static int maria_rollback(handlerton *hton __attribute__ ((unused)),
THD *thd, bool all)
static int maria_rollback(THD *thd, bool all)
{
TRN *trn= THD_TRN;
DBUG_ENTER("maria_rollback");
......
......@@ -1340,7 +1340,7 @@ static void mrn_drop_database(handlerton *hton, char *path)
DBUG_VOID_RETURN;
}
static int mrn_close_connection(handlerton *hton, THD *thd)
static int mrn_close_connection(THD *thd)
{
MRN_DBUG_ENTER_FUNCTION();
void *p = thd_get_ha_data(thd, mrn_hton_ptr);
......
......@@ -155,7 +155,7 @@ int oqgraph_discover_table_structure(handlerton *hton, THD* thd,
share->init_from_sql_statement_string(thd, true, sql.ptr(), sql.length());
}
int oqgraph_close_connection(handlerton *hton, THD *thd);
int oqgraph_close_connection(THD *thd);
static int oqgraph_init(void *p)
{
......@@ -380,7 +380,7 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg)
** OQGRAPH tables
*****************************************************************************/
int oqgraph_close_connection(handlerton *hton, THD *thd)
int oqgraph_close_connection(THD *thd)
{
DBUG_PRINT( "oq-debug", ("thd: 0x%lx; oqgraph_close_connection.", (long) thd));
// close_thread_tables(thd); // maybe this?
......
......@@ -3798,7 +3798,7 @@ static Rdb_transaction *get_or_create_tx(THD *const thd) {
return tx;
}
static int rocksdb_close_connection(handlerton *const hton, THD *const thd) {
static int rocksdb_close_connection(THD *const thd) {
Rdb_transaction *tx = get_tx_from_thd(thd);
if (tx != nullptr) {
bool is_critical_error;
......@@ -3876,7 +3876,7 @@ static bool rocksdb_flush_wal(handlerton* hton __attribute__((__unused__)))
For a slave, prepare() updates the slave_gtid_info table which tracks the
replication progress.
*/
static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
static int rocksdb_prepare(THD* thd, bool prepare_tx)
{
bool async=false; // This is "ASYNC_COMMIT" feature which is only present in webscalesql
......@@ -3960,10 +3960,9 @@ static int rocksdb_prepare(handlerton* hton, THD* thd, bool prepare_tx)
do nothing for prepare/commit by xid
this is needed to avoid crashes in XA scenarios
*/
static int rocksdb_commit_by_xid(handlerton *const hton, XID *const xid) {
static int rocksdb_commit_by_xid(XID *const xid) {
DBUG_ENTER_FUNC();
DBUG_ASSERT(hton != nullptr);
DBUG_ASSERT(xid != nullptr);
DBUG_ASSERT(commit_latency_stats != nullptr);
......@@ -3993,11 +3992,9 @@ static int rocksdb_commit_by_xid(handlerton *const hton, XID *const xid) {
DBUG_RETURN(HA_EXIT_SUCCESS);
}
static int rocksdb_rollback_by_xid(
handlerton *const hton MY_ATTRIBUTE((__unused__)), XID *const xid) {
static int rocksdb_rollback_by_xid(XID *const xid) {
DBUG_ENTER_FUNC();
DBUG_ASSERT(hton != nullptr);
DBUG_ASSERT(xid != nullptr);
DBUG_ASSERT(rdb != nullptr);
......@@ -4049,7 +4046,7 @@ static void rdb_xid_from_string(const std::string &src, XID *const dst) {
Reading last committed binary log info from RocksDB system row.
The info is needed for crash safe slave/master to work.
*/
static int rocksdb_recover(handlerton* hton, XID* xid_list, uint len)
static int rocksdb_recover(XID* xid_list, uint len)
#ifdef MARIAROCKS_NOT_YET
char* const binlog_file,
my_off_t *const binlog_pos,
......@@ -4128,7 +4125,7 @@ static void rocksdb_checkpoint_request(void *cookie)
@param all: TRUE - commit the transaction
FALSE - SQL statement ended
*/
static void rocksdb_commit_ordered(handlerton *hton, THD* thd, bool all)
static void rocksdb_commit_ordered(THD* thd, bool all)
{
// Same assert as InnoDB has
DBUG_ASSERT(all || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT |
......@@ -4154,11 +4151,10 @@ static void rocksdb_commit_ordered(handlerton *hton, THD* thd, bool all)
}
static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx)
static int rocksdb_commit(THD* thd, bool commit_tx)
{
DBUG_ENTER_FUNC();
DBUG_ASSERT(hton != nullptr);
DBUG_ASSERT(thd != nullptr);
DBUG_ASSERT(commit_latency_stats != nullptr);
......@@ -4236,8 +4232,7 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx)
}
static int rocksdb_rollback(handlerton *const hton, THD *const thd,
bool rollback_tx) {
static int rocksdb_rollback(THD *const thd, bool rollback_tx) {
Rdb_transaction *tx = get_tx_from_thd(thd);
Rdb_perf_context_guard guard(tx, rocksdb_perf_context_level(thd));
......@@ -4875,7 +4870,6 @@ static bool rocksdb_explicit_snapshot(
InnoDB and RocksDB transactions.
*/
static int rocksdb_start_tx_and_assign_read_view(
handlerton *const hton, /*!< in: RocksDB handlerton */
THD *const thd /*!< in: MySQL thread handle of the
user for whom the transaction should
be committed */
......@@ -4918,7 +4912,7 @@ static int rocksdb_start_tx_and_assign_read_view(
DBUG_ASSERT(!tx->has_snapshot());
tx->set_tx_read_only(true);
rocksdb_register_tx(hton, thd, tx);
rocksdb_register_tx(rocksdb_hton, thd, tx);
tx->acquire_snapshot(true);
#ifdef MARIADB_NOT_YET
......@@ -5026,19 +5020,16 @@ static int rocksdb_start_tx_with_shared_read_view(
* Current SAVEPOINT does not correctly handle ROLLBACK and does not return
* errors. This needs to be addressed in future versions (Issue#96).
*/
static int rocksdb_savepoint(handlerton *const hton, THD *const thd,
void *const savepoint) {
static int rocksdb_savepoint(THD *const thd, void *const savepoint) {
return HA_EXIT_SUCCESS;
}
static int rocksdb_rollback_to_savepoint(handlerton *const hton, THD *const thd,
void *const savepoint) {
static int rocksdb_rollback_to_savepoint(THD *const thd, void *const savepoint) {
Rdb_transaction *tx = get_tx_from_thd(thd);
return tx->rollback_to_savepoint(savepoint);
}
static bool rocksdb_rollback_to_savepoint_can_release_mdl(
handlerton *const /* hton */, THD *const /* thd */) {
static bool rocksdb_rollback_to_savepoint_can_release_mdl(THD *const) {
return true;
}
......
......@@ -364,10 +364,6 @@ static int discover_table_existence(handlerton *hton, const char *db,
return !parse_table_name(table_name, strlen(table_name), &from, &to, &step);
}
static int dummy_commit_rollback(handlerton *, THD *, bool) { return 0; }
static int dummy_savepoint(handlerton *, THD *, void *) { return 0; }
/*****************************************************************************
Example of a simple group by handler for queries like:
SELECT SUM(seq) from sequence_table;
......@@ -535,9 +531,10 @@ static int init(void *p)
hton->drop_table= drop_table;
hton->discover_table= discover_table;
hton->discover_table_existence= discover_table_existence;
hton->commit= hton->rollback= dummy_commit_rollback;
hton->commit= hton->rollback= [](THD *, bool) { return 0; };
hton->savepoint_set= hton->savepoint_rollback= hton->savepoint_release=
dummy_savepoint;
[](THD *, void *) { return 0; };
hton->create_group_by= create_group_by_handler;
hton->update_optimizer_costs= sequence_update_optimizer_costs;
return 0;
......
......@@ -649,7 +649,7 @@ template int CSphSEQuery::ParseArray<longlong> ( longlong **, const char * );
static handler * sphinx_create_handler ( handlerton * hton, TABLE_SHARE * table, MEM_ROOT * mem_root );
static int sphinx_init_func ( void * p );
static int sphinx_close_connection ( handlerton * hton, THD * thd );
static int sphinx_close_connection ( THD * thd );
static int sphinx_panic ( handlerton * hton, enum ha_panic_function flag );
static bool sphinx_show_status ( handlerton * hton, THD * thd, stat_print_fn * stat_print, enum ha_stat_type stat_type );
......@@ -763,11 +763,11 @@ static bool sphinx_init_func_for_handlerton ()
#if MYSQL_VERSION_ID>50100
static int sphinx_close_connection ( handlerton * hton, THD * thd )
static int sphinx_close_connection ( THD * thd )
{
// deallocate common handler data
SPH_ENTER_FUNC();
CSphTLS * pTls = (CSphTLS *) thd_get_ha_data ( thd, hton );
CSphTLS * pTls = (CSphTLS *) thd_get_ha_data ( thd, sphinx_hton_ptr );
SafeDelete ( pTls );
SPH_RET(0);
}
......
......@@ -6189,7 +6189,6 @@ handler* spider_create_handler(
}
int spider_close_connection(
handlerton* hton,
THD* thd
) {
int roop_count = 0;
......@@ -6219,7 +6218,7 @@ int spider_close_connection(
SPIDER_CONN_RESTORE_DASTATUS;
}
spider_rollback(spider_hton_ptr, thd, TRUE);
spider_rollback(thd, TRUE);
Dummy_error_handler deh; // suppress network errors at this stage
thd->push_internal_handler(&deh);
......
......@@ -2965,7 +2965,6 @@ int spider_internal_xa_rollback_by_xid(
}
int spider_start_consistent_snapshot(
handlerton *hton,
THD* thd
) {
int error_num;
......@@ -3053,7 +3052,6 @@ int spider_start_consistent_snapshot(
}
int spider_commit(
handlerton *hton,
THD *thd,
bool all
) {
......@@ -3091,7 +3089,7 @@ int spider_commit(
{
*/
/* rollback for semi_trx */
spider_rollback(hton, thd, all);
spider_rollback(thd, all);
/*
}
*/
......@@ -3148,7 +3146,6 @@ int spider_commit(
}
int spider_rollback(
handlerton *hton,
THD *thd,
bool all
) {
......@@ -3225,7 +3222,6 @@ int spider_rollback(
}
int spider_xa_prepare(
handlerton *hton,
THD* thd,
bool all
) {
......@@ -3260,7 +3256,6 @@ int spider_xa_prepare(
}
int spider_xa_recover(
handlerton *hton,
XID* xid_list,
uint len
) {
......@@ -3276,7 +3271,6 @@ int spider_xa_recover(
}
int spider_xa_commit_by_xid(
handlerton *hton,
XID* xid
) {
SPIDER_TRX *trx;
......@@ -3298,7 +3292,6 @@ int spider_xa_commit_by_xid(
}
int spider_xa_rollback_by_xid(
handlerton *hton,
XID* xid
) {
SPIDER_TRX *trx;
......
......@@ -180,41 +180,34 @@ int spider_internal_xa_rollback_by_xid(
);
int spider_start_consistent_snapshot(
handlerton *hton,
THD* thd
);
int spider_commit(
handlerton *hton,
THD *thd,
bool all
);
int spider_rollback(
handlerton *hton,
THD *thd,
bool all
);
int spider_xa_prepare(
handlerton *hton,
THD* thd,
bool all
);
int spider_xa_recover(
handlerton *hton,
XID* xid_list,
uint len
);
int spider_xa_commit_by_xid(
handlerton *hton,
XID* xid
);
int spider_xa_rollback_by_xid(
handlerton *hton,
XID* xid
);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment