From: Date: November 15 2007 10:13am Subject: bk commit into 5.1 tree (istruewing:1.2617) BUG#26379 List-Archive: http://lists.mysql.com/commits/37833 X-Bug: 26379 Message-Id: Below is the list of changes that have just been committed into a local 5.1 repository of istruewing. When istruewing does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-11-15 10:13:02+01:00, istruewing@stripped +2 -0 Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table Not to be pushed as is. Final post-review fixes. Intermediate patch for review purpose. sql/sql_base.cc@stripped, 2007-11-15 10:13:00+01:00, istruewing@stripped +8 -13 Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table Moved temporary detach to mark_temp_tables_as_free_for_reuse(). sql/sql_insert.cc@stripped, 2007-11-15 10:13:00+01:00, istruewing@stripped +8 -0 Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table Reestablished LEX settings after lex initialization. diff -Nrup a/sql/sql_base.cc b/sql/sql_base.cc --- a/sql/sql_base.cc 2007-11-14 19:50:29 +01:00 +++ b/sql/sql_base.cc 2007-11-15 10:13:00 +01:00 @@ -1137,6 +1137,14 @@ static void mark_temp_tables_as_free_for { table->query_id= 0; table->file->ha_reset(); + /* + Detach temporary MERGE children from temporary parent to allow new + attach at next open. Do not do the detach, if close_thread_tables() + is called from a sub-statement. The temporary table might still be + used in the top-level statement. + */ + if (table->child_l || table->parent) + detach_merge_children(table, TRUE); } } } @@ -1275,19 +1283,6 @@ void close_thread_tables(THD *thd) Mark all temporary tables used by this statement as free for reuse. */ mark_temp_tables_as_free_for_reuse(thd); - - /* - Detach temporary MERGE children from temporary parent to allow new - attach at next open. Do not do the detach, if close_thread_tables() - is called from a sub-statement. The temporary table might still be - used in the top-level statement. - */ - for (table= thd->temporary_tables; table; table= table->next) - { - if ((table->query_id == thd->query_id) && - (table->child_l || table->parent)) - detach_merge_children(table, TRUE); - } if (thd->locked_tables || prelocked_mode) { diff -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc --- a/sql/sql_insert.cc 2007-11-14 19:43:50 +01:00 +++ b/sql/sql_insert.cc 2007-11-15 10:13:00 +01:00 @@ -2273,6 +2273,14 @@ pthread_handler_t handle_delayed_insert( parsed using a lex, that depends on initialized thd->lex. */ lex_start(thd); + thd->lex->current_select= 0; // for my_message_sql + thd->lex->sql_command= SQLCOM_INSERT; // For innodb::store_lock() + /* + Statement-based replication of INSERT DELAYED has problems with RAND() + and user vars, so in mixed mode we go to row-based. + */ + thd->lex->set_stmt_unsafe(); + thd->set_current_stmt_binlog_row_based_if_mixed(); if (!(di->table= open_n_lock_single_table(thd, &di->table_list, TL_WRITE_DELAYED))) {