Commit a6926451 authored by Michael Widenius's avatar Michael Widenius

Fixed bug found by Pavel Ivanov in Gtid_log_event.

- Removed double call to trans_begin() for GTID BEGIN event
- Don't set OPTION_BEGIN before calling trans_begin() as this causes extra work in trans_begin()

sql/log_event.cc:
  Removed double call to trans_begin for GTID BEGIN event.
  Don't set OPTION_BEGIN before calling trans_begin() as this causes extra work in trans_begin().
  This was done by removing parsing of "BEGIN" and instead executing trans_begin() direct.
  This is much faster, but we lost the ability logging of possible slow "BEGIN" statements. As this should never happen it can be ignored.
parent 2520e8d1
...@@ -6518,24 +6518,22 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi) ...@@ -6518,24 +6518,22 @@ Gtid_log_event::do_apply_event(rpl_group_info *rgi)
return 0; return 0;
/* Execute this like a BEGIN query event. */ /* Execute this like a BEGIN query event. */
thd->variables.option_bits|= OPTION_BEGIN | OPTION_GTID_BEGIN; thd->variables.option_bits|= OPTION_GTID_BEGIN;
DBUG_PRINT("info", ("Set OPTION_GTID_BEGIN")); DBUG_PRINT("info", ("Set OPTION_GTID_BEGIN"));
trans_begin(thd, 0);
thd->set_query_and_id(gtid_begin_string, sizeof(gtid_begin_string)-1, thd->set_query_and_id(gtid_begin_string, sizeof(gtid_begin_string)-1,
&my_charset_bin, next_query_id()); &my_charset_bin, next_query_id());
Parser_state parser_state; thd->lex->sql_command= SQLCOM_BEGIN;
if (!parser_state.init(thd, thd->query(), thd->query_length())) thd->is_slave_error= 0;
status_var_increment(thd->status_var.com_stat[thd->lex->sql_command]);
if (trans_begin(thd, 0))
{ {
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state); DBUG_PRINT("error", ("trans_begin() failed"));
/* Finalize server status flags after executing a statement. */
thd->update_server_status();
log_slow_statement(thd);
if (unlikely(thd->is_fatal_error))
thd->is_slave_error= 1; thd->is_slave_error= 1;
else if (likely(!thd->is_slave_error))
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
} }
thd->update_stats();
if (likely(!thd->is_slave_error))
general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
thd->reset_query(); thd->reset_query();
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
......
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