diff options
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r-- | sql/log_event.cc | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc index d224f555cf2..16290c58685 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -674,15 +674,16 @@ const char* Log_event::get_type_str() #ifndef MYSQL_CLIENT Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans) - :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), thd(thd_arg) + :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), + cache_type(Log_event::EVENT_INVALID_CACHE), thd(thd_arg) { server_id= thd->server_id; when= thd->start_time; - cache_type= ((using_trans || stmt_has_updated_trans_table(thd) || - (thd->lex->stmt_accessed_temp_table() && - trans_has_updated_trans_table(thd))) - ? Log_event::EVENT_TRANSACTIONAL_CACHE : - Log_event::EVENT_STMT_CACHE); + + if (using_trans) + cache_type= Log_event::EVENT_TRANSACTIONAL_CACHE; + else + cache_type= Log_event::EVENT_STMT_CACHE; } /** @@ -2520,21 +2521,18 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, LEX *lex= thd->lex; /* - TRUE defines that either a trx-cache or stmt-cache must be used - and wrapped by a BEGIN...COMMIT. Otherwise, the statement will - be written directly to the binary log without being wrapped by - a BEGIN...COMMIT. + Defines that the statement will be written directly to the binary log + without being wrapped by a BEGIN...COMMIT. Otherwise, the statement + will be written to either the trx-cache or stmt-cache. - Note that a cache will not be used if the parameter direct is - TRUE. + Note that a cache will not be used if the parameter direct is TRUE. */ bool use_cache= FALSE; /* - TRUE defines that the trx-cache must be used and by consequence - the use_cache is TRUE. + TRUE defines that the trx-cache must be used and by consequence the + use_cache is TRUE. - Note that a cache will not be used if the parameter direct is - TRUE. + Note that a cache will not be used if the parameter direct is TRUE. */ bool trx_cache= FALSE; cache_type= Log_event::EVENT_INVALID_CACHE; @@ -2542,16 +2540,14 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, switch (lex->sql_command) { case SQLCOM_DROP_TABLE: - use_cache= trx_cache= (lex->drop_temporary && - thd->in_multi_stmt_transaction_mode()); + use_cache= (lex->drop_temporary && thd->in_multi_stmt_transaction_mode()); break; case SQLCOM_CREATE_TABLE: - use_cache= trx_cache= - ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && - thd->in_multi_stmt_transaction_mode()) || - (lex->select_lex.item_list.elements && + trx_cache= (lex->select_lex.item_list.elements && thd->is_current_stmt_binlog_format_row()); + use_cache= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) && + thd->in_multi_stmt_transaction_mode()) || trx_cache; break; case SQLCOM_SET_OPTION: use_cache= trx_cache= (lex->autocommit ? FALSE : TRUE); @@ -2570,14 +2566,14 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, { cache_type= Log_event::EVENT_NO_CACHE; } + else if (using_trans || trx_cache || stmt_has_updated_trans_table(thd) || + thd->lex->is_mixed_stmt_unsafe(thd->in_multi_stmt_transaction_mode(), + thd->variables.binlog_direct_non_trans_update, + trans_has_updated_trans_table(thd), + thd->tx_isolation)) + cache_type= Log_event::EVENT_TRANSACTIONAL_CACHE; else - { - cache_type= ((using_trans || stmt_has_updated_trans_table(thd) || trx_cache || - (thd->lex->stmt_accessed_temp_table() && - trans_has_updated_trans_table(thd))) - ? Log_event::EVENT_TRANSACTIONAL_CACHE : - Log_event::EVENT_STMT_CACHE); - } + cache_type= Log_event::EVENT_STMT_CACHE; DBUG_ASSERT(cache_type != Log_event::EVENT_INVALID_CACHE); DBUG_PRINT("info",("Query_log_event has flags2: %lu sql_mode: %lu", (ulong) flags2, sql_mode)); |