diff options
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 902e7fa7b5f..d28b4859ab5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1534,13 +1534,13 @@ void release_ddl_log() while (used_list) { DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry; - my_free(used_list, MYF(0)); + my_free(used_list); used_list= tmp; } while (free_list) { DDL_LOG_MEMORY_ENTRY *tmp= free_list->next_log_entry; - my_free(free_list, MYF(0)); + my_free(free_list); free_list= tmp; } close_ddl_log(); @@ -1696,8 +1696,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) if (readfrm(shadow_path, &data, &length) || packfrm(data, length, &lpt->pack_frm_data, &lpt->pack_frm_len)) { - my_free(data, MYF(MY_ALLOW_ZERO_PTR)); - my_free(lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(data); + my_free(lpt->pack_frm_data); mem_alloc_error(length); error= 1; goto end; @@ -2202,7 +2202,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (some_tables_deleted || tmp_table_deleted || !error) { query_cache_invalidate3(thd, tables, 0); - if (!dont_log_query) + if (!dont_log_query && mysql_bin_log.is_open()) { if (!thd->is_current_stmt_binlog_format_row() || (non_temp_tables_count > 0 && !tmp_table_deleted)) @@ -4882,6 +4882,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, if (wait_while_table_is_used(thd, table->table, HA_EXTRA_PREPARE_FOR_RENAME)) goto err; + DEBUG_SYNC(thd, "after_admin_flush"); /* Flush entries in the query cache involving this table. */ query_cache_invalidate3(thd, table->table, 0); /* @@ -4929,6 +4930,8 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, */ if (thd->stmt_da->is_ok()) thd->stmt_da->reset_diagnostics_area(); + table->table= NULL; + result_code= result_code ? HA_ADMIN_FAILED : HA_ADMIN_OK; goto send_result; } } @@ -5059,6 +5062,7 @@ send_result_message: trans_commit_stmt(thd); trans_commit(thd); close_thread_tables(thd); + table->table= NULL; thd->mdl_context.release_transactional_locks(); if (!result_code) // recreation went ok { @@ -5149,7 +5153,11 @@ send_result_message: { if (table->table->s->tmp_table) { - if (open_for_modify) + /* + If the table was not opened successfully, do not try to get + status information. (Bug#47633) + */ + if (open_for_modify && !open_error) table->table->file->info(HA_STATUS_CONST); } else if (open_for_modify || fatal_error) @@ -7331,12 +7339,22 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (table->s->tmp_table != NO_TMP_TABLE) { /* Close lock if this is a transactional table */ - if (thd->lock && - ! (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + if (thd->lock) { - mysql_unlock_tables(thd, thd->lock); - thd->lock=0; + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + mysql_unlock_tables(thd, thd->lock); + thd->lock=0; + } + else + { + /* + If LOCK TABLES list is not empty and contains this table, + unlock the table and remove the table from this list. + */ + mysql_lock_remove(thd, thd->lock, table); + } } /* Remove link to old table and rename the new one */ close_temporary_table(thd, table, 1, 1); @@ -7526,7 +7544,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (t_table) { intern_close_table(t_table); - my_free(t_table, MYF(0)); + my_free(t_table); } else sql_print_warning("Could not open table %s.%s after rename\n", |