Commit ee972a4d authored by unknown's avatar unknown

fix for FLUSH TABLES WITH READ LOCK

parent 745f1197
...@@ -33,6 +33,25 @@ int generate_table(THD *thd, TABLE_LIST *table_list, ...@@ -33,6 +33,25 @@ int generate_table(THD *thd, TABLE_LIST *table_list,
DBUG_ENTER("generate_table"); DBUG_ENTER("generate_table");
thd->proc_info="generate_table"; thd->proc_info="generate_table";
if(global_read_lock)
{
if(thd->global_read_lock)
{
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0),
table_list->real_name);
DBUG_RETURN(-1);
}
pthread_mutex_lock(&LOCK_open);
while (global_read_lock && ! thd->killed ||
thd->version != refresh_version)
{
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
pthread_mutex_unlock(&LOCK_open);
}
/* If it is a temporary table, close and regenerate it */ /* If it is a temporary table, close and regenerate it */
if ((table_ptr=find_temporary_table(thd,table_list->db, if ((table_ptr=find_temporary_table(thd,table_list->db,
table_list->real_name))) table_list->real_name)))
......
...@@ -57,6 +57,23 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) ...@@ -57,6 +57,23 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
pthread_mutex_unlock(&thd->mysys_var->mutex); pthread_mutex_unlock(&thd->mysys_var->mutex);
if(global_read_lock)
{
if(thd->global_read_lock)
{
my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0),
tables->real_name);
error = 1;
goto err;
}
while (global_read_lock && ! thd->killed ||
thd->version != refresh_version)
{
(void) pthread_cond_wait(&COND_refresh,&LOCK_open);
}
}
for (TABLE_LIST *table=tables ; table ; table=table->next) for (TABLE_LIST *table=tables ; table ; table=table->next)
{ {
char *db=table->db ? table->db : thd->db; char *db=table->db ? table->db : thd->db;
...@@ -125,6 +142,8 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) ...@@ -125,6 +142,8 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
} }
} }
error = 0;
err:
VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh
pthread_mutex_unlock(&LOCK_open); pthread_mutex_unlock(&LOCK_open);
...@@ -138,6 +157,8 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) ...@@ -138,6 +157,8 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists)
my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr());
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if(error)
DBUG_RETURN(-1);
send_ok(&thd->net); send_ok(&thd->net);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
......
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