Commit 4bd8c634 authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: don't repeat common code

parent 364e7a9a
...@@ -3103,65 +3103,57 @@ Open_table_context::recover_from_failed_open() ...@@ -3103,65 +3103,57 @@ Open_table_context::recover_from_failed_open()
switch (m_action) switch (m_action)
{ {
case OT_BACKOFF_AND_RETRY: case OT_BACKOFF_AND_RETRY:
break;
case OT_REOPEN_TABLES: case OT_REOPEN_TABLES:
break; break;
case OT_DISCOVER: case OT_DISCOVER:
{ case OT_REPAIR:
if ((result= lock_table_names(m_thd, m_thd->lex->create_info, if ((result= lock_table_names(m_thd, m_thd->lex->create_info,
m_failed_table, NULL, m_failed_table, NULL,
get_timeout(), 0))) get_timeout(), 0)))
break; break;
tdc_remove_table(m_thd, m_failed_table->db.str,
m_failed_table->table_name.str);
m_thd->get_stmt_da()->clear_warning_info(m_thd->query_id);
m_thd->clear_error(); // Clear error message
No_such_table_error_handler no_such_table_handler; tdc_remove_table(m_thd, m_failed_table->db.str,
bool open_if_exists= m_failed_table->open_strategy == TABLE_LIST::OPEN_IF_EXISTS; m_failed_table->table_name.str);
if (open_if_exists) switch (m_action)
m_thd->push_internal_handler(&no_such_table_handler); {
case OT_DISCOVER:
result= !tdc_acquire_share(m_thd, m_failed_table,
GTS_TABLE | GTS_FORCE_DISCOVERY | GTS_NOLOCK);
if (open_if_exists)
{ {
m_thd->pop_internal_handler(); m_thd->get_stmt_da()->clear_warning_info(m_thd->query_id);
if (result && no_such_table_handler.safely_trapped_errors()) m_thd->clear_error(); // Clear error message
result= FALSE;
}
/* No_such_table_error_handler no_such_table_handler;
Rollback to start of the current statement to release exclusive lock bool open_if_exists= m_failed_table->open_strategy == TABLE_LIST::OPEN_IF_EXISTS;
on table which was discovered but preserve locks from previous statements
in current transaction.
*/
m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp());
break;
}
case OT_REPAIR:
{
if ((result= lock_table_names(m_thd, m_thd->lex->create_info,
m_failed_table, NULL,
get_timeout(), 0)))
break;
tdc_remove_table(m_thd, m_failed_table->db.str, if (open_if_exists)
m_failed_table->table_name.str); m_thd->push_internal_handler(&no_such_table_handler);
result= auto_repair_table(m_thd, m_failed_table); result= !tdc_acquire_share(m_thd, m_failed_table,
/* GTS_TABLE | GTS_FORCE_DISCOVERY | GTS_NOLOCK);
Rollback to start of the current statement to release exclusive lock if (open_if_exists)
on table which was discovered but preserve locks from previous statements {
in current transaction. m_thd->pop_internal_handler();
*/ if (result && no_such_table_handler.safely_trapped_errors())
m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp()); result= FALSE;
break; }
break;
}
case OT_REPAIR:
result= auto_repair_table(m_thd, m_failed_table);
break;
case OT_BACKOFF_AND_RETRY:
case OT_REOPEN_TABLES:
case OT_NO_ACTION:
DBUG_ASSERT(0);
} }
default: /*
Rollback to start of the current statement to release exclusive lock
on table which was discovered but preserve locks from previous statements
in current transaction.
*/
m_thd->mdl_context.rollback_to_savepoint(start_of_statement_svp());
break;
case OT_NO_ACTION:
DBUG_ASSERT(0); DBUG_ASSERT(0);
} }
m_thd->pop_internal_handler(); m_thd->pop_internal_handler();
......
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