Commit 41361d89 authored by He Zhenxing's avatar He Zhenxing

Post fix of BUG#37145

Binlog the CREATE EVENT unless the created event been successfully dropped

Modified Query_log_event constructor to make sure that error_code
is not set to ER_SERVER_SHUTDOWN or ER_QUERY_INTERRUPTED errors
when NOT_KILLED
parent 72252108
...@@ -412,6 +412,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, ...@@ -412,6 +412,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists))) if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
{ {
Event_queue_element *new_element; Event_queue_element *new_element;
bool dropped= 0;
if (!(new_element= new Event_queue_element())) if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM ret= TRUE; // OOM
...@@ -419,8 +420,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, ...@@ -419,8 +420,9 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
parse_data->name, parse_data->name,
new_element))) new_element)))
{ {
db_repository->drop_event(thd, parse_data->dbname, parse_data->name, if (!db_repository->drop_event(thd, parse_data->dbname, parse_data->name,
TRUE); TRUE))
dropped= 1;
delete new_element; delete new_element;
} }
else else
...@@ -429,6 +431,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, ...@@ -429,6 +431,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data,
bool created; bool created;
if (event_queue) if (event_queue)
event_queue->create_event(thd, new_element, &created); event_queue->create_event(thd, new_element, &created);
}
/*
binlog the create event unless it's been successfully dropped
*/
if (!dropped)
{
/* Binlog the create event. */ /* Binlog the create event. */
DBUG_ASSERT(thd->query && thd->query_length); DBUG_ASSERT(thd->query && thd->query_length);
write_bin_log(thd, TRUE, thd->query, thd->query_length); write_bin_log(thd, TRUE, thd->query, thd->query_length);
......
...@@ -2292,7 +2292,16 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg, ...@@ -2292,7 +2292,16 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
(thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) : (thd_arg->is_error() ? thd_arg->main_da.sql_errno() : 0) :
((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 : ((thd_arg->system_thread & SYSTEM_THREAD_DELAYED_INSERT) ? 0 :
thd_arg->killed_errno()); thd_arg->killed_errno());
/* thd_arg->main_da.sql_errno() might be ER_SERVER_SHUTDOWN or
ER_QUERY_INTERRUPTED, So here we need to make sure that
error_code is not set to these errors when specified NOT_KILLED
by the caller
*/
if ((killed_status_arg == THD::NOT_KILLED) &&
(error_code == ER_SERVER_SHUTDOWN || error_code == ER_QUERY_INTERRUPTED))
error_code= 0;
time(&end_time); time(&end_time);
exec_time = (ulong) (end_time - thd_arg->start_time); exec_time = (ulong) (end_time - thd_arg->start_time);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment