Added comments on why we do reopen
Handle error case of not being able to reopen which requires us to remove table from thread's open list and table_cache.
This commit is contained in:
parent
516f95acea
commit
911a85d548
@ -5846,21 +5846,31 @@ static void release_log_entries(partition_info *part_info)
|
|||||||
RETURN VALUES
|
RETURN VALUES
|
||||||
NONE
|
NONE
|
||||||
*/
|
*/
|
||||||
void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
|
static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
if (lpt->thd->locked_tables)
|
if (lpt->thd->locked_tables)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
When we have the table locked, it is necessary to reopen the table
|
||||||
|
since all table objects were closed and removed as part of the
|
||||||
|
ALTER TABLE of partitioning structure.
|
||||||
|
*/
|
||||||
pthread_mutex_lock(&LOCK_open);
|
pthread_mutex_lock(&LOCK_open);
|
||||||
lpt->thd->in_lock_tables= 1;
|
lpt->thd->in_lock_tables= 1;
|
||||||
err= reopen_tables(lpt->thd, 1, 1);
|
err= reopen_tables(lpt->thd, 1, 1);
|
||||||
lpt->thd->in_lock_tables= 0;
|
lpt->thd->in_lock_tables= 0;
|
||||||
pthread_mutex_unlock(&LOCK_open);
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
/* Issue a warning since we weren't able to regain the lock again. */
|
/*
|
||||||
|
Issue a warning since we weren't able to regain the lock again.
|
||||||
|
We also need to unlink table from thread's open list and from
|
||||||
|
table_cache
|
||||||
|
*/
|
||||||
|
unlink_open_table(lpt->thd, lpt->table, FALSE);
|
||||||
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
|
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
|
||||||
}
|
}
|
||||||
|
pthread_mutex_unlock(&LOCK_open);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user