Commit 0e812fc4 authored by unknown's avatar unknown

Fix for replication of INSERT | REPLACE | CREATE ... SELECT


sql/sql_select.cc:
  Fix for repllication of INSERT | REPLACE | CREATE  ... SELECT
parent 5cd07da7
...@@ -1595,6 +1595,7 @@ mysql_execute_command(void) ...@@ -1595,6 +1595,7 @@ mysql_execute_command(void)
for (table = tables->next ; table ; table=table->next) for (table = tables->next ; table ; table=table->next)
table->lock_type= lex->lock_option; table->lock_type= lex->lock_option;
} }
select_lex->options|= SELECT_NO_UNLOCK;
thd->offset_limit=select_lex->offset_limit; thd->offset_limit=select_lex->offset_limit;
thd->select_limit=select_lex->select_limit+select_lex->offset_limit; thd->select_limit=select_lex->select_limit+select_lex->offset_limit;
if (thd->select_limit < select_lex->select_limit) if (thd->select_limit < select_lex->select_limit)
...@@ -1922,6 +1923,8 @@ mysql_execute_command(void) ...@@ -1922,6 +1923,8 @@ mysql_execute_command(void)
if ((res=check_table_access(thd, SELECT_ACL, save_next))) if ((res=check_table_access(thd, SELECT_ACL, save_next)))
goto error; goto error;
} }
/* Don't unlock tables until command is written to binary log */
select_lex->options|= SELECT_NO_UNLOCK;
select_result *result; select_result *result;
thd->offset_limit=select_lex->offset_limit; thd->offset_limit=select_lex->offset_limit;
......
...@@ -4469,16 +4469,13 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure) ...@@ -4469,16 +4469,13 @@ do_select(JOIN *join,List<Item> *fields,TABLE *table,Procedure *procedure)
error=0; error=0;
if (!table) // If sending data to client if (!table) // If sending data to client
{ {
//note that the call below may trigger binlog writing for some commands...
if (join->result->send_eof())
error= 1; // Don't send error
/* /*
...which must be done before unlocking the read tables (otherwise The following will unlock all cursors if the command wasn't an
another thread may, quickly between unlock and binlog-write, update command
update the read table and write to the binlog, which will
result in badly ordered binlog events (and replication breaks).
*/ */
join_free(join); // Unlock all cursors join_free(join);
if (join->result->send_eof())
error= 1; // Don't send error
} }
DBUG_PRINT("info",("%ld records output",join->send_records)); DBUG_PRINT("info",("%ld records output",join->send_records));
} }
......
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