From 513923868545338c00390f35f63b92efd55f50bb Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 4 Sep 2012 19:26:30 +0300 Subject: Switch automaticly to statement based replication for statements that can't generate row based events. This is needed to avoid getting updates to system, statistics and admin tables logged to binary log. - Removed special code used to temporarily change to statement based replication. - Changed to a faster and smaller interface for temporarily switching to statement based replication. sql/event_db_repository.cc: Change to new interface to not use row based replication for system table changes. sql/events.cc: Change to new interface to not use row based replication for system table changes. sql/sp.cc: Removed temporarily switching to statement based replication (this is now done automaticly in mysql_execute_command()) sql/sql_acl.cc: Change to new interface to not use row based replication for system table changes. Removed temporarily switching to statement based replication (this is now done automaticly in mysql_execute_command()) sql/sql_class.h: Added new interface for temporarily switching to statement based replication. sql/sql_parse.cc: Mark commands that needs original replication mode with CF_FORCE_ORIGINAL_BINLOG_FORMAT. Switch automaticly to statement based replication for statements that can't generate row based events (and can't change replication mode) sql/sql_udf.cc: Removed temporarily switching to statement based replication (this is now done automaticly in mysql_execute_command()) --- sql/events.cc | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'sql/events.cc') diff --git a/sql/events.cc b/sql/events.cc index 8b4bab9e3a6..d8caa059c64 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -306,7 +306,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists) { bool ret; - bool save_binlog_row_based, event_already_exists; + bool event_already_exists; + enum_binlog_format save_binlog_format; DBUG_ENTER("Events::create_event"); if (check_if_system_tables_error()) @@ -338,8 +339,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, Turn off row binlogging of this statement and use statement-based so that all supporting tables are updated for CREATE EVENT command. */ - if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row())) - thd->clear_current_stmt_binlog_format_row(); + save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); if (lock_object_name(thd, MDL_key::EVENT, parse_data->dbname.str, parse_data->name.str)) @@ -398,10 +398,8 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, } } } - /* Restore the state of binlog format */ - DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); - if (save_binlog_row_based) - thd->set_current_stmt_binlog_format_row(); + + thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); } @@ -431,7 +429,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname, LEX_STRING *new_name) { int ret; - bool save_binlog_row_based; + enum_binlog_format save_binlog_format; Event_queue_element *new_element; DBUG_ENTER("Events::update_event"); @@ -478,8 +476,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, Turn off row binlogging of this statement and use statement-based so that all supporting tables are updated for UPDATE EVENT command. */ - if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row())) - thd->clear_current_stmt_binlog_format_row(); + save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); if (lock_object_name(thd, MDL_key::EVENT, parse_data->dbname.str, parse_data->name.str)) @@ -513,11 +510,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } } - /* Restore the state of binlog format */ - DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); - if (save_binlog_row_based) - thd->set_current_stmt_binlog_format_row(); + thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); } @@ -550,7 +544,7 @@ bool Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) { int ret; - bool save_binlog_row_based; + enum_binlog_format save_binlog_format; DBUG_ENTER("Events::drop_event"); if (check_if_system_tables_error()) @@ -563,8 +557,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) Turn off row binlogging of this statement and use statement-based so that all supporting tables are updated for DROP EVENT command. */ - if ((save_binlog_row_based= thd->is_current_stmt_binlog_format_row())) - thd->clear_current_stmt_binlog_format_row(); + save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); if (lock_object_name(thd, MDL_key::EVENT, dbname.str, name.str)) @@ -578,10 +571,8 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) DBUG_ASSERT(thd->query() && thd->query_length()); ret= write_bin_log(thd, TRUE, thd->query(), thd->query_length()); } - /* Restore the state of binlog format */ - DBUG_ASSERT(!thd->is_current_stmt_binlog_format_row()); - if (save_binlog_row_based) - thd->set_current_stmt_binlog_format_row(); + + thd->restore_stmt_binlog_format(save_binlog_format); DBUG_RETURN(ret); } -- cgit v1.2.1