From d1d472646d578608791dcd33c13ca6b2472e31b2 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 4 May 2020 14:20:14 +0300 Subject: 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 --- sql/handler.cc | 72 ++++++++++++++++---------------- sql/log.cc | 54 ++++++++++++------------ sql/log_event_server.cc | 38 ++++++++--------- sql/rpl_gtid.cc | 2 +- sql/rpl_rli.cc | 2 +- sql/semisync_master.cc | 2 +- sql/session_tracker.cc | 4 +- sql/slave.cc | 6 +-- sql/sp_head.cc | 6 +-- sql/sql_base.cc | 10 ++--- sql/sql_class.cc | 52 ++++++++++++----------- sql/sql_class.h | 36 +++++++++------- sql/sql_delete.cc | 34 +++++++-------- sql/sql_handler.cc | 2 +- sql/sql_insert.cc | 38 ++++++++--------- sql/sql_load.cc | 14 +++---- sql/sql_parse.cc | 18 ++++---- sql/sql_prepare.cc | 2 +- sql/sql_sequence.cc | 4 +- sql/sql_table.cc | 10 ++--- sql/sql_update.cc | 48 ++++++++++----------- sql/sys_vars.cc | 10 ++--- sql/temporary_tables.cc | 2 +- sql/threadpool_common.cc | 2 +- sql/transaction.cc | 48 ++++++++++----------- sql/wsrep_applier.cc | 2 +- sql/wsrep_trans_observer.h | 2 +- sql/xa.cc | 90 ++++++++++++++++++++-------------------- storage/maria/ha_maria.cc | 6 +-- storage/spider/spd_db_conn.cc | 2 +- storage/spider/spd_direct_sql.cc | 8 ++-- storage/spider/spd_trx.cc | 2 +- 32 files changed, 317 insertions(+), 311 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 9e648815beb..39841cc28d7 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1244,14 +1244,14 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg, ulonglong trxid) if (all) { - trans= &thd->transaction.all; + trans= &thd->transaction->all; thd->server_status|= SERVER_STATUS_IN_TRANS; if (thd->tx_read_only) thd->server_status|= SERVER_STATUS_IN_TRANS_READONLY; DBUG_PRINT("info", ("setting SERVER_STATUS_IN_TRANS")); } else - trans= &thd->transaction.stmt; + trans= &thd->transaction->stmt; ha_info= thd->ha_data[ht_arg->slot].ha_info + (all ? 1 : 0); @@ -1263,8 +1263,8 @@ void trans_register_ha(THD *thd, bool all, handlerton *ht_arg, ulonglong trxid) trans->no_2pc|=(ht_arg->prepare==0); /* Set implicit xid even if there's explicit XA, it will be ignored anyway. */ - if (thd->transaction.implicit_xid.is_null()) - thd->transaction.implicit_xid.set(thd->query_id); + if (thd->transaction->implicit_xid.is_null()) + thd->transaction->implicit_xid.set(thd->query_id); /* Register transaction start in performance schema if not done already. @@ -1327,7 +1327,7 @@ static int prepare_or_error(handlerton *ht, THD *thd, bool all) int ha_prepare(THD *thd) { int error=0, all=1; - THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; + THD_TRANS *trans=all ? &thd->transaction->all : &thd->transaction->stmt; Ha_trx_info *ha_info= trans->ha_list; DBUG_ENTER("ha_prepare"); @@ -1377,7 +1377,7 @@ uint ha_count_rw_all(THD *thd, Ha_trx_info **ptr_ha_info) { unsigned rw_ha_count= 0; - for (auto ha_info= thd->transaction.all.ha_list; ha_info; + for (auto ha_info= thd->transaction->all.ha_list; ha_info; ha_info= ha_info->next()) { if (ha_info->is_trx_read_write()) @@ -1472,7 +1472,7 @@ int ha_commit_trans(THD *thd, bool all) 'all' means that this is either an explicit commit issued by user, or an implicit commit issued by a DDL. */ - THD_TRANS *trans= all ? &thd->transaction.all : &thd->transaction.stmt; + THD_TRANS *trans= all ? &thd->transaction->all : &thd->transaction->stmt; /* "real" is a nick name for a transaction for which a commit will make persistent changes. E.g. a 'stmt' transaction inside a 'all' @@ -1480,7 +1480,7 @@ int ha_commit_trans(THD *thd, bool all) the changes are not durable as they might be rolled back if the enclosing 'all' transaction is rolled back. */ - bool is_real_trans= ((all || thd->transaction.all.ha_list == 0) && + bool is_real_trans= ((all || thd->transaction->all.ha_list == 0) && !(thd->variables.option_bits & OPTION_GTID_BEGIN)); Ha_trx_info *ha_info= trans->ha_list; bool need_prepare_ordered, need_commit_ordered; @@ -1507,8 +1507,8 @@ int ha_commit_trans(THD *thd, bool all) flags will not get propagated to its normal transaction's counterpart. */ - DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL || - trans == &thd->transaction.stmt); + DBUG_ASSERT(thd->transaction->stmt.ha_list == NULL || + trans == &thd->transaction->stmt); if (thd->in_sub_stmt) { @@ -1538,7 +1538,7 @@ int ha_commit_trans(THD *thd, bool all) */ if (is_real_trans) { - thd->transaction.cleanup(); + thd->transaction->cleanup(); MYSQL_COMMIT_TRANSACTION(thd->m_transaction_psi); thd->m_transaction_psi= NULL; } @@ -1649,7 +1649,7 @@ int ha_commit_trans(THD *thd, bool all) // Here, the call will not commit inside InnoDB. It is only working // around closing thd->transaction.stmt open by TR_table::open(). if (all) - commit_one_phase_2(thd, false, &thd->transaction.stmt, false); + commit_one_phase_2(thd, false, &thd->transaction->stmt, false); } } #endif @@ -1710,11 +1710,11 @@ int ha_commit_trans(THD *thd, bool all) goto done; } - DBUG_ASSERT(thd->transaction.implicit_xid.get_my_xid() == - thd->transaction.implicit_xid.quick_get_my_xid()); - DBUG_ASSERT(!thd->transaction.xid_state.is_explicit_XA() || + DBUG_ASSERT(thd->transaction->implicit_xid.get_my_xid() == + thd->transaction->implicit_xid.quick_get_my_xid()); + DBUG_ASSERT(!thd->transaction->xid_state.is_explicit_XA() || thd->lex->xa_opt == XA_ONE_PHASE); - xid= thd->transaction.implicit_xid.quick_get_my_xid(); + xid= thd->transaction->implicit_xid.quick_get_my_xid(); #ifdef WITH_WSREP if (run_wsrep_hooks && !error) @@ -1845,7 +1845,7 @@ end: int ha_commit_one_phase(THD *thd, bool all) { - THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; + THD_TRANS *trans=all ? &thd->transaction->all : &thd->transaction->stmt; /* "real" is a nick name for a transaction for which a commit will make persistent changes. E.g. a 'stmt' transaction inside a 'all' @@ -1859,7 +1859,7 @@ int ha_commit_one_phase(THD *thd, bool all) ha_commit_one_phase() can be called with an empty transaction.all.ha_list, see why in trans_register_ha()). */ - bool is_real_trans= ((all || thd->transaction.all.ha_list == 0) && + bool is_real_trans= ((all || thd->transaction->all.ha_list == 0) && !(thd->variables.option_bits & OPTION_GTID_BEGIN)); int res; DBUG_ENTER("ha_commit_one_phase"); @@ -1906,8 +1906,8 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) if (all) { #ifdef HAVE_QUERY_CACHE - if (thd->transaction.changed_tables) - query_cache.invalidate(thd, thd->transaction.changed_tables); + if (thd->transaction->changed_tables) + query_cache.invalidate(thd, thd->transaction->changed_tables); #endif } } @@ -1915,7 +1915,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) if (is_real_trans) { thd->has_waiter= false; - thd->transaction.cleanup(); + thd->transaction->cleanup(); if (count >= 2) statistic_increment(transactions_multi_engine, LOCK_status); } @@ -1927,7 +1927,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans) int ha_rollback_trans(THD *thd, bool all) { int error=0; - THD_TRANS *trans=all ? &thd->transaction.all : &thd->transaction.stmt; + THD_TRANS *trans=all ? &thd->transaction->all : &thd->transaction->stmt; Ha_trx_info *ha_info= trans->ha_list, *ha_info_next; /* "real" is a nick name for a transaction for which a commit will @@ -1942,15 +1942,15 @@ int ha_rollback_trans(THD *thd, bool all) ha_commit_one_phase() is called with an empty transaction.all.ha_list, see why in trans_register_ha()). */ - bool is_real_trans=all || thd->transaction.all.ha_list == 0; + bool is_real_trans=all || thd->transaction->all.ha_list == 0; DBUG_ENTER("ha_rollback_trans"); /* We must not rollback the normal transaction if a statement transaction is pending. */ - DBUG_ASSERT(thd->transaction.stmt.ha_list == NULL || - trans == &thd->transaction.stmt); + DBUG_ASSERT(thd->transaction->stmt.ha_list == NULL || + trans == &thd->transaction->stmt); #ifdef HAVE_REPLICATION if (is_real_trans) @@ -1967,7 +1967,7 @@ int ha_rollback_trans(THD *thd, bool all) builds, we explicitly do the signalling before rolling back. */ DBUG_ASSERT(!(thd->rgi_slave && thd->rgi_slave->did_mark_start_commit) || - thd->transaction.xid_state.is_explicit_XA()); + thd->transaction->xid_state.is_explicit_XA()); if (thd->rgi_slave && thd->rgi_slave->did_mark_start_commit) thd->rgi_slave->unmark_start_commit(); } @@ -2042,10 +2042,10 @@ int ha_rollback_trans(THD *thd, bool all) transaction hasn't been started in any transactional storage engine. */ if (thd->transaction_rollback_request) - thd->transaction.xid_state.set_error(thd->get_stmt_da()->sql_errno()); + thd->transaction->xid_state.set_error(thd->get_stmt_da()->sql_errno()); thd->has_waiter= false; - thd->transaction.cleanup(); + thd->transaction->cleanup(); } if (all) thd->transaction_rollback_request= FALSE; @@ -2063,7 +2063,7 @@ int ha_rollback_trans(THD *thd, bool all) it doesn't matter if a warning is pushed to a system thread or not: No one will see it... */ - if (is_real_trans && thd->transaction.all.modified_non_trans_table && + if (is_real_trans && thd->transaction->all.modified_non_trans_table && !thd->slave_thread && thd->killed < KILL_CONNECTION) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, @@ -2405,8 +2405,8 @@ commit_checkpoint_notify_ha(handlerton *hton, void *cookie) bool ha_rollback_to_savepoint_can_release_mdl(THD *thd) { Ha_trx_info *ha_info; - THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : - &thd->transaction.all); + THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction->stmt : + &thd->transaction->all); DBUG_ENTER("ha_rollback_to_savepoint_can_release_mdl"); @@ -2430,8 +2430,8 @@ bool ha_rollback_to_savepoint_can_release_mdl(THD *thd) int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv) { int error=0; - THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : - &thd->transaction.all); + THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction->stmt : + &thd->transaction->all); Ha_trx_info *ha_info, *ha_info_next; DBUG_ENTER("ha_rollback_to_savepoint"); @@ -2516,8 +2516,8 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv) } #endif /* WITH_WSREP */ int error=0; - THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction.stmt : - &thd->transaction.all); + THD_TRANS *trans= (thd->in_sub_stmt ? &thd->transaction->stmt : + &thd->transaction->all); Ha_trx_info *ha_info= trans->ha_list; DBUG_ENTER("ha_savepoint"); @@ -5021,7 +5021,7 @@ int ha_enable_transaction(THD *thd, bool on) DBUG_ENTER("ha_enable_transaction"); DBUG_PRINT("enter", ("on: %d", (int) on)); - if ((thd->transaction.on= on)) + if ((thd->transaction->on= on)) { /* Now all storage engines should have transaction handling enabled. diff --git a/sql/log.cc b/sql/log.cc index 138d1a654f2..85ea8f9d663 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1774,7 +1774,7 @@ binlog_flush_cache(THD *thd, binlog_cache_mngr *cache_mngr, if ((using_stmt && !cache_mngr->stmt_cache.empty()) || (using_trx && !cache_mngr->trx_cache.empty()) || - thd->transaction.xid_state.is_explicit_XA()) + thd->transaction->xid_state.is_explicit_XA()) { if (using_stmt && thd->binlog_flush_pending_rows_event(TRUE, FALSE)) DBUG_RETURN(1); @@ -1879,11 +1879,11 @@ binlog_commit_flush_trx_cache(THD *thd, bool all, binlog_cache_mngr *cache_mngr) if (thd->lex->sql_command == SQLCOM_XA_COMMIT && thd->lex->xa_opt != XA_ONE_PHASE) { - DBUG_ASSERT(thd->transaction.xid_state.is_explicit_XA()); - DBUG_ASSERT(thd->transaction.xid_state.get_state_code() == + DBUG_ASSERT(thd->transaction->xid_state.is_explicit_XA()); + DBUG_ASSERT(thd->transaction->xid_state.get_state_code() == XA_PREPARED); - buflen= serialize_with_xid(thd->transaction.xid_state.get_xid(), + buflen= serialize_with_xid(thd->transaction->xid_state.get_xid(), buf, query, q_len); } Query_log_event end_evt(thd, buf, buflen, TRUE, TRUE, TRUE, 0); @@ -1910,11 +1910,11 @@ binlog_rollback_flush_trx_cache(THD *thd, bool all, char buf[q_len + ser_buf_size]= "ROLLBACK"; size_t buflen= sizeof("ROLLBACK") - 1; - if (thd->transaction.xid_state.is_explicit_XA()) + if (thd->transaction->xid_state.is_explicit_XA()) { /* for not prepared use plain ROLLBACK */ - if (thd->transaction.xid_state.get_state_code() == XA_PREPARED) - buflen= serialize_with_xid(thd->transaction.xid_state.get_xid(), + if (thd->transaction->xid_state.get_state_code() == XA_PREPARED) + buflen= serialize_with_xid(thd->transaction->xid_state.get_xid(), buf, query, q_len); } Query_log_event end_evt(thd, buf, buflen, TRUE, TRUE, TRUE, 0); @@ -1999,7 +1999,7 @@ binlog_truncate_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr, bool all) inline bool is_preparing_xa(THD *thd) { return - thd->transaction.xid_state.is_explicit_XA() && + thd->transaction->xid_state.is_explicit_XA() && thd->lex->sql_command == SQLCOM_XA_PREPARE; } @@ -2039,15 +2039,15 @@ static int binlog_rollback_by_xid(handlerton *hton, XID *xid) (void) thd->binlog_setup_trx_data(); DBUG_ASSERT(thd->lex->sql_command == SQLCOM_XA_ROLLBACK || - (thd->transaction.xid_state.get_state_code() == XA_ROLLBACK_ONLY)); + (thd->transaction->xid_state.get_state_code() == XA_ROLLBACK_ONLY)); return binlog_rollback(hton, thd, TRUE); } inline bool is_prepared_xa(THD *thd) { - return thd->transaction.xid_state.is_explicit_XA() && - thd->transaction.xid_state.get_state_code() == XA_PREPARED; + return thd->transaction->xid_state.is_explicit_XA() && + thd->transaction->xid_state.get_state_code() == XA_PREPARED; } @@ -2084,7 +2084,7 @@ static bool trans_cannot_safely_rollback(THD *thd, bool all) static int binlog_commit_flush_xa_prepare(THD *thd, bool all, binlog_cache_mngr *cache_mngr) { - XID *xid= thd->transaction.xid_state.get_xid(); + XID *xid= thd->transaction->xid_state.get_xid(); { // todo assert wsrep_simulate || is_open() @@ -2155,8 +2155,8 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) ("all: %d, in_transaction: %s, all.modified_non_trans_table: %s, stmt.modified_non_trans_table: %s", all, YESNO(thd->in_multi_stmt_transaction_mode()), - YESNO(thd->transaction.all.modified_non_trans_table), - YESNO(thd->transaction.stmt.modified_non_trans_table))); + YESNO(thd->transaction->all.modified_non_trans_table), + YESNO(thd->transaction->stmt.modified_non_trans_table))); thd->backup_stage(&org_stage); @@ -2167,7 +2167,7 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) } if (cache_mngr->trx_cache.empty() && - thd->transaction.xid_state.get_state_code() != XA_PREPARED) + thd->transaction->xid_state.get_state_code() != XA_PREPARED) { /* we're here because cache_log was flushed in MYSQL_BIN_LOG::log_xid() @@ -2227,8 +2227,8 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) DBUG_PRINT("debug", ("all: %s, all.modified_non_trans_table: %s, stmt.modified_non_trans_table: %s", YESNO(all), - YESNO(thd->transaction.all.modified_non_trans_table), - YESNO(thd->transaction.stmt.modified_non_trans_table))); + YESNO(thd->transaction->all.modified_non_trans_table), + YESNO(thd->transaction->stmt.modified_non_trans_table))); /* If an incident event is set we do not flush the content of the statement @@ -2245,7 +2245,7 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) } if (cache_mngr->trx_cache.empty() && - thd->transaction.xid_state.get_state_code() != XA_PREPARED) + thd->transaction->xid_state.get_state_code() != XA_PREPARED) { /* we're here because cache_log was flushed in MYSQL_BIN_LOG::log_xid() @@ -5618,7 +5618,7 @@ stmt_has_updated_trans_table(const THD *thd) { Ha_trx_info *ha_info; - for (ha_info= thd->transaction.stmt.ha_list; ha_info; + for (ha_info= thd->transaction->stmt.ha_list; ha_info; ha_info= ha_info->next()) { if (ha_info->is_trx_read_write() && ha_info->ht() != binlog_hton) @@ -5697,8 +5697,8 @@ bool ending_single_stmt_trans(THD* thd, const bool all) */ bool trans_has_updated_non_trans_table(const THD* thd) { - return (thd->transaction.all.modified_non_trans_table || - thd->transaction.stmt.modified_non_trans_table); + return (thd->transaction->all.modified_non_trans_table || + thd->transaction->stmt.modified_non_trans_table); } /** @@ -5711,7 +5711,7 @@ bool trans_has_updated_non_trans_table(const THD* thd) */ bool stmt_has_updated_non_trans_table(const THD* thd) { - return (thd->transaction.stmt.modified_non_trans_table); + return (thd->transaction->stmt.modified_non_trans_table); } /* @@ -7581,7 +7581,7 @@ MYSQL_BIN_LOG::write_transaction_to_binlog(THD *thd, entry.using_stmt_cache= using_stmt_cache; entry.using_trx_cache= using_trx_cache; entry.need_unlog= is_preparing_xa(thd); - ha_info= all ? thd->transaction.all.ha_list : thd->transaction.stmt.ha_list; + ha_info= all ? thd->transaction->all.ha_list : thd->transaction->stmt.ha_list; for (; !entry.need_unlog && ha_info; ha_info= ha_info->next()) { @@ -8158,7 +8158,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) */ DBUG_ASSERT(!cache_mngr->stmt_cache.empty() || !cache_mngr->trx_cache.empty() || - current->thd->transaction.xid_state.is_explicit_XA()); + current->thd->transaction->xid_state.is_explicit_XA()); if (unlikely((current->error= write_transaction_or_stmt(current, commit_id)))) @@ -9108,7 +9108,7 @@ void TC_LOG::run_prepare_ordered(THD *thd, bool all) { Ha_trx_info *ha_info= - all ? thd->transaction.all.ha_list : thd->transaction.stmt.ha_list; + all ? thd->transaction->all.ha_list : thd->transaction->stmt.ha_list; mysql_mutex_assert_owner(&LOCK_prepare_ordered); for (; ha_info; ha_info= ha_info->next()) @@ -9125,7 +9125,7 @@ void TC_LOG::run_commit_ordered(THD *thd, bool all) { Ha_trx_info *ha_info= - all ? thd->transaction.all.ha_list : thd->transaction.stmt.ha_list; + all ? thd->transaction->all.ha_list : thd->transaction->stmt.ha_list; mysql_mutex_assert_owner(&LOCK_commit_ordered); for (; ha_info; ha_info= ha_info->next()) @@ -10129,7 +10129,7 @@ int TC_LOG_BINLOG::unlog_xa_prepare(THD *thd, bool all) { /* an empty XA-prepare event group is logged */ #ifndef DBUG_OFF - for (ha_info= thd->transaction.all.ha_list; rw_count > 1 && ha_info; + for (ha_info= thd->transaction->all.ha_list; rw_count > 1 && ha_info; ha_info= ha_info->next()) DBUG_ASSERT(ha_info->ht() != binlog_hton); #endif diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index b6c626e7735..124fb10d4ea 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -2045,7 +2045,7 @@ compare_errors: DBUG_EXECUTE_IF("stop_slave_middle_group", if (!current_stmt_is_commit && is_begin() == 0) { - if (thd->transaction.all.modified_non_trans_table) + if (thd->transaction->all.modified_non_trans_table) const_cast(rli)->abort_slave= 1; };); } @@ -2366,7 +2366,7 @@ int Format_description_log_event::do_apply_event(rpl_group_info *rgi) original place when it comes to us; we'll know this by checking log_pos ("artificial" events have log_pos == 0). */ - if (!is_artificial_event() && created && thd->transaction.all.ha_list) + if (!is_artificial_event() && created && thd->transaction->all.ha_list) { /* This is not an error (XA is safe), just an information */ rli->report(INFORMATION_LEVEL, 0, NULL, @@ -3238,13 +3238,13 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, { cache_type= Log_event::EVENT_NO_CACHE; bool is_tmp_table= thd_arg->lex->stmt_accessed_temp_table(); - if (thd_arg->transaction.stmt.trans_did_wait() || - thd_arg->transaction.all.trans_did_wait()) + if (thd_arg->transaction->stmt.trans_did_wait() || + thd_arg->transaction->all.trans_did_wait()) flags2|= FL_WAITED; - if (thd_arg->transaction.stmt.trans_did_ddl() || - thd_arg->transaction.stmt.has_created_dropped_temp_table() || - thd_arg->transaction.all.trans_did_ddl() || - thd_arg->transaction.all.has_created_dropped_temp_table()) + if (thd_arg->transaction->stmt.trans_did_ddl() || + thd_arg->transaction->stmt.has_created_dropped_temp_table() || + thd_arg->transaction->all.trans_did_ddl() || + thd_arg->transaction->all.has_created_dropped_temp_table()) flags2|= FL_DDL; else if (is_transactional && !is_tmp_table) flags2|= FL_TRANSACTIONAL; @@ -3254,7 +3254,7 @@ Gtid_log_event::Gtid_log_event(THD *thd_arg, uint64 seq_no_arg, if (thd_arg->rgi_slave) flags2|= (thd_arg->rgi_slave->gtid_ev_flags2 & (FL_DDL|FL_WAITED)); - XID_STATE &xid_state= thd->transaction.xid_state; + XID_STATE &xid_state= thd->transaction->xid_state; if (is_transactional && xid_state.is_explicit_XA() && (thd->lex->sql_command == SQLCOM_XA_PREPARE || xid_state.get_state_code() == XA_PREPARED)) @@ -3925,7 +3925,7 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) sub_id= rgi->gtid_sub_id; gtid= rgi->current_gtid; - if (!thd->transaction.xid_state.is_explicit_XA()) + if (!thd->transaction->xid_state.is_explicit_XA()) { if ((err= do_record_gtid(thd, rgi, true /* in_trans */, &hton))) return err; @@ -3945,7 +3945,7 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) res= do_commit(); if (!res && rgi->gtid_pending) { - DBUG_ASSERT(!thd->transaction.xid_state.is_explicit_XA()); + DBUG_ASSERT(!thd->transaction->xid_state.is_explicit_XA()); if ((err= do_record_gtid(thd, rgi, false, &hton))) return err; @@ -3964,7 +3964,7 @@ int Xid_apply_log_event::do_apply_event(rpl_group_info *rgi) /* Increment the global status commit count variable */ - enum enum_sql_command cmd= !thd->transaction.xid_state.is_explicit_XA() ? + enum enum_sql_command cmd= !thd->transaction->xid_state.is_explicit_XA() ? SQLCOM_COMMIT : SQLCOM_XA_PREPARE; status_var_increment(thd->status_var.com_stat[cmd]); @@ -5337,8 +5337,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) has not yet modified anything. Note, all.modified is reset by THD::reset_for_next_command(). */ - thd->transaction.stmt.modified_non_trans_table= FALSE; - thd->transaction.stmt.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; + thd->transaction->stmt.modified_non_trans_table= FALSE; + thd->transaction->stmt.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; /* This is a row injection, so we flag the "statement" as such. Note that this code is called both when the slave does row @@ -5699,8 +5699,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) m_curr_row= m_curr_row_end; if (likely(error == 0) && !transactional_table) - thd->transaction.all.modified_non_trans_table= - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->all.modified_non_trans_table= + thd->transaction->stmt.modified_non_trans_table= TRUE; } // row processing loop while (error == 0 && (m_curr_row != m_rows_end)); @@ -5716,7 +5716,7 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) to shutdown trying to finish incomplete events group. */ DBUG_EXECUTE_IF("stop_slave_middle_group", - if (thd->transaction.all.modified_non_trans_table) + if (thd->transaction->all.modified_non_trans_table) const_cast(rli)->abort_slave= 1;); } @@ -5869,8 +5869,8 @@ static int rows_event_stmt_cleanup(rpl_group_info *rgi, THD * thd) */ if (!thd->in_multi_stmt_transaction_mode()) { - thd->transaction.all.modified_non_trans_table= 0; - thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; + thd->transaction->all.modified_non_trans_table= 0; + thd->transaction->all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; } rgi->cleanup_context(thd, 0); diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc index c5f765f9cda..af0c4747d2b 100644 --- a/sql/rpl_gtid.cc +++ b/sql/rpl_gtid.cc @@ -507,7 +507,7 @@ rpl_slave_state::select_gtid_pos_table(THD *thd, LEX_CSTRING *out_tablename) Ha_trx_info *ha_info; uint count = 0; - for (ha_info= thd->transaction.all.ha_list; ha_info; ha_info= ha_info->next()) + for (ha_info= thd->transaction->all.ha_list; ha_info; ha_info= ha_info->next()) { void *trx_hton= ha_info->ht(); auto table_entry= list; diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 1a0147f7d8d..fbda0f57f74 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -2232,7 +2232,7 @@ void rpl_group_info::cleanup_context(THD *thd, bool error) trans_rollback above does not rollback XA transactions (todo/fixme consider to do so. */ - if (thd->transaction.xid_state.is_explicit_XA()) + if (thd->transaction->xid_state.is_explicit_XA()) xa_trans_force_rollback(thd); thd->mdl_context.release_transactional_locks(); diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index 79634d142eb..2480eebf8d7 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -682,7 +682,7 @@ int Repl_semi_sync_master::wait_after_commit(THD* thd, bool all) my_off_t log_pos; bool is_real_trans= - (all || thd->transaction.all.ha_list == 0); + (all || thd->transaction->all.ha_list == 0); /* The coordinates are propagated to this point having been computed in report_binlog_update diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc index fb68ec44a91..129d909c045 100644 --- a/sql/session_tracker.cc +++ b/sql/session_tracker.cc @@ -741,7 +741,7 @@ bool Transaction_state_tracker::store(THD *thd, String *buf) if ((thd->variables.session_track_transaction_info == TX_TRACK_CHISTICS) && (tx_changed & TX_CHG_CHISTICS)) { - bool is_xa= thd->transaction.xid_state.is_explicit_XA(); + bool is_xa= thd->transaction->xid_state.is_explicit_XA(); size_t start; /* 2 length by 1 byte and code */ @@ -918,7 +918,7 @@ bool Transaction_state_tracker::store(THD *thd, String *buf) if ((tx_curr_state & TX_EXPLICIT) && is_xa) { - XID *xid= thd->transaction.xid_state.get_xid(); + XID *xid= thd->transaction->xid_state.get_xid(); long glen, blen; buf->append(STRING_WITH_LEN("XA START")); diff --git a/sql/slave.cc b/sql/slave.cc index 9b9400bd7bc..1902a3681a5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1535,7 +1535,7 @@ static bool sql_slave_killed(rpl_group_info *rgi) rli->is_in_group(). */ - if ((thd->transaction.all.modified_non_trans_table || + if ((thd->transaction->all.modified_non_trans_table || (thd->variables.option_bits & OPTION_KEEP_LOG)) && rli->is_in_group()) { @@ -1549,7 +1549,7 @@ static bool sql_slave_killed(rpl_group_info *rgi) DBUG_PRINT("info", ("modified_non_trans_table: %d OPTION_BEGIN: %d " "OPTION_KEEP_LOG: %d is_in_group: %d", - thd->transaction.all.modified_non_trans_table, + thd->transaction->all.modified_non_trans_table, MY_TEST(thd->variables.option_bits & OPTION_BEGIN), MY_TEST(thd->variables.option_bits & OPTION_KEEP_LOG), rli->is_in_group())); @@ -4386,7 +4386,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, (LOG_EVENT_IS_QUERY(typ) && strcmp("COMMIT", ((Query_log_event *) ev)->query) == 0)) { - DBUG_ASSERT(thd->transaction.all.modified_non_trans_table); + DBUG_ASSERT(thd->transaction->all.modified_non_trans_table); rli->abort_slave= 1; mysql_mutex_unlock(&rli->data_lock); delete ev; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index e61164e8e40..ce28e926a86 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3426,8 +3426,8 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, It's reset further in the common code part. It's merged with the saved parent's value at the exit of this func. */ - bool parent_modified_non_trans_table= thd->transaction.stmt.modified_non_trans_table; - thd->transaction.stmt.modified_non_trans_table= FALSE; + bool parent_modified_non_trans_table= thd->transaction->stmt.modified_non_trans_table; + thd->transaction->stmt.modified_non_trans_table= FALSE; DBUG_ASSERT(!thd->derived_tables); DBUG_ASSERT(thd->Item_change_list::is_empty()); /* @@ -3550,7 +3550,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, Merge here with the saved parent's values what is needed from the substatement gained */ - thd->transaction.stmt.modified_non_trans_table |= parent_modified_non_trans_table; + thd->transaction->stmt.modified_non_trans_table |= parent_modified_non_trans_table; TRANSACT_TRACKER(add_trx_state_from_thd(thd)); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 3413b3787bd..6078b9a2e5d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -793,7 +793,7 @@ int close_thread_tables(THD *thd) DEBUG_SYNC(thd, "before_close_thread_tables"); #endif - DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt || + DBUG_ASSERT(thd->transaction->stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)); for (table= thd->open_tables; table; table= table->next) @@ -2351,7 +2351,7 @@ Locked_tables_list::unlock_locked_tables(THD *thd) TRANSACT_TRACKER(clear_trx_state(thd, TX_LOCKED_TABLES)); - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); error= close_thread_tables(thd); /* @@ -4117,7 +4117,7 @@ bool open_tables(THD *thd, const DDL_options_st &options, DBUG_ENTER("open_tables"); /* Data access in XA transaction is only allowed when it is active. */ - if (*start && thd->transaction.xid_state.check_has_uncommitted_xa()) + if (*start && thd->transaction->xid_state.check_has_uncommitted_xa()) DBUG_RETURN(true); thd->current_tablenr= 0; @@ -5186,7 +5186,7 @@ end: table on the fly, and thus mustn't manipulate with the transaction of the enclosing statement. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty() || + DBUG_ASSERT(thd->transaction->stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)); close_thread_tables(thd); /* Don't keep locks for a failed statement. */ @@ -5583,7 +5583,7 @@ void close_tables_for_reopen(THD *thd, TABLE_LIST **tables, table on the fly, and thus mustn't manipulate with the transaction of the enclosing statement. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty() || + DBUG_ASSERT(thd->transaction->stmt.is_empty() || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)); close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(start_of_statement_svp); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 7a3e25c422b..dda8e00f6bf 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -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; diff --git a/sql/sql_class.h b/sql/sql_class.h index 1069b49790a..d4a95fa3fd8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2733,6 +2733,10 @@ public: free_root(&mem_root,MYF(MY_KEEP_PREALLOC)); DBUG_VOID_RETURN; } + void free() + { + free_root(&mem_root,MYF(0)); + } my_bool is_active() { return (all.ha_list != NULL); @@ -2744,7 +2748,7 @@ public: init_sql_alloc(key_memory_thd_transactions, &mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0, MYF(MY_THREAD_SPECIFIC)); } - } transaction; + } default_transaction, *transaction; Global_read_lock global_read_lock; Field *dup_field; #ifndef __WIN__ @@ -3582,8 +3586,8 @@ public: timeval transaction_time() { if (!in_multi_stmt_transaction_mode()) - transaction.start_time.reset(this); - return transaction.start_time; + transaction->start_time.reset(this); + return transaction->start_time; } inline void set_start_time() @@ -3756,7 +3760,7 @@ public: } inline void* trans_alloc(size_t size) { - return alloc_root(&transaction.mem_root,size); + return alloc_root(&transaction->mem_root,size); } LEX_CSTRING strmake_lex_cstring(const char *str, size_t length) @@ -4172,7 +4176,7 @@ public: inline bool really_abort_on_warning() { return (abort_on_warning && - (!transaction.stmt.modified_non_trans_table || + (!transaction->stmt.modified_non_trans_table || (variables.sql_mode & MODE_STRICT_ALL_TABLES))); } void set_status_var_init(); @@ -4838,9 +4842,9 @@ public: if (!wsrep_xid.is_null()) return &wsrep_xid; #endif /* WITH_WSREP */ - return transaction.xid_state.is_explicit_XA() ? - transaction.xid_state.get_xid() : - &transaction.implicit_xid; + return (transaction->xid_state.is_explicit_XA() ? + transaction->xid_state.get_xid() : + &transaction->implicit_xid); } /* Members related to temporary tables. */ @@ -5084,10 +5088,10 @@ public: /* Copy relevant `stmt` transaction flags to `all` transaction. */ void merge_unsafe_rollback_flags() { - if (transaction.stmt.modified_non_trans_table) - transaction.all.modified_non_trans_table= TRUE; - transaction.all.m_unsafe_rollback_flags|= - (transaction.stmt.m_unsafe_rollback_flags & + if (transaction->stmt.modified_non_trans_table) + transaction->all.modified_non_trans_table= TRUE; + transaction->all.m_unsafe_rollback_flags|= + (transaction->stmt.m_unsafe_rollback_flags & (THD_TRANS::DID_WAIT | THD_TRANS::CREATED_TEMP_TABLE | THD_TRANS::DROPPED_TEMP_TABLE | THD_TRANS::DID_DDL)); } @@ -5097,7 +5101,7 @@ public: { if (in_active_multi_stmt_transaction()) { - if (transaction.all.is_trx_read_write()) + if (transaction->all.is_trx_read_write()) { if (variables.idle_write_transaction_timeout > 0) return variables.idle_write_transaction_timeout; @@ -7284,13 +7288,13 @@ class Sp_eval_expr_state { m_thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; m_thd->abort_on_warning= m_thd->is_strict_mode(); - m_thd->transaction.stmt.modified_non_trans_table= false; + m_thd->transaction->stmt.modified_non_trans_table= false; } void stop() { m_thd->count_cuted_fields= m_count_cuted_fields; m_thd->abort_on_warning= m_abort_on_warning; - m_thd->transaction.stmt.modified_non_trans_table= + m_thd->transaction->stmt.modified_non_trans_table= m_stmt_modified_non_trans_table; } public: @@ -7298,7 +7302,7 @@ public: :m_thd(thd), m_count_cuted_fields(thd->count_cuted_fields), m_abort_on_warning(thd->abort_on_warning), - m_stmt_modified_non_trans_table(thd->transaction.stmt. + m_stmt_modified_non_trans_table(thd->transaction->stmt. modified_non_trans_table) { start(); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 039ed417078..071fd2ab8ac 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -878,11 +878,11 @@ cleanup: transactional_table= table->file->has_transactions(); if (!transactional_table && deleted > 0) - thd->transaction.stmt.modified_non_trans_table= - thd->transaction.all.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= + thd->transaction->all.modified_non_trans_table= TRUE; /* See similar binlogging code in sql_update.cc, for comments */ - if (likely((error < 0) || thd->transaction.stmt.modified_non_trans_table)) + if (likely((error < 0) || thd->transaction->stmt.modified_non_trans_table)) { if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { @@ -911,7 +911,7 @@ cleanup: } } } - DBUG_ASSERT(transactional_table || !deleted || thd->transaction.stmt.modified_non_trans_table); + DBUG_ASSERT(transactional_table || !deleted || thd->transaction->stmt.modified_non_trans_table); if (likely(error < 0) || (thd->lex->ignore && !thd->is_error() && !thd->is_fatal_error)) @@ -1332,7 +1332,7 @@ int multi_delete::send_data(List &values) { deleted++; if (!table->file->has_transactions()) - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, FALSE)) @@ -1368,17 +1368,17 @@ void multi_delete::abort_result_set() /* the error was handled or nothing deleted and no side effects return */ if (error_handled || - (!thd->transaction.stmt.modified_non_trans_table && !deleted)) + (!thd->transaction->stmt.modified_non_trans_table && !deleted)) DBUG_VOID_RETURN; /* Something already deleted so we have to invalidate cache */ if (deleted) query_cache_invalidate3(thd, delete_tables, 1); - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); /* If rows from the first table only has been deleted and it is @@ -1400,7 +1400,7 @@ void multi_delete::abort_result_set() DBUG_VOID_RETURN; } - if (thd->transaction.stmt.modified_non_trans_table) + if (thd->transaction->stmt.modified_non_trans_table) { /* there is only side effects; to binlog with the error @@ -1538,7 +1538,7 @@ int multi_delete::do_table_deletes(TABLE *table, SORT_INFO *sort_info, } } if (last_deleted != deleted && !table->file->has_transactions()) - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; end_read_record(&info); @@ -1566,10 +1566,10 @@ bool multi_delete::send_eof() /* reset used flags */ THD_STAGE_INFO(thd, stage_end); - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); /* We must invalidate the query cache before binlog writing and @@ -1580,7 +1580,7 @@ bool multi_delete::send_eof() query_cache_invalidate3(thd, delete_tables, 1); } if (likely((local_error == 0) || - thd->transaction.stmt.modified_non_trans_table)) + thd->transaction->stmt.modified_non_trans_table)) { if(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index e3e08444f84..a6f93f6dfee 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -480,7 +480,7 @@ err: If called with reopen flag, no need to rollback either, it will be done at statement end. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(mdl_savepoint); thd->set_open_tables(backup_open_tables); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 0914b4ac497..2b1f10a7cd2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1156,13 +1156,13 @@ values_loop_end: query_cache_invalidate3(thd, table_list, 1); } - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); if (error <= 0 || - thd->transaction.stmt.modified_non_trans_table || + thd->transaction->stmt.modified_non_trans_table || was_insert_delayed) { if(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) @@ -1225,7 +1225,7 @@ values_loop_end: } } DBUG_ASSERT(transactional_table || !changed || - thd->transaction.stmt.modified_non_trans_table); + thd->transaction->stmt.modified_non_trans_table); } THD_STAGE_INFO(thd, stage_end); /* @@ -2056,7 +2056,7 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, select_result *sink) else info->updated++; if (!table->file->has_transactions()) - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; if (table->triggers && table->triggers->process_triggers(thd, TRG_EVENT_DELETE, TRG_ACTION_AFTER, TRUE)) @@ -2122,7 +2122,7 @@ after_trg_or_ignored_err: if (key) my_safe_afree(key,table->s->max_unique_length); if (!table->file->has_transactions()) - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; DBUG_RETURN(trg_error); err: @@ -4139,13 +4139,13 @@ bool select_insert::prepare_eof() query_cache_invalidate3(thd, table, 1); } - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); DBUG_ASSERT(trans_table || !changed || - thd->transaction.stmt.modified_non_trans_table); + thd->transaction->stmt.modified_non_trans_table); /* Write to binlog before commiting transaction. No statement will @@ -4154,7 +4154,7 @@ bool select_insert::prepare_eof() ha_autocommit_or_rollback() is issued below. */ if ((WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) && - (likely(!error) || thd->transaction.stmt.modified_non_trans_table)) + (likely(!error) || thd->transaction->stmt.modified_non_trans_table)) { int errcode= 0; int res; @@ -4274,11 +4274,11 @@ void select_insert::abort_result_set() */ changed= (info.copied || info.deleted || info.updated); transactional_table= table->file->has_transactions(); - if (thd->transaction.stmt.modified_non_trans_table || + if (thd->transaction->stmt.modified_non_trans_table || thd->log_current_statement) { if (!can_rollback_data()) - thd->transaction.all.modified_non_trans_table= TRUE; + thd->transaction->all.modified_non_trans_table= TRUE; if(WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { @@ -4294,7 +4294,7 @@ void select_insert::abort_result_set() query_cache_invalidate3(thd, table, 1); } DBUG_ASSERT(transactional_table || !changed || - thd->transaction.stmt.modified_non_trans_table); + thd->transaction->stmt.modified_non_trans_table); table->s->table_creation_was_logged|= binary_logged; table->file->ha_release_auto_increment(); @@ -4874,7 +4874,7 @@ bool select_create::send_eof() mark the flag at this point. */ if (table->s->tmp_table) - thd->transaction.stmt.mark_created_temp_table(); + thd->transaction->stmt.mark_created_temp_table(); if (thd->slave_thread) thd->variables.binlog_annotate_row_events= 0; @@ -5039,7 +5039,7 @@ void select_create::abort_result_set() save_option_bits= thd->variables.option_bits; thd->variables.option_bits&= ~OPTION_BIN_LOG; select_insert::abort_result_set(); - thd->transaction.stmt.modified_non_trans_table= FALSE; + thd->transaction->stmt.modified_non_trans_table= FALSE; thd->variables.option_bits= save_option_bits; /* possible error of writing binary log is ignored deliberately */ diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 3ce37170b48..8cff557962c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -739,7 +739,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, /* since there is already an error, the possible error of writing binary log will be ignored */ - if (thd->transaction.stmt.modified_non_trans_table) + if (thd->transaction->stmt.modified_non_trans_table) (void) write_execute_load_query_log_event(thd, ex, table_list->db.str, table_list->table_name.str, @@ -764,10 +764,10 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, (ulong) (info.records - info.copied), (long) thd->get_stmt_da()->current_statement_warn_count()); - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); #ifndef EMBEDDED_LIBRARY if (mysql_bin_log.is_open()) { @@ -816,7 +816,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, my_ok(thd, info.copied + info.deleted, 0L, name); err: DBUG_ASSERT(transactional_table || !(info.copied || info.deleted) || - thd->transaction.stmt.modified_non_trans_table); + thd->transaction->stmt.modified_non_trans_table); table->file->ha_release_auto_increment(); table->auto_increment_field_not_null= FALSE; thd->abort_on_warning= 0; @@ -1300,7 +1300,7 @@ read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, We don't need to reset auto-increment field since we are restoring its default value at the beginning of each loop iteration. */ - thd->transaction.stmt.modified_non_trans_table= no_trans_update_stmt; + thd->transaction->stmt.modified_non_trans_table= no_trans_update_stmt; thd->get_stmt_da()->inc_current_row_for_warning(); continue_loop:; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5922584c8c1..18ccc830816 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1104,7 +1104,7 @@ int bootstrap(MYSQL_FILE *file) thd->reset_kill_query(); /* Ensure that killed_errmsg is released */ free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); - free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC)); + thd->transaction->free(); thd->lex->restore_set_statement_var(); } delete thd; @@ -2118,7 +2118,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, mysqld_list_fields(thd,&table_list,fields); thd->lex->unit.cleanup(); /* No need to rollback statement transaction, it's not started. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(mdl_savepoint); @@ -3177,7 +3177,7 @@ mysql_create_routine(THD *thd, LEX *lex) creation of routine and implicit GRANT parts of one fully atomic statement. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); close_thread_tables(thd); /* Check if the definer exists on slave, @@ -3398,7 +3398,7 @@ mysql_execute_command(THD *thd) DBUG_RETURN(1); } - DBUG_ASSERT(thd->transaction.stmt.is_empty() || thd->in_sub_stmt); + DBUG_ASSERT(thd->transaction->stmt.is_empty() || thd->in_sub_stmt); /* Each statement or replication event which might produce deadlock should handle transaction rollback on its own. So by the start of @@ -3625,7 +3625,7 @@ mysql_execute_command(THD *thd) thd->progress.report_to_client= MY_TEST(sql_command_flags[lex->sql_command] & CF_REPORT_PROGRESS); - DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table == FALSE); + DBUG_ASSERT(thd->transaction->stmt.modified_non_trans_table == FALSE); /* store old value of binlog format */ enum_binlog_format orig_binlog_format,orig_current_stmt_binlog_format; @@ -3782,7 +3782,7 @@ mysql_execute_command(THD *thd) */ DBUG_ASSERT(! thd->in_sub_stmt); /* Statement transaction still should not be started. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) { /* Commit the normal transaction if one is active. */ @@ -3796,7 +3796,7 @@ mysql_execute_command(THD *thd) goto error; } } - thd->transaction.stmt.mark_trans_did_ddl(); + thd->transaction->stmt.mark_trans_did_ddl(); #ifdef WITH_WSREP /* Clean up the previous transaction on implicit commit */ if (wsrep_thd_is_local(thd) && wsrep_after_statement(thd)) @@ -6578,7 +6578,7 @@ drop_routine(THD *thd, LEX *lex) dropping of routine and implicit REVOKE parts of one fully atomic statement. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); close_thread_tables(thd); if (sp_result != SP_KEY_NOT_FOUND && @@ -7581,7 +7581,7 @@ void THD::reset_for_next_command(bool do_clear_error) if (!in_multi_stmt_transaction_mode()) { variables.option_bits&= ~OPTION_KEEP_LOG; - transaction.all.reset(); + transaction->all.reset(); } DBUG_ASSERT(security_ctx== &main_security_ctx); thread_specific_used= FALSE; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 98ffc842196..6dbdfe75767 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -4087,7 +4087,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) lex->unit.cleanup(); /* No need to commit statement transaction, it's not started. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); close_thread_tables(thd); thd->mdl_context.rollback_to_savepoint(mdl_savepoint); diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index f41221e11de..45bc519816a 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -437,7 +437,7 @@ int SEQUENCE::read_initial_values(TABLE *table) MYSQL_LOCK *lock; bool mdl_lock_used= 0; THD *thd= table->in_use; - bool has_active_transaction= !thd->transaction.stmt.is_empty(); + bool has_active_transaction= !thd->transaction->stmt.is_empty(); /* There is already a mdl_ticket for this table. However, for list_fields the MDL lock is of type MDL_SHARED_HIGH_PRIO which is not usable @@ -490,7 +490,7 @@ int SEQUENCE::read_initial_values(TABLE *table) But we also don't want to commit the stmt transaction while in a substatement, see MDEV-15977. */ - if (!has_active_transaction && !thd->transaction.stmt.is_empty() && + if (!has_active_transaction && !thd->transaction->stmt.is_empty() && !thd->in_sub_stmt) trans_commit_stmt(thd); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index afc397850d4..c90b8699b80 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2616,7 +2616,7 @@ err: trans_tmp_table_deleted || non_tmp_table_deleted) { if (non_trans_tmp_table_deleted || trans_tmp_table_deleted) - thd->transaction.stmt.mark_dropped_temp_table(); + thd->transaction->stmt.mark_dropped_temp_table(); query_cache_invalidate3(thd, tables, 0); if (!dont_log_query && mysql_bin_log.is_open()) @@ -5391,7 +5391,7 @@ err: } if (create_info->tmp_table()) - thd->transaction.stmt.mark_created_temp_table(); + thd->transaction->stmt.mark_created_temp_table(); /* Write log if no error or if we already deleted a table */ if (likely(!result) || thd->log_current_statement) @@ -6009,7 +6009,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, res, create_info->tmp_table(), local_create_info.table)); if (create_info->tmp_table()) { - thd->transaction.stmt.mark_created_temp_table(); + thd->transaction->stmt.mark_created_temp_table(); if (!res && local_create_info.table) { /* @@ -10931,7 +10931,7 @@ bool mysql_trans_commit_alter_copy_data(THD *thd) DBUG_ENTER("mysql_trans_commit_alter_copy_data"); /* Save flags as trans_commit_implicit are deleting them */ - save_unsafe_rollback_flags= thd->transaction.stmt.m_unsafe_rollback_flags; + save_unsafe_rollback_flags= thd->transaction->stmt.m_unsafe_rollback_flags; DEBUG_SYNC(thd, "alter_table_copy_trans_commit"); @@ -10949,7 +10949,7 @@ bool mysql_trans_commit_alter_copy_data(THD *thd) if (trans_commit_implicit(thd)) error= TRUE; - thd->transaction.stmt.m_unsafe_rollback_flags= save_unsafe_rollback_flags; + thd->transaction->stmt.m_unsafe_rollback_flags= save_unsafe_rollback_flags; DBUG_RETURN(error); } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8e6eb4c815a..43f33184fe3 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1227,7 +1227,7 @@ update_end: table->file->try_semi_consistent_read(0); if (!transactional_table && updated > 0) - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; end_read_record(&info); delete select; @@ -1246,10 +1246,10 @@ update_end: query_cache_invalidate3(thd, table_list, 1); } - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); /* error < 0 means really no error at all: we processed all rows until the @@ -1260,7 +1260,7 @@ update_end: Sometimes we want to binlog even if we updated no rows, in case user used it to be sure master and slave are in same state. */ - if (likely(error < 0) || thd->transaction.stmt.modified_non_trans_table) + if (likely(error < 0) || thd->transaction->stmt.modified_non_trans_table) { if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { @@ -1281,7 +1281,7 @@ update_end: } } } - DBUG_ASSERT(transactional_table || !updated || thd->transaction.stmt.modified_non_trans_table); + DBUG_ASSERT(transactional_table || !updated || thd->transaction->stmt.modified_non_trans_table); free_underlaid_joins(thd, select_lex); delete file_sort; if (table->file->pushed_cond) @@ -2452,7 +2452,7 @@ multi_update::~multi_update() delete [] copy_field; thd->count_cuted_fields= CHECK_FIELD_IGNORE; // Restore this setting DBUG_ASSERT(trans_safe || !updated || - thd->transaction.all.modified_non_trans_table); + thd->transaction->all.modified_non_trans_table); } @@ -2577,7 +2577,7 @@ int multi_update::send_data(List ¬_used_values) else { trans_safe= FALSE; - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; } } } @@ -2632,7 +2632,7 @@ void multi_update::abort_result_set() { /* the error was handled or nothing deleted and no side effects return */ if (unlikely(error_handled || - (!thd->transaction.stmt.modified_non_trans_table && !updated))) + (!thd->transaction->stmt.modified_non_trans_table && !updated))) return; /* Something already updated so we have to invalidate cache */ @@ -2645,14 +2645,14 @@ void multi_update::abort_result_set() if (! trans_safe) { - DBUG_ASSERT(thd->transaction.stmt.modified_non_trans_table); + DBUG_ASSERT(thd->transaction->stmt.modified_non_trans_table); if (do_update && table_count > 1) { /* Add warning here */ (void) do_updates(); } } - if (thd->transaction.stmt.modified_non_trans_table) + if (thd->transaction->stmt.modified_non_trans_table) { /* The query has to binlog because there's a modified non-transactional table @@ -2671,11 +2671,11 @@ void multi_update::abort_result_set() thd->query(), thd->query_length(), transactional_tables, FALSE, FALSE, errcode); } - thd->transaction.all.modified_non_trans_table= TRUE; + thd->transaction->all.modified_non_trans_table= TRUE; } - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); - DBUG_ASSERT(trans_safe || !updated || thd->transaction.stmt.modified_non_trans_table); + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + DBUG_ASSERT(trans_safe || !updated || thd->transaction->stmt.modified_non_trans_table); } @@ -2896,7 +2896,7 @@ int multi_update::do_updates() else { trans_safe= FALSE; // Can't do safe rollback - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; } } (void) table->file->ha_rnd_end(); @@ -2933,7 +2933,7 @@ err2: else { trans_safe= FALSE; - thd->transaction.stmt.modified_non_trans_table= TRUE; + thd->transaction->stmt.modified_non_trans_table= TRUE; } } DBUG_RETURN(1); @@ -2980,13 +2980,13 @@ bool multi_update::send_eof() either from the query's list or via a stored routine: bug#13270,23333 */ - if (thd->transaction.stmt.modified_non_trans_table) - thd->transaction.all.modified_non_trans_table= TRUE; - thd->transaction.all.m_unsafe_rollback_flags|= - (thd->transaction.stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); + if (thd->transaction->stmt.modified_non_trans_table) + thd->transaction->all.modified_non_trans_table= TRUE; + thd->transaction->all.m_unsafe_rollback_flags|= + (thd->transaction->stmt.m_unsafe_rollback_flags & THD_TRANS::DID_WAIT); if (likely(local_error == 0 || - thd->transaction.stmt.modified_non_trans_table)) + thd->transaction->stmt.modified_non_trans_table)) { if (WSREP_EMULATE_BINLOG(thd) || mysql_bin_log.is_open()) { @@ -3018,7 +3018,7 @@ bool multi_update::send_eof() } } DBUG_ASSERT(trans_safe || !updated || - thd->transaction.stmt.modified_non_trans_table); + thd->transaction->stmt.modified_non_trans_table); if (likely(local_error != 0)) error_handled= TRUE; // to force early leave from ::abort_result_set() diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index df6f9933e36..6fe1bfc732a 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2999,7 +2999,7 @@ static Sys_var_charptr_fscs Sys_tmpdir( static bool fix_trans_mem_root(sys_var *self, THD *thd, enum_var_type type) { if (type != OPT_GLOBAL) - reset_root_defaults(&thd->transaction.mem_root, + reset_root_defaults(&thd->transaction->mem_root, thd->variables.trans_alloc_block_size, thd->variables.trans_prealloc_size); return false; @@ -4326,8 +4326,8 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type) thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_NOT_AUTOCOMMIT | OPTION_GTID_BEGIN); - thd->transaction.all.modified_non_trans_table= false; - thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; + thd->transaction->all.modified_non_trans_table= false; + thd->transaction->all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; thd->server_status|= SERVER_STATUS_AUTOCOMMIT; return false; } @@ -4336,8 +4336,8 @@ static bool fix_autocommit(sys_var *self, THD *thd, enum_var_type type) (OPTION_AUTOCOMMIT |OPTION_NOT_AUTOCOMMIT)) == 0) { // disabling autocommit - thd->transaction.all.modified_non_trans_table= false; - thd->transaction.all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; + thd->transaction->all.modified_non_trans_table= false; + thd->transaction->all.m_unsafe_rollback_flags&= ~THD_TRANS::DID_WAIT; thd->server_status&= ~SERVER_STATUS_AUTOCOMMIT; thd->variables.option_bits|= OPTION_NOT_AUTOCOMMIT; return false; diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index ef6f1c42434..521b9c8973f 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1402,7 +1402,7 @@ bool THD::log_events_and_free_tmp_shares() variables.character_set_client= cs_save; get_stmt_da()->set_overwrite_status(true); - transaction.stmt.mark_dropped_temp_table(); + transaction->stmt.mark_dropped_temp_table(); bool error2= mysql_bin_log.write(&qinfo); if (unlikely(error|= error2)) { diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 50cc9aa43f2..83a599a01dd 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -162,7 +162,7 @@ static TP_PRIORITY get_priority(TP_connection *c) DBUG_ASSERT(c->thd == current_thd); TP_PRIORITY prio= (TP_PRIORITY)c->thd->variables.threadpool_priority; if (prio == TP_PRIORITY_AUTO) - prio= c->thd->transaction.is_active() ? TP_PRIORITY_HIGH : TP_PRIORITY_LOW; + prio= c->thd->transaction->is_active() ? TP_PRIORITY_HIGH : TP_PRIORITY_LOW; return prio; } diff --git a/sql/transaction.cc b/sql/transaction.cc index c9fd211c1f8..23d6ba1ecba 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -69,12 +69,12 @@ static bool trans_check(THD *thd) Always commit statement transaction before manipulating with the normal one. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty()); + DBUG_ASSERT(thd->transaction->stmt.is_empty()); if (unlikely(thd->in_sub_stmt)) my_error(ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG, MYF(0)); - if (thd->transaction.xid_state.is_explicit_XA()) - thd->transaction.xid_state.er_xaer_rmfail(); + if (thd->transaction->xid_state.is_explicit_XA()) + thd->transaction->xid_state.er_xaer_rmfail(); else DBUG_RETURN(FALSE); @@ -130,10 +130,10 @@ bool trans_begin(THD *thd, uint flags) The following set should not be needed as transaction state should already be reset. We should at some point change this to an assert. */ - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->has_waiter= false; thd->waiting_on_group_commit= false; - thd->transaction.start_time.reset(thd); + thd->transaction->start_time.reset(thd); if (res) DBUG_RETURN(TRUE); @@ -272,7 +272,7 @@ bool trans_commit(THD *thd) repl_semisync_master.wait_after_commit(thd, FALSE); #endif thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG); - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->lex->start_transaction_opt= 0; /* The transaction should be marked as complete in P_S. */ @@ -321,7 +321,7 @@ bool trans_commit_implicit(THD *thd) } thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG); - thd->transaction.all.reset(); + thd->transaction->all.reset(); /* The transaction should be marked as complete in P_S. */ DBUG_ASSERT(thd->m_transaction_psi == NULL); @@ -367,7 +367,7 @@ bool trans_rollback(THD *thd) /* Reset the binlog transaction marker */ thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_GTID_BEGIN); - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->lex->start_transaction_opt= 0; /* The transaction should be marked as complete in P_S. */ @@ -405,7 +405,7 @@ bool trans_rollback_implicit(THD *thd) Don't perform rollback in the middle of sub-statement, wait till its end. */ - DBUG_ASSERT(thd->transaction.stmt.is_empty() && !thd->in_sub_stmt); + DBUG_ASSERT(thd->transaction->stmt.is_empty() && !thd->in_sub_stmt); thd->server_status&= ~SERVER_STATUS_IN_TRANS; DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); @@ -416,7 +416,7 @@ bool trans_rollback_implicit(THD *thd) preserve backward compatibility. */ thd->variables.option_bits&= ~(OPTION_KEEP_LOG); - thd->transaction.all.reset(); + thd->transaction->all.reset(); /* Rollback should clear transaction_rollback_request flag. */ DBUG_ASSERT(!thd->transaction_rollback_request); @@ -458,7 +458,7 @@ bool trans_commit_stmt(THD *thd) thd->merge_unsafe_rollback_flags(); - if (thd->transaction.stmt.ha_list) + if (thd->transaction->stmt.ha_list) { res= ha_commit_trans(thd, FALSE); if (! thd->in_active_multi_stmt_transaction()) @@ -493,7 +493,7 @@ bool trans_commit_stmt(THD *thd) DBUG_ASSERT(thd->in_active_multi_stmt_transaction() || thd->m_transaction_psi == NULL); - thd->transaction.stmt.reset(); + thd->transaction->stmt.reset(); DBUG_RETURN(MY_TEST(res)); } @@ -521,7 +521,7 @@ bool trans_rollback_stmt(THD *thd) thd->merge_unsafe_rollback_flags(); - if (thd->transaction.stmt.ha_list) + if (thd->transaction->stmt.ha_list) { ha_rollback_trans(thd, FALSE); if (! thd->in_active_multi_stmt_transaction()) @@ -536,7 +536,7 @@ bool trans_rollback_stmt(THD *thd) DBUG_ASSERT(thd->in_active_multi_stmt_transaction() || thd->m_transaction_psi == NULL); - thd->transaction.stmt.reset(); + thd->transaction->stmt.reset(); DBUG_RETURN(FALSE); } @@ -545,7 +545,7 @@ bool trans_rollback_stmt(THD *thd) static SAVEPOINT ** find_savepoint(THD *thd, LEX_CSTRING name) { - SAVEPOINT **sv= &thd->transaction.savepoints; + SAVEPOINT **sv= &thd->transaction->savepoints; while (*sv) { @@ -579,7 +579,7 @@ bool trans_savepoint(THD *thd, LEX_CSTRING name) !opt_using_transactions) DBUG_RETURN(FALSE); - if (thd->transaction.xid_state.check_has_uncommitted_xa()) + if (thd->transaction->xid_state.check_has_uncommitted_xa()) DBUG_RETURN(TRUE); sv= find_savepoint(thd, name); @@ -590,14 +590,14 @@ bool trans_savepoint(THD *thd, LEX_CSTRING name) ha_release_savepoint(thd, *sv); *sv= (*sv)->prev; } - else if ((newsv= (SAVEPOINT *) alloc_root(&thd->transaction.mem_root, + else if ((newsv= (SAVEPOINT *) alloc_root(&thd->transaction->mem_root, savepoint_alloc_size)) == NULL) { my_error(ER_OUT_OF_RESOURCES, MYF(0)); DBUG_RETURN(TRUE); } - newsv->name= strmake_root(&thd->transaction.mem_root, name.str, name.length); + newsv->name= strmake_root(&thd->transaction->mem_root, name.str, name.length); newsv->length= (uint)name.length; /* @@ -608,8 +608,8 @@ bool trans_savepoint(THD *thd, LEX_CSTRING name) if (unlikely(ha_savepoint(thd, newsv))) DBUG_RETURN(TRUE); - newsv->prev= thd->transaction.savepoints; - thd->transaction.savepoints= newsv; + newsv->prev= thd->transaction->savepoints; + thd->transaction->savepoints= newsv; /* Remember locks acquired before the savepoint was set. @@ -655,7 +655,7 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name) DBUG_RETURN(TRUE); } - if (thd->transaction.xid_state.check_has_uncommitted_xa()) + if (thd->transaction->xid_state.check_has_uncommitted_xa()) DBUG_RETURN(TRUE); /** @@ -688,13 +688,13 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_CSTRING name) if (ha_rollback_to_savepoint(thd, sv)) res= TRUE; else if (((thd->variables.option_bits & OPTION_KEEP_LOG) || - thd->transaction.all.modified_non_trans_table) && + thd->transaction->all.modified_non_trans_table) && !thd->slave_thread) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, ER_WARNING_NOT_COMPLETE_ROLLBACK, ER_THD(thd, ER_WARNING_NOT_COMPLETE_ROLLBACK)); - thd->transaction.savepoints= sv; + thd->transaction->savepoints= sv; if (!res && mdl_can_safely_rollback_to_savepoint) thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint); @@ -732,7 +732,7 @@ bool trans_release_savepoint(THD *thd, LEX_CSTRING name) if (ha_release_savepoint(thd, sv)) res= TRUE; - thd->transaction.savepoints= sv->prev; + thd->transaction->savepoints= sv->prev; DBUG_RETURN(MY_TEST(res)); } diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 25a4e22aeb4..4005de22e72 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -191,7 +191,7 @@ int wsrep_apply_events(THD* thd, /* Use the original server id for logging. */ thd->set_server_id(ev->server_id); thd->set_time(); // time the query - thd->transaction.start_time.reset(thd); + thd->transaction->start_time.reset(thd); thd->lex->current_select= 0; if (!ev->when) { diff --git a/sql/wsrep_trans_observer.h b/sql/wsrep_trans_observer.h index 55bb7462d99..39256c3df9f 100644 --- a/sql/wsrep_trans_observer.h +++ b/sql/wsrep_trans_observer.h @@ -82,7 +82,7 @@ static inline bool wsrep_not_committed(THD* thd) */ static inline bool wsrep_is_real(THD* thd, bool all) { - return (all || thd->transaction.all.ha_list == 0); + return (all || thd->transaction->all.ha_list == 0); } /* diff --git a/sql/xa.cc b/sql/xa.cc index 69e9fd70af6..68e6e67fa0b 100644 --- a/sql/xa.cc +++ b/sql/xa.cc @@ -397,11 +397,11 @@ bool xa_trans_force_rollback(THD *thd) } thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG | OPTION_GTID_BEGIN); - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->server_status&= ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); - xid_cache_delete(thd, &thd->transaction.xid_state); + xid_cache_delete(thd, &thd->transaction->xid_state); trans_track_end_trx(thd); @@ -422,17 +422,17 @@ bool trans_xa_start(THD *thd) { DBUG_ENTER("trans_xa_start"); - if (thd->transaction.xid_state.is_explicit_XA() && - thd->transaction.xid_state.xid_cache_element->xa_state == XA_IDLE && + if (thd->transaction->xid_state.is_explicit_XA() && + thd->transaction->xid_state.xid_cache_element->xa_state == XA_IDLE && thd->lex->xa_opt == XA_RESUME) { bool not_equal= - !thd->transaction.xid_state.xid_cache_element->xid.eq(thd->lex->xid); + !thd->transaction->xid_state.xid_cache_element->xid.eq(thd->lex->xid); if (not_equal) my_error(ER_XAER_NOTA, MYF(0)); else { - thd->transaction.xid_state.xid_cache_element->xa_state= XA_ACTIVE; + thd->transaction->xid_state.xid_cache_element->xa_state= XA_ACTIVE; MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_ACTIVE); } DBUG_RETURN(not_equal); @@ -443,14 +443,14 @@ bool trans_xa_start(THD *thd) my_error(ER_XAER_INVAL, MYF(0)); else if (!thd->lex->xid->gtrid_length) my_error(ER_XAER_INVAL, MYF(0)); - else if (thd->transaction.xid_state.is_explicit_XA()) - thd->transaction.xid_state.er_xaer_rmfail(); + else if (thd->transaction->xid_state.is_explicit_XA()) + thd->transaction->xid_state.er_xaer_rmfail(); else if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction()) my_error(ER_XAER_OUTSIDE, MYF(0)); else if (!trans_begin(thd)) { MYSQL_SET_TRANSACTION_XID(thd->m_transaction_psi, thd->lex->xid, XA_ACTIVE); - if (xid_cache_insert(thd, &thd->transaction.xid_state, thd->lex->xid)) + if (xid_cache_insert(thd, &thd->transaction->xid_state, thd->lex->xid)) { trans_rollback(thd); DBUG_RETURN(true); @@ -478,19 +478,19 @@ bool trans_xa_end(THD *thd) /* TODO: SUSPEND and FOR MIGRATE are not supported yet. */ if (thd->lex->xa_opt != XA_NONE) my_error(ER_XAER_INVAL, MYF(0)); - else if (!thd->transaction.xid_state.is_explicit_XA() || - thd->transaction.xid_state.xid_cache_element->xa_state != XA_ACTIVE) - thd->transaction.xid_state.er_xaer_rmfail(); - else if (!thd->transaction.xid_state.xid_cache_element->xid.eq(thd->lex->xid)) + else if (!thd->transaction->xid_state.is_explicit_XA() || + thd->transaction->xid_state.xid_cache_element->xa_state != XA_ACTIVE) + thd->transaction->xid_state.er_xaer_rmfail(); + else if (!thd->transaction->xid_state.xid_cache_element->xid.eq(thd->lex->xid)) my_error(ER_XAER_NOTA, MYF(0)); - else if (!xa_trans_rolled_back(thd->transaction.xid_state.xid_cache_element)) + else if (!xa_trans_rolled_back(thd->transaction->xid_state.xid_cache_element)) { - thd->transaction.xid_state.xid_cache_element->xa_state= XA_IDLE; + thd->transaction->xid_state.xid_cache_element->xa_state= XA_IDLE; MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_IDLE); } DBUG_RETURN(thd->is_error() || - thd->transaction.xid_state.xid_cache_element->xa_state != XA_IDLE); + thd->transaction->xid_state.xid_cache_element->xa_state != XA_IDLE); } @@ -509,10 +509,10 @@ bool trans_xa_prepare(THD *thd) DBUG_ENTER("trans_xa_prepare"); - if (!thd->transaction.xid_state.is_explicit_XA() || - thd->transaction.xid_state.xid_cache_element->xa_state != XA_IDLE) - thd->transaction.xid_state.er_xaer_rmfail(); - else if (!thd->transaction.xid_state.xid_cache_element->xid.eq(thd->lex->xid)) + if (!thd->transaction->xid_state.is_explicit_XA() || + thd->transaction->xid_state.xid_cache_element->xa_state != XA_IDLE) + thd->transaction->xid_state.er_xaer_rmfail(); + else if (!thd->transaction->xid_state.xid_cache_element->xid.eq(thd->lex->xid)) my_error(ER_XAER_NOTA, MYF(0)); else { @@ -533,15 +533,15 @@ bool trans_xa_prepare(THD *thd) if (!mdl_request.ticket) ha_rollback_trans(thd, TRUE); thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG); - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->server_status&= ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); - xid_cache_delete(thd, &thd->transaction.xid_state); + xid_cache_delete(thd, &thd->transaction->xid_state); my_error(ER_XA_RBROLLBACK, MYF(0)); } else { - thd->transaction.xid_state.xid_cache_element->xa_state= XA_PREPARED; + thd->transaction->xid_state.xid_cache_element->xa_state= XA_PREPARED; MYSQL_SET_TRANSACTION_XA_STATE(thd->m_transaction_psi, XA_PREPARED); res= thd->variables.pseudo_slave_mode || thd->slave_thread ? slave_applier_reset_xa_trans(thd) : 0; @@ -564,7 +564,7 @@ bool trans_xa_prepare(THD *thd) bool trans_xa_commit(THD *thd) { bool res= true; - XID_STATE &xid_state= thd->transaction.xid_state; + XID_STATE &xid_state= thd->transaction->xid_state; DBUG_ENTER("trans_xa_commit"); @@ -655,7 +655,7 @@ bool trans_xa_commit(THD *thd) if ((res= MY_TEST(r))) my_error(r == 1 ? ER_XA_RBROLLBACK : ER_XAER_RMERR, MYF(0)); } - else if (thd->transaction.xid_state.xid_cache_element->xa_state == XA_PREPARED) + else if (thd->transaction->xid_state.xid_cache_element->xa_state == XA_PREPARED) { MDL_request mdl_request; if (thd->lex->xa_opt != XA_NONE) @@ -710,7 +710,7 @@ bool trans_xa_commit(THD *thd) } thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG); - thd->transaction.all.reset(); + thd->transaction->all.reset(); thd->server_status&= ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); @@ -734,7 +734,7 @@ bool trans_xa_commit(THD *thd) bool trans_xa_rollback(THD *thd) { - XID_STATE &xid_state= thd->transaction.xid_state; + XID_STATE &xid_state= thd->transaction->xid_state; DBUG_ENTER("trans_xa_rollback"); @@ -817,22 +817,22 @@ bool trans_xa_rollback(THD *thd) bool trans_xa_detach(THD *thd) { - DBUG_ASSERT(thd->transaction.xid_state.is_explicit_XA()); + DBUG_ASSERT(thd->transaction->xid_state.is_explicit_XA()); - if (thd->transaction.xid_state.xid_cache_element->xa_state != XA_PREPARED) + if (thd->transaction->xid_state.xid_cache_element->xa_state != XA_PREPARED) return xa_trans_force_rollback(thd); - else if (!thd->transaction.all.is_trx_read_write()) + else if (!thd->transaction->all.is_trx_read_write()) { - thd->transaction.xid_state.set_error(ER_XA_RBROLLBACK); + thd->transaction->xid_state.set_error(ER_XA_RBROLLBACK); ha_rollback_trans(thd, true); } - thd->transaction.xid_state.xid_cache_element->acquired_to_recovered(); - thd->transaction.xid_state.xid_cache_element= 0; - thd->transaction.cleanup(); + thd->transaction->xid_state.xid_cache_element->acquired_to_recovered(); + thd->transaction->xid_state.xid_cache_element= 0; + thd->transaction->cleanup(); Ha_trx_info *ha_info, *ha_info_next; - for (ha_info= thd->transaction.all.ha_list; + for (ha_info= thd->transaction->all.ha_list; ha_info; ha_info= ha_info_next) { @@ -840,8 +840,8 @@ bool trans_xa_detach(THD *thd) ha_info->reset(); /* keep it conveniently zero-filled */ } - thd->transaction.all.ha_list= 0; - thd->transaction.all.no_2pc= 0; + thd->transaction->all.ha_list= 0; + thd->transaction->all.no_2pc= 0; return false; } @@ -1055,23 +1055,23 @@ static bool slave_applier_reset_xa_trans(THD *thd) ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); - thd->transaction.xid_state.xid_cache_element->acquired_to_recovered(); - thd->transaction.xid_state.xid_cache_element= 0; + thd->transaction->xid_state.xid_cache_element->acquired_to_recovered(); + thd->transaction->xid_state.xid_cache_element= 0; - for (Ha_trx_info *ha_info= thd->transaction.all.ha_list, *ha_info_next; + for (Ha_trx_info *ha_info= thd->transaction->all.ha_list, *ha_info_next; ha_info; ha_info= ha_info_next) { ha_info_next= ha_info->next(); ha_info->reset(); } - thd->transaction.all.ha_list= 0; + thd->transaction->all.ha_list= 0; ha_close_connection(thd); - thd->transaction.cleanup(); - thd->transaction.all.reset(); + thd->transaction->cleanup(); + thd->transaction->all.reset(); - DBUG_ASSERT(!thd->transaction.all.ha_list); - DBUG_ASSERT(!thd->transaction.all.no_2pc); + DBUG_ASSERT(!thd->transaction->all.ha_list); + DBUG_ASSERT(!thd->transaction->all.no_2pc); thd->has_waiter= false; MYSQL_COMMIT_TRANSACTION(thd->m_transaction_psi); // TODO/Fixme: commit? diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index f55cef922c9..eae99ace9ee 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -959,7 +959,7 @@ static int maria_create_trn_for_mysql(MARIA_HA *info) if (!trn) /* no transaction yet - open it now */ { - trn= trnman_new_trn(& thd->transaction.wt); + trn= trnman_new_trn(& thd->transaction->wt); if (unlikely(!trn)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); thd_set_ha_data(thd, maria_hton, trn); @@ -2772,7 +2772,7 @@ int ha_maria::external_lock(THD *thd, int lock_type) trnman_increment_locked_tables(file->trn); } - if (!thd->transaction.on) + if (!thd->transaction->on) { /* No need to log REDOs/UNDOs. If this is an internal temporary table @@ -2983,7 +2983,7 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn) tables may be under LOCK TABLES, and so they will start the next 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_set_ha_data(thd, maria_hton, trn); if (unlikely(trn == NULL)) { diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc index 657e81671ee..a84dd680f85 100644 --- a/storage/spider/spd_db_conn.cc +++ b/storage/spider/spd_db_conn.cc @@ -10219,7 +10219,7 @@ int spider_db_udf_direct_sql( need_trx_end = TRUE; } else { #endif - if (c_thd->transaction.stmt.ha_list) + if (c_thd->transaction->stmt.ha_list) need_trx_end = FALSE; else need_trx_end = TRUE; diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc index 406d189fcc9..0f1f2fad27a 100644 --- a/storage/spider/spd_direct_sql.cc +++ b/storage/spider/spd_direct_sql.cc @@ -1813,7 +1813,7 @@ long long spider_direct_sql_body( if (conn->bg_init) pthread_mutex_unlock(&conn->bg_conn_mutex); if (direct_sql->modified_non_trans_table) - thd->transaction.stmt.modified_non_trans_table = TRUE; + thd->transaction->stmt.modified_non_trans_table = TRUE; if (error_num == HA_ERR_OUT_OF_MEM) my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); goto error; @@ -1821,7 +1821,7 @@ long long spider_direct_sql_body( if (conn->bg_init) pthread_mutex_unlock(&conn->bg_conn_mutex); if (direct_sql->modified_non_trans_table) - thd->transaction.stmt.modified_non_trans_table = TRUE; + thd->transaction->stmt.modified_non_trans_table = TRUE; #ifndef WITHOUT_SPIDER_BG_SEARCH } if (!bg) @@ -1930,7 +1930,7 @@ void spider_direct_sql_deinit_body( if (bg_direct_sql->modified_non_trans_table) { THD *thd = current_thd; - thd->transaction.stmt.modified_non_trans_table = TRUE; + thd->transaction->stmt.modified_non_trans_table = TRUE; } pthread_cond_destroy(&bg_direct_sql->bg_cond); pthread_mutex_destroy(&bg_direct_sql->bg_mutex); @@ -1961,7 +1961,7 @@ long long spider_direct_sql_bg_end( pthread_cond_wait(&bg_direct_sql->bg_cond, &bg_direct_sql->bg_mutex); pthread_mutex_unlock(&bg_direct_sql->bg_mutex); if (bg_direct_sql->modified_non_trans_table) - thd->transaction.stmt.modified_non_trans_table = TRUE; + thd->transaction->stmt.modified_non_trans_table = TRUE; if (bg_direct_sql->bg_error) { my_message(bg_direct_sql->bg_error, bg_direct_sql->bg_error_msg, MYF(0)); diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc index f7565eda2c9..0e6d81e28f1 100644 --- a/storage/spider/spd_trx.cc +++ b/storage/spider/spd_trx.cc @@ -1939,7 +1939,7 @@ int spider_internal_start_trx( if (!trx->trx_start) { if ( - thd->transaction.xid_state.is_explicit_XA() && + thd->transaction->xid_state.is_explicit_XA() && spider_param_support_xa() ) { trx->trx_xa = TRUE; -- cgit v1.2.1