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()
switch (m_action)
{
case OT_BACKOFF_AND_RETRY:
break;
case OT_REOPEN_TABLES:
break;
case OT_DISCOVER:
{
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,
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
case OT_REPAIR:
if ((result= lock_table_names(m_thd, m_thd->lex->create_info,
m_failed_table, NULL,
get_timeout(), 0)))
break;
No_such_table_error_handler no_such_table_handler;
bool open_if_exists= m_failed_table->open_strategy == TABLE_LIST::OPEN_IF_EXISTS;
tdc_remove_table(m_thd, m_failed_table->db.str,
m_failed_table->table_name.str);
if (open_if_exists)
m_thd->push_internal_handler(&no_such_table_handler);
result= !tdc_acquire_share(m_thd, m_failed_table,
GTS_TABLE | GTS_FORCE_DISCOVERY | GTS_NOLOCK);
if (open_if_exists)
switch (m_action)
{
case OT_DISCOVER:
{
m_thd->pop_internal_handler();
if (result && no_such_table_handler.safely_trapped_errors())
result= FALSE;
}
m_thd->get_stmt_da()->clear_warning_info(m_thd->query_id);
m_thd->clear_error(); // Clear error message
/*
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_REPAIR:
{
if ((result= lock_table_names(m_thd, m_thd->lex->create_info,
m_failed_table, NULL,
get_timeout(), 0)))
break;
No_such_table_error_handler no_such_table_handler;
bool open_if_exists= m_failed_table->open_strategy == TABLE_LIST::OPEN_IF_EXISTS;
tdc_remove_table(m_thd, m_failed_table->db.str,
m_failed_table->table_name.str);
if (open_if_exists)
m_thd->push_internal_handler(&no_such_table_handler);
result= auto_repair_table(m_thd, m_failed_table);
/*
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;
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();
if (result && no_such_table_handler.safely_trapped_errors())
result= FALSE;
}
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);
}
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