From c973b0fde3310fecb5121f32c84f62183a7cc059 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 27 Mar 2020 16:32:34 +0530 Subject: MDEV-21832 FORCE all partition to rebuild if any one of the partition does rebuild - In ha_innobase::commit_inplace_alter_table() assumes that all partition should do the same kind of alter operations. During DDL, if one partition requires table rebuild and other partition doesn't need rebuild then all partition should be forced to rebuild. --- sql/ha_partition.cc | 53 ++++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'sql') diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 48610cabd4f..64a4f430b8e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -9996,7 +9996,8 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) { uint index= 0; - enum_alter_inplace_result result= HA_ALTER_INPLACE_NO_LOCK; + enum_alter_inplace_result result; + alter_table_operations orig_ops; ha_partition_inplace_ctx *part_inplace_ctx; bool first_is_set= false; THD *thd= ha_thd(); @@ -10023,33 +10024,35 @@ ha_partition::check_if_supported_inplace_alter(TABLE *altered_table, if (!part_inplace_ctx->handler_ctx_array) DBUG_RETURN(HA_ALTER_ERROR); - /* Set all to NULL, including the terminating one. */ - for (index= 0; index <= m_tot_parts; index++) - part_inplace_ctx->handler_ctx_array[index]= NULL; + do { + result= HA_ALTER_INPLACE_NO_LOCK; + /* Set all to NULL, including the terminating one. */ + for (index= 0; index <= m_tot_parts; index++) + part_inplace_ctx->handler_ctx_array[index]= NULL; - ha_alter_info->handler_flags |= ALTER_PARTITIONED; - for (index= 0; index < m_tot_parts; index++) - { - enum_alter_inplace_result p_result= - m_file[index]->check_if_supported_inplace_alter(altered_table, - ha_alter_info); - part_inplace_ctx->handler_ctx_array[index]= ha_alter_info->handler_ctx; - - if (index == 0) + ha_alter_info->handler_flags |= ALTER_PARTITIONED; + orig_ops= ha_alter_info->handler_flags; + for (index= 0; index < m_tot_parts; index++) { - first_is_set= (ha_alter_info->handler_ctx != NULL); - } - else if (first_is_set != (ha_alter_info->handler_ctx != NULL)) - { - /* Either none or all partitions must set handler_ctx! */ - DBUG_ASSERT(0); - DBUG_RETURN(HA_ALTER_ERROR); + enum_alter_inplace_result p_result= + m_file[index]->check_if_supported_inplace_alter(altered_table, + ha_alter_info); + part_inplace_ctx->handler_ctx_array[index]= ha_alter_info->handler_ctx; + + if (index == 0) + first_is_set= (ha_alter_info->handler_ctx != NULL); + else if (first_is_set != (ha_alter_info->handler_ctx != NULL)) + { + /* Either none or all partitions must set handler_ctx! */ + DBUG_ASSERT(0); + DBUG_RETURN(HA_ALTER_ERROR); + } + if (p_result < result) + result= p_result; + if (result == HA_ALTER_ERROR) + break; } - if (p_result < result) - result= p_result; - if (result == HA_ALTER_ERROR) - break; - } + } while (orig_ops != ha_alter_info->handler_flags); ha_alter_info->handler_ctx= part_inplace_ctx; /* -- cgit v1.2.1