From 911a85d54844ad75f407359bd86a44c76c7e6dc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Feb 2008 11:26:24 +0100 Subject: [PATCH] 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. --- sql/sql_partition.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 677d45dc33d..3f65baa71ff 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5846,21 +5846,31 @@ static void release_log_entries(partition_info *part_info) RETURN VALUES NONE */ -void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) +static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt) { int err; 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); lpt->thd->in_lock_tables= 1; err= reopen_tables(lpt->thd, 1, 1); lpt->thd->in_lock_tables= 0; - pthread_mutex_unlock(&LOCK_open); 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"); } + pthread_mutex_unlock(&LOCK_open); } }