Skip to content

Commit 198af54

Browse files
committed
MDEV-20494 Fix wrongly ignored error status
1 parent 76063c2 commit 198af54

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

sql/sql_partition.cc

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6848,9 +6848,9 @@ static void release_log_entries(partition_info *part_info)
68486848
alter_partition_lock_handling()
68496849
lpt Struct carrying parameters
68506850
RETURN VALUES
6851-
NONE
6851+
true on error
68526852
*/
6853-
static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
6853+
static bool alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
68546854
{
68556855
THD *thd= lpt->thd;
68566856

@@ -6864,24 +6864,9 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
68646864
lpt->table= 0;
68656865
lpt->table_list->table= 0;
68666866
if (thd->locked_tables_mode)
6867-
{
6868-
Diagnostics_area *stmt_da= NULL;
6869-
Diagnostics_area tmp_stmt_da(true);
6870-
6871-
if (unlikely(thd->is_error()))
6872-
{
6873-
/* reopen might fail if we have a previous error, use a temporary da. */
6874-
stmt_da= thd->get_stmt_da();
6875-
thd->set_stmt_da(&tmp_stmt_da);
6876-
}
6867+
return thd->locked_tables_list.reopen_tables(thd, false);
68776868

6878-
// TODO: why error status of reopen_tables() is ignored?
6879-
if (unlikely(thd->locked_tables_list.reopen_tables(thd, false)))
6880-
sql_print_warning("We failed to reacquire LOCKs in ALTER TABLE");
6881-
6882-
if (stmt_da)
6883-
thd->set_stmt_da(stmt_da);
6884-
}
6869+
return false;
68856870
}
68866871

68876872

@@ -7082,6 +7067,8 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
70827067
thd->set_stmt_da(&tmp_stmt_da);
70837068
}
70847069

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

@@ -7305,13 +7292,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
73057292
ERROR_INJECT_ERROR("fail_drop_partition_8") ||
73067293
(write_log_completed(lpt, FALSE), FALSE) ||
73077294
ERROR_INJECT_CRASH("crash_drop_partition_9") ||
7308-
ERROR_INJECT_ERROR("fail_drop_partition_9") ||
7309-
(alter_partition_lock_handling(lpt), FALSE))
7295+
ERROR_INJECT_ERROR("fail_drop_partition_9"))
73107296
{
73117297
handle_alter_part_error(lpt, action_completed, TRUE, frm_install,
73127298
close_table_on_failure);
73137299
goto err;
73147300
}
7301+
if (alter_partition_lock_handling(lpt))
7302+
goto err;
73157303
}
73167304
else if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
73177305
(part_info->part_type == RANGE_PARTITION ||
@@ -7382,13 +7370,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
73827370
ERROR_INJECT_ERROR("fail_add_partition_9") ||
73837371
(write_log_completed(lpt, FALSE), FALSE) ||
73847372
ERROR_INJECT_CRASH("crash_add_partition_10") ||
7385-
ERROR_INJECT_ERROR("fail_add_partition_10") ||
7386-
(alter_partition_lock_handling(lpt), FALSE))
7373+
ERROR_INJECT_ERROR("fail_add_partition_10"))
73877374
{
73887375
handle_alter_part_error(lpt, action_completed, FALSE, frm_install,
73897376
close_table_on_failure);
73907377
goto err;
73917378
}
7379+
if (alter_partition_lock_handling(lpt))
7380+
goto err;
73927381
}
73937382
else
73947383
{
@@ -7487,13 +7476,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
74877476
ERROR_INJECT_ERROR("fail_change_partition_11") ||
74887477
(write_log_completed(lpt, FALSE), FALSE) ||
74897478
ERROR_INJECT_CRASH("crash_change_partition_12") ||
7490-
ERROR_INJECT_ERROR("fail_change_partition_12") ||
7491-
(alter_partition_lock_handling(lpt), FALSE))
7479+
ERROR_INJECT_ERROR("fail_change_partition_12"))
74927480
{
74937481
handle_alter_part_error(lpt, action_completed, FALSE, frm_install,
74947482
close_table_on_failure);
74957483
goto err;
74967484
}
7485+
if (alter_partition_lock_handling(lpt))
7486+
goto err;
74977487
}
74987488
downgrade_mdl_if_lock_tables_mode(thd, mdl_ticket, MDL_SHARED_NO_READ_WRITE);
74997489
/*

0 commit comments

Comments
 (0)