Commit 5e1b3cc8 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Fixed Aria to follow THD ha_data protocol

Use thd_get_ha_data()/thd_set_ha_data() which protect against plugin
removal until it has THD ha_data.

Part of MDEV-19515 - Improve connect speed
parent ba59cc0f
...@@ -56,7 +56,7 @@ C_MODE_END ...@@ -56,7 +56,7 @@ C_MODE_END
#else #else
#define CANNOT_ROLLBACK_FLAG 0 #define CANNOT_ROLLBACK_FLAG 0
#endif #endif
#define THD_TRN (*(TRN **)thd_ha_data(thd, maria_hton)) #define THD_TRN (TRN*) thd_get_ha_data(thd, maria_hton)
ulong pagecache_division_limit, pagecache_age_threshold, pagecache_file_hash_size; ulong pagecache_division_limit, pagecache_age_threshold, pagecache_file_hash_size;
ulonglong pagecache_buffer_size; ulonglong pagecache_buffer_size;
...@@ -953,7 +953,7 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) ...@@ -953,7 +953,7 @@ static int maria_create_trn_for_mysql(MARIA_HA *info)
trn= trnman_new_trn(& thd->transaction.wt); trn= trnman_new_trn(& thd->transaction.wt);
if (unlikely(!trn)) if (unlikely(!trn))
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
THD_TRN= trn; thd_set_ha_data(thd, maria_hton, trn);
if (thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) if (thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
trans_register_ha(thd, TRUE, maria_hton); trans_register_ha(thd, TRUE, maria_hton);
} }
...@@ -2848,13 +2848,13 @@ int ha_maria::external_lock(THD *thd, int lock_type) ...@@ -2848,13 +2848,13 @@ int ha_maria::external_lock(THD *thd, int lock_type)
#ifdef MARIA_CANNOT_ROLLBACK #ifdef MARIA_CANNOT_ROLLBACK
if (ma_commit(trn)) if (ma_commit(trn))
DBUG_RETURN(1); DBUG_RETURN(1);
THD_TRN= 0; thd_set_ha_data(thd, maria_hton, 0);
#else #else
if (!(thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) if (!(thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
{ {
trnman_rollback_trn(trn); trnman_rollback_trn(trn);
DBUG_PRINT("info", ("THD_TRN set to 0x0")); DBUG_PRINT("info", ("THD_TRN set to 0x0"));
THD_TRN= 0; thd_set_ha_data(thd, maria_hton, 0);
} }
#endif #endif
} }
...@@ -2911,7 +2911,7 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type) ...@@ -2911,7 +2911,7 @@ int ha_maria::start_stmt(THD *thd, thr_lock_type lock_type)
static void reset_thd_trn(THD *thd, MARIA_HA *first_table) static void reset_thd_trn(THD *thd, MARIA_HA *first_table)
{ {
DBUG_ENTER("reset_thd_trn"); DBUG_ENTER("reset_thd_trn");
THD_TRN= NULL; thd_set_ha_data(thd, maria_hton, 0);
MARIA_HA *next; MARIA_HA *next;
for (MARIA_HA *table= first_table; table ; table= next) for (MARIA_HA *table= first_table; table ; table= next)
{ {
...@@ -2984,7 +2984,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) ...@@ -2984,7 +2984,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
statement assuming they have a trn (see ha_maria::start_stmt()). statement assuming they have a trn (see ha_maria::start_stmt()).
*/ */
trn= trnman_new_trn(& thd->transaction.wt); trn= trnman_new_trn(& thd->transaction.wt);
THD_TRN= trn; thd_set_ha_data(thd, maria_hton, trn);
if (unlikely(trn == NULL)) if (unlikely(trn == NULL))
{ {
reset_thd_trn(thd, used_tables); reset_thd_trn(thd, used_tables);
......
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