mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
updated patch for BUG#4680 (incomplete DROP DATABASE breaking replication).
We binlog the DROP TABLE for each table that was actually dropped. Per Sergei's suggestion a fixed buffer for the DROP TABLE query is pre-allocated from THD pool, and logging now is done in batches - new batch is started if the buffer becomes full. Reduced memory usage by reusing the table list instead of accumulating a list of dropped table names. Also fixed the problem if the table was not actually dropped, eg due to permissions. Extended the test case to make sure batched query logging does work.
This commit is contained in:
@ -156,8 +156,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
|
||||
int mysql_rm_table_part2_with_lock(THD *thd,
|
||||
TABLE_LIST *tables, bool if_exists,
|
||||
bool drop_temporary, bool dont_log_query,
|
||||
List<String>* dropped_tables)
|
||||
bool drop_temporary, bool dont_log_query)
|
||||
{
|
||||
int error;
|
||||
thd->mysys_var->current_mutex= &LOCK_open;
|
||||
@ -166,23 +165,6 @@ int mysql_rm_table_part2_with_lock(THD *thd,
|
||||
|
||||
error=mysql_rm_table_part2(thd,tables, if_exists, drop_temporary,
|
||||
dont_log_query);
|
||||
/*
|
||||
For now we assume that if we got success all the tables in the list
|
||||
were actually dropped, otherwise, assume none were dropped.
|
||||
TODO: fix it to work with a partial drop - extremely rare case, but
|
||||
can happen.
|
||||
*/
|
||||
if (!error && dropped_tables)
|
||||
{
|
||||
TABLE_LIST* tbl;
|
||||
|
||||
for (tbl= tables; tbl; tbl= tbl->next)
|
||||
{
|
||||
String *dropped_table= new (thd->mem_root)
|
||||
String(tbl->real_name,&my_charset_latin1);
|
||||
dropped_tables->push_back(dropped_table);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&LOCK_open);
|
||||
|
||||
@ -238,6 +220,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
for (table=tables ; table ; table=table->next)
|
||||
{
|
||||
char *db=table->db;
|
||||
table->was_dropped= 0;
|
||||
mysql_ha_flush(thd, table, MYSQL_HA_CLOSE_FINAL);
|
||||
if (!close_temporary_table(thd, db, table->real_name))
|
||||
{
|
||||
@ -298,6 +281,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
wrong_tables.append(',');
|
||||
wrong_tables.append(String(table->real_name,system_charset_info));
|
||||
}
|
||||
else
|
||||
table->was_dropped= 1;
|
||||
}
|
||||
thd->tmp_table_used= tmp_table_deleted;
|
||||
error= 0;
|
||||
|
Reference in New Issue
Block a user