diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2021-11-05 20:35:45 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2021-11-05 20:35:45 +0100 |
commit | 109fc67d4da46d52d2a96528eaea3b0ef6275692 (patch) | |
tree | 8d5f52c188eab272508e02a83ead266e50529608 /sql | |
parent | 9b967c4c31555174a293922d4717d83b7d68bc76 (diff) | |
parent | 8635be6a2962f8e256c27836c35064ccaabb7486 (diff) | |
download | mariadb-git-109fc67d4da46d52d2a96528eaea3b0ef6275692.tar.gz |
Merge branch '10.5' into 10.6mariadb-10.6.5
Diffstat (limited to 'sql')
-rw-r--r-- | sql/handler.h | 12 | ||||
-rw-r--r-- | sql/log.cc | 37 | ||||
-rw-r--r-- | sql/sp_head.cc | 8 | ||||
-rw-r--r-- | sql/sql_class.h | 3 |
4 files changed, 31 insertions, 29 deletions
diff --git a/sql/handler.h b/sql/handler.h index 75a15ed4c6a..0cdaf1dd698 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1946,9 +1946,13 @@ struct THD_TRANS /* Define the type of statements which cannot be rolled back safely. Each type occupies one bit in m_unsafe_rollback_flags. + MODIFIED_NON_TRANS_TABLE is limited to mark only the temporary + non-transactional table *when* it's cached along with the transactional + events; the regular table is covered by the "namesake" bool var. */ enum unsafe_statement_types { + MODIFIED_NON_TRANS_TABLE= 1, CREATED_TEMP_TABLE= 2, DROPPED_TEMP_TABLE= 4, DID_WAIT= 8, @@ -1956,6 +1960,14 @@ struct THD_TRANS EXECUTED_TABLE_ADMIN_CMD= 0x20 }; + void mark_modified_non_trans_temp_table() + { + m_unsafe_rollback_flags|= MODIFIED_NON_TRANS_TABLE; + } + bool has_modified_non_trans_temp_table() const + { + return (m_unsafe_rollback_flags & MODIFIED_NON_TRANS_TABLE) != 0; + } void mark_executed_table_admin_cmd() { DBUG_PRINT("debug", ("mark_executed_table_admin_cmd")); diff --git a/sql/log.cc b/sql/log.cc index b372af823d6..41eed80ef66 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -275,7 +275,7 @@ class binlog_cache_data public: binlog_cache_data(): m_pending(0), status(0), before_stmt_pos(MY_OFF_T_UNDEF), - incident(FALSE), changes_to_non_trans_temp_table_flag(FALSE), + incident(FALSE), saved_max_binlog_cache_size(0), ptr_binlog_cache_use(0), ptr_binlog_cache_disk_use(0) { } @@ -324,16 +324,6 @@ public: return(incident); } - void set_changes_to_non_trans_temp_table() - { - changes_to_non_trans_temp_table_flag= TRUE; - } - - bool changes_to_non_trans_temp_table() - { - return (changes_to_non_trans_temp_table_flag); - } - void reset() { bool cache_was_empty= empty(); @@ -345,7 +335,6 @@ public: if (truncate_file) my_chsize(cache_log.file, 0, 0, MYF(MY_WME)); - changes_to_non_trans_temp_table_flag= FALSE; status= 0; incident= FALSE; before_stmt_pos= MY_OFF_T_UNDEF; @@ -444,12 +433,6 @@ private: */ bool incident; - /* - This flag indicates if the cache has changes to temporary tables. - @TODO This a temporary fix and should be removed after BUG#54562. - */ - bool changes_to_non_trans_temp_table_flag; - /** This function computes binlog cache and disk usage. */ @@ -2062,13 +2045,12 @@ inline bool is_prepared_xa(THD *thd) */ static bool trans_cannot_safely_rollback(THD *thd, bool all) { - binlog_cache_mngr *const cache_mngr= - (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton); + DBUG_ASSERT(ending_trans(thd, all)); return ((thd->variables.option_bits & OPTION_KEEP_LOG) || (trans_has_updated_non_trans_table(thd) && thd->wsrep_binlog_format() == BINLOG_FORMAT_STMT) || - (cache_mngr->trx_cache.changes_to_non_trans_temp_table() && + (thd->transaction->all.has_modified_non_trans_temp_table() && thd->wsrep_binlog_format() == BINLOG_FORMAT_MIXED) || (trans_has_updated_non_trans_table(thd) && ending_single_stmt_trans(thd,all) && @@ -2287,17 +2269,19 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all) /* Truncate the cache if: . aborting a single or multi-statement transaction or; - . the OPTION_KEEP_LOG is not active and; + . the current statement created or dropped a temporary table + while having actual STATEMENT format; . the format is not STMT or no non-trans table was updated and; . the format is not MIXED or no temporary non-trans table was updated. */ else if (ending_trans(thd, all) || - (!(thd->variables.option_bits & OPTION_KEEP_LOG) && + (!(thd->transaction->stmt.has_created_dropped_temp_table() && + !thd->is_current_stmt_binlog_format_row()) && (!stmt_has_updated_non_trans_table(thd) || thd->wsrep_binlog_format() != BINLOG_FORMAT_STMT) && - (!cache_mngr->trx_cache.changes_to_non_trans_temp_table() || + (!thd->transaction->stmt.has_modified_non_trans_temp_table() || thd->wsrep_binlog_format() != BINLOG_FORMAT_MIXED))) error= binlog_truncate_trx_cache(thd, cache_mngr, all); } @@ -6640,9 +6624,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate) cache_data= cache_mngr->get_binlog_cache_data(is_trans_cache); file= &cache_data->cache_log; - if (thd->lex->stmt_accessed_non_trans_temp_table()) - cache_data->set_changes_to_non_trans_temp_table(); - + if (thd->lex->stmt_accessed_non_trans_temp_table() && is_trans_cache) + thd->transaction->stmt.mark_modified_non_trans_temp_table(); thd->binlog_start_trans_and_stmt(); } DBUG_PRINT("info",("event type: %d",event_info->get_type_code())); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index d1cf5c2d9bd..641c88de826 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -3438,8 +3438,13 @@ 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; + bool parent_modified_non_trans_table= + thd->transaction->stmt.modified_non_trans_table; + unsigned int parent_unsafe_rollback_flags= + thd->transaction->stmt.m_unsafe_rollback_flags; thd->transaction->stmt.modified_non_trans_table= FALSE; + thd->transaction->stmt.m_unsafe_rollback_flags= 0; + DBUG_ASSERT(!thd->derived_tables); DBUG_ASSERT(thd->Item_change_list::is_empty()); /* @@ -3562,6 +3567,7 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp, what is needed from the substatement gained */ thd->transaction->stmt.modified_non_trans_table |= parent_modified_non_trans_table; + thd->transaction->stmt.m_unsafe_rollback_flags |= parent_unsafe_rollback_flags; TRANSACT_TRACKER(add_trx_state_from_thd(thd)); diff --git a/sql/sql_class.h b/sql/sql_class.h index b5874d2435a..0f1dfdeb6f6 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5412,7 +5412,8 @@ public: 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::MODIFIED_NON_TRANS_TABLE | + THD_TRANS::DID_WAIT | THD_TRANS::CREATED_TEMP_TABLE | THD_TRANS::DROPPED_TEMP_TABLE | THD_TRANS::DID_DDL | THD_TRANS::EXECUTED_TABLE_ADMIN_CMD)); } |