summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc40
1 files changed, 12 insertions, 28 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 1d9b4645421..895eeec454b 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -252,8 +252,9 @@ void make_default_log_name(char **out, const char* log_ext, bool once)
class binlog_cache_data
{
public:
- binlog_cache_data(): m_pending(0), before_stmt_pos(MY_OFF_T_UNDEF),
- incident(FALSE), changes_to_non_trans_temp_table_flag(FALSE),
+ binlog_cache_data(): m_pending(0),
+ before_stmt_pos(MY_OFF_T_UNDEF),
+ incident(FALSE),
saved_max_binlog_cache_size(0), ptr_binlog_cache_use(0),
ptr_binlog_cache_disk_use(0)
{ }
@@ -289,16 +290,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()
{
compute_statistics();
@@ -306,7 +297,6 @@ public:
if(cache_log.file != -1)
my_chsize(cache_log.file, 0, 0, MYF(MY_WME));
- changes_to_non_trans_temp_table_flag= FALSE;
incident= FALSE;
before_stmt_pos= MY_OFF_T_UNDEF;
/*
@@ -401,12 +391,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.
*/
@@ -1942,13 +1926,12 @@ static int binlog_prepare(handlerton *hton, THD *thd, bool all)
*/
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) &&
@@ -2092,17 +2075,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);
}
@@ -6276,9 +6261,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info, my_bool *with_annotate)
file= cache_mngr->get_binlog_cache_log(is_trans_cache);
cache_data= cache_mngr->get_binlog_cache_data(is_trans_cache);
- 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()));