summaryrefslogtreecommitdiff
path: root/sql/sql_admin.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-05-18 09:50:30 -0700
committerIgor Babaev <igor@askmonty.org>2012-05-18 09:50:30 -0700
commitd48b4a83a28750ccd9364e8e68ba5bfb9221858b (patch)
treeb464c088716907ab8f697f7668c93e092e35b069 /sql/sql_admin.cc
parent9b79feba56d8b0f955447afddbc4ab8b1d4d33c1 (diff)
parent8e95e6543b629e67e68974b8657ecfda0ba29c8a (diff)
downloadmariadb-git-d48b4a83a28750ccd9364e8e68ba5bfb9221858b.tar.gz
Merge.
Diffstat (limited to 'sql/sql_admin.cc')
-rw-r--r--sql/sql_admin.cc38
1 files changed, 25 insertions, 13 deletions
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index c2d06a149e8..a3271e94c38 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -80,6 +80,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
{
int error= 0;
TABLE tmp_table, *table;
+ TABLE_LIST *pos_in_locked_tables= 0;
TABLE_SHARE *share;
bool has_mdl_lock= FALSE;
char from[FN_REFLEN],tmp[FN_REFLEN+32];
@@ -194,9 +195,13 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
Table was successfully open in mysql_admin_table(). Now we need
to close it, but leave it protected by exclusive metadata lock.
*/
- if (wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
+ pos_in_locked_tables= table->pos_in_locked_tables;
+ if (wait_while_table_is_used(thd, table,
+ HA_EXTRA_PREPARE_FOR_FORCED_CLOSE))
goto end;
- close_all_tables_for_name(thd, table_list->table->s, FALSE);
+ /* Close table but don't remove from locked list */
+ close_all_tables_for_name(thd, table_list->table->s,
+ HA_EXTRA_NOT_USED);
table_list->table= 0;
}
/*
@@ -230,18 +235,25 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
goto end;
}
- if (thd->locked_tables_list.reopen_tables(thd))
- goto end;
-
- /*
- Now we should be able to open the partially repaired table
- to finish the repair in the handler later on.
- */
- if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+ if (thd->locked_tables_list.locked_tables())
{
- error= send_check_errmsg(thd, table_list, "repair",
- "Failed to open partially repaired table");
- goto end;
+ if (thd->locked_tables_list.reopen_tables(thd))
+ goto end;
+ /* Restore the table in the table list with the new opened table */
+ table_list->table= pos_in_locked_tables->table;
+ }
+ else
+ {
+ /*
+ Now we should be able to open the partially repaired table
+ to finish the repair in the handler later on.
+ */
+ if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+ {
+ error= send_check_errmsg(thd, table_list, "repair",
+ "Failed to open partially repaired table");
+ goto end;
+ }
}
end: