1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-11 05:52:26 +03:00

Change THD->transaction to a pointer to enable multiple transactions

All changes (except one) is of type
thd->transaction.  -> thd->transaction->

thd->transaction points by default to 'thd->default_transaction'
This allows us to 'easily' have multiple active transactions for a
THD object, like when reading data from the mysql.proc table
This commit is contained in:
Monty
2020-05-04 14:20:14 +03:00
parent 7ae812cf2c
commit d1d472646d
32 changed files with 317 additions and 311 deletions

View File

@@ -813,12 +813,14 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
system_thread= NON_SYSTEM_THREAD;
cleanup_done= free_connection_done= abort_on_warning= 0;
peer_port= 0; // For SHOW PROCESSLIST
transaction.m_pending_rows_event= 0;
transaction.on= 1;
wt_thd_lazy_init(&transaction.wt, &variables.wt_deadlock_search_depth_short,
&variables.wt_timeout_short,
&variables.wt_deadlock_search_depth_long,
&variables.wt_timeout_long);
transaction= &default_transaction;
transaction->m_pending_rows_event= 0;
transaction->on= 1;
wt_thd_lazy_init(&transaction->wt,
&variables.wt_deadlock_search_depth_short,
&variables.wt_timeout_short,
&variables.wt_deadlock_search_depth_long,
&variables.wt_timeout_long);
#ifdef SIGNAL_WITH_VIO_CLOSE
active_vio = 0;
#endif
@@ -1262,10 +1264,10 @@ void THD::init()
if (variables.sql_mode & MODE_ANSI_QUOTES)
server_status|= SERVER_STATUS_ANSI_QUOTES;
transaction.all.modified_non_trans_table=
transaction.stmt.modified_non_trans_table= FALSE;
transaction.all.m_unsafe_rollback_flags=
transaction.stmt.m_unsafe_rollback_flags= 0;
transaction->all.modified_non_trans_table=
transaction->stmt.modified_non_trans_table= FALSE;
transaction->all.m_unsafe_rollback_flags=
transaction->stmt.m_unsafe_rollback_flags= 0;
open_options=ha_open_options;
update_lock_default= (variables.low_priority_updates ?
@@ -1396,11 +1398,11 @@ void THD::init_for_queries()
reset_root_defaults(mem_root, variables.query_alloc_block_size,
variables.query_prealloc_size);
reset_root_defaults(&transaction.mem_root,
reset_root_defaults(&transaction->mem_root,
variables.trans_alloc_block_size,
variables.trans_prealloc_size);
DBUG_ASSERT(!transaction.xid_state.is_explicit_XA());
DBUG_ASSERT(transaction.implicit_xid.is_null());
DBUG_ASSERT(!transaction->xid_state.is_explicit_XA());
DBUG_ASSERT(transaction->implicit_xid.is_null());
}
@@ -1539,7 +1541,7 @@ void THD::cleanup(void)
delete_dynamic(&user_var_events);
close_temporary_tables();
if (transaction.xid_state.is_explicit_XA())
if (transaction->xid_state.is_explicit_XA())
trans_xa_detach(this);
else
trans_rollback(this);
@@ -1565,7 +1567,7 @@ void THD::cleanup(void)
decrease_user_connections(user_connect);
user_connect= 0; // Safety
}
wt_thd_destroy(&transaction.wt);
wt_thd_destroy(&transaction->wt);
my_hash_free(&user_vars);
my_hash_free(&sequences);
@@ -1697,7 +1699,7 @@ THD::~THD()
#endif
mdl_context.destroy();
free_root(&transaction.mem_root,MYF(0));
transaction->free();
mysql_cond_destroy(&COND_wakeup_ready);
mysql_mutex_destroy(&LOCK_wakeup_ready);
mysql_mutex_destroy(&LOCK_thd_data);
@@ -2597,8 +2599,8 @@ void THD::add_changed_table(TABLE *table)
void THD::add_changed_table(const char *key, size_t key_length)
{
DBUG_ENTER("THD::add_changed_table(key)");
CHANGED_TABLE_LIST **prev_changed = &transaction.changed_tables;
CHANGED_TABLE_LIST *curr = transaction.changed_tables;
CHANGED_TABLE_LIST **prev_changed = &transaction->changed_tables;
CHANGED_TABLE_LIST *curr = transaction->changed_tables;
for (; curr; prev_changed = &(curr->next), curr = curr->next)
{
@@ -5050,7 +5052,7 @@ thd_rpl_deadlock_check(MYSQL_THD thd, MYSQL_THD other_thd)
if (!thd)
return 0;
DEBUG_SYNC(thd, "thd_report_wait_for");
thd->transaction.stmt.mark_trans_did_wait();
thd->transaction->stmt.mark_trans_did_wait();
if (!other_thd)
return 0;
binlog_report_wait_for(thd, other_thd);
@@ -5153,7 +5155,7 @@ thd_need_ordering_with(const MYSQL_THD thd, const MYSQL_THD other_thd)
extern "C" int thd_non_transactional_update(const MYSQL_THD thd)
{
return(thd->transaction.all.modified_non_trans_table);
return(thd->transaction->all.modified_non_trans_table);
}
extern "C" int thd_binlog_format(const MYSQL_THD thd)
@@ -5362,7 +5364,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
backup->limit_found_rows= limit_found_rows;
backup->cuted_fields= cuted_fields;
backup->client_capabilities= client_capabilities;
backup->savepoints= transaction.savepoints;
backup->savepoints= transaction->savepoints;
backup->first_successful_insert_id_in_prev_stmt=
first_successful_insert_id_in_prev_stmt;
backup->first_successful_insert_id_in_cur_stmt=
@@ -5384,7 +5386,7 @@ void THD::reset_sub_statement_state(Sub_statement_state *backup,
client_capabilities &= ~CLIENT_MULTI_RESULTS;
in_sub_stmt|= new_state;
cuted_fields= 0;
transaction.savepoints= 0;
transaction->savepoints= 0;
first_successful_insert_id_in_cur_stmt= 0;
reset_slow_query_state();
}
@@ -5410,16 +5412,16 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup)
level. It is enough to release first savepoint set on this level since
all later savepoints will be released automatically.
*/
if (transaction.savepoints)
if (transaction->savepoints)
{
SAVEPOINT *sv;
for (sv= transaction.savepoints; sv->prev; sv= sv->prev)
for (sv= transaction->savepoints; sv->prev; sv= sv->prev)
{}
/* ha_release_savepoint() never returns error. */
(void)ha_release_savepoint(this, sv);
}
count_cuted_fields= backup->count_cuted_fields;
transaction.savepoints= backup->savepoints;
transaction->savepoints= backup->savepoints;
variables.option_bits= backup->option_bits;
in_sub_stmt= backup->in_sub_stmt;
enable_slow_log= backup->enable_slow_log;