Skip to content

Commit

Permalink
MDEV-20494 Fix wrongly ignored error status
Browse files Browse the repository at this point in the history
  • Loading branch information
midenok committed Apr 3, 2020
1 parent 76063c2 commit 198af54
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions sql/sql_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6848,9 +6848,9 @@ static void release_log_entries(partition_info *part_info)
alter_partition_lock_handling()
lpt Struct carrying parameters
RETURN VALUES
NONE
true on error
*/
static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
static bool alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
{
THD *thd= lpt->thd;

Expand All @@ -6864,24 +6864,9 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
lpt->table= 0;
lpt->table_list->table= 0;
if (thd->locked_tables_mode)
{
Diagnostics_area *stmt_da= NULL;
Diagnostics_area tmp_stmt_da(true);

if (unlikely(thd->is_error()))
{
/* reopen might fail if we have a previous error, use a temporary da. */
stmt_da= thd->get_stmt_da();
thd->set_stmt_da(&tmp_stmt_da);
}
return thd->locked_tables_list.reopen_tables(thd, false);

// TODO: why error status of reopen_tables() is ignored?
if (unlikely(thd->locked_tables_list.reopen_tables(thd, false)))
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");

if (stmt_da)
thd->set_stmt_da(stmt_da);
}
return false;
}


Expand Down Expand Up @@ -7082,6 +7067,8 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
thd->set_stmt_da(&tmp_stmt_da);
}

/* NB: error status is not needed here, the statement fails with
the original error. */
if (unlikely(thd->locked_tables_list.reopen_tables(thd, false)))
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");

Expand Down Expand Up @@ -7305,13 +7292,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_ERROR("fail_drop_partition_8") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
ERROR_INJECT_ERROR("fail_drop_partition_9") ||
(alter_partition_lock_handling(lpt), FALSE))
ERROR_INJECT_ERROR("fail_drop_partition_9"))
{
handle_alter_part_error(lpt, action_completed, TRUE, frm_install,
close_table_on_failure);
goto err;
}
if (alter_partition_lock_handling(lpt))
goto err;
}
else if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
(part_info->part_type == RANGE_PARTITION ||
Expand Down Expand Up @@ -7382,13 +7370,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_ERROR("fail_add_partition_9") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_add_partition_10") ||
ERROR_INJECT_ERROR("fail_add_partition_10") ||
(alter_partition_lock_handling(lpt), FALSE))
ERROR_INJECT_ERROR("fail_add_partition_10"))
{
handle_alter_part_error(lpt, action_completed, FALSE, frm_install,
close_table_on_failure);
goto err;
}
if (alter_partition_lock_handling(lpt))
goto err;
}
else
{
Expand Down Expand Up @@ -7487,13 +7476,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
ERROR_INJECT_ERROR("fail_change_partition_11") ||
(write_log_completed(lpt, FALSE), FALSE) ||
ERROR_INJECT_CRASH("crash_change_partition_12") ||
ERROR_INJECT_ERROR("fail_change_partition_12") ||
(alter_partition_lock_handling(lpt), FALSE))
ERROR_INJECT_ERROR("fail_change_partition_12"))
{
handle_alter_part_error(lpt, action_completed, FALSE, frm_install,
close_table_on_failure);
goto err;
}
if (alter_partition_lock_handling(lpt))
goto err;
}
downgrade_mdl_if_lock_tables_mode(thd, mdl_ticket, MDL_SHARED_NO_READ_WRITE);
/*
Expand Down

0 comments on commit 198af54

Please sign in to comment.