@@ -6848,9 +6848,9 @@ static void release_log_entries(partition_info *part_info)
6848
6848
alter_partition_lock_handling()
6849
6849
lpt Struct carrying parameters
6850
6850
RETURN VALUES
6851
- NONE
6851
+ true on error
6852
6852
*/
6853
- static void alter_partition_lock_handling (ALTER_PARTITION_PARAM_TYPE *lpt)
6853
+ static bool alter_partition_lock_handling (ALTER_PARTITION_PARAM_TYPE *lpt)
6854
6854
{
6855
6855
THD *thd= lpt->thd ;
6856
6856
@@ -6864,24 +6864,9 @@ static void alter_partition_lock_handling(ALTER_PARTITION_PARAM_TYPE *lpt)
6864
6864
lpt->table = 0 ;
6865
6865
lpt->table_list ->table = 0 ;
6866
6866
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 );
6877
6868
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 ;
6885
6870
}
6886
6871
6887
6872
@@ -7082,6 +7067,8 @@ void handle_alter_part_error(ALTER_PARTITION_PARAM_TYPE *lpt,
7082
7067
thd->set_stmt_da (&tmp_stmt_da);
7083
7068
}
7084
7069
7070
+ /* NB: error status is not needed here, the statement fails with
7071
+ the original error. */
7085
7072
if (unlikely (thd->locked_tables_list .reopen_tables (thd, false )))
7086
7073
sql_print_warning (" We failed to reacquire LOCKs in ALTER TABLE" );
7087
7074
@@ -7305,13 +7292,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
7305
7292
ERROR_INJECT_ERROR (" fail_drop_partition_8" ) ||
7306
7293
(write_log_completed (lpt, FALSE ), FALSE ) ||
7307
7294
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" ))
7310
7296
{
7311
7297
handle_alter_part_error (lpt, action_completed, TRUE , frm_install,
7312
7298
close_table_on_failure);
7313
7299
goto err;
7314
7300
}
7301
+ if (alter_partition_lock_handling (lpt))
7302
+ goto err;
7315
7303
}
7316
7304
else if ((alter_info->partition_flags & ALTER_PARTITION_ADD) &&
7317
7305
(part_info->part_type == RANGE_PARTITION ||
@@ -7382,13 +7370,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
7382
7370
ERROR_INJECT_ERROR (" fail_add_partition_9" ) ||
7383
7371
(write_log_completed (lpt, FALSE ), FALSE ) ||
7384
7372
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" ))
7387
7374
{
7388
7375
handle_alter_part_error (lpt, action_completed, FALSE , frm_install,
7389
7376
close_table_on_failure);
7390
7377
goto err;
7391
7378
}
7379
+ if (alter_partition_lock_handling (lpt))
7380
+ goto err;
7392
7381
}
7393
7382
else
7394
7383
{
@@ -7487,13 +7476,14 @@ uint fast_alter_partition_table(THD *thd, TABLE *table,
7487
7476
ERROR_INJECT_ERROR (" fail_change_partition_11" ) ||
7488
7477
(write_log_completed (lpt, FALSE ), FALSE ) ||
7489
7478
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" ))
7492
7480
{
7493
7481
handle_alter_part_error (lpt, action_completed, FALSE , frm_install,
7494
7482
close_table_on_failure);
7495
7483
goto err;
7496
7484
}
7485
+ if (alter_partition_lock_handling (lpt))
7486
+ goto err;
7497
7487
}
7498
7488
downgrade_mdl_if_lock_tables_mode (thd, mdl_ticket, MDL_SHARED_NO_READ_WRITE);
7499
7489
/*
0 commit comments