@@ -7108,6 +7108,61 @@ commit_cache_rebuild(
71087108 DBUG_VOID_RETURN;
71097109}
71107110
7111+ /* * Store the column number of the columns in a list belonging
7112+ to indexes which are not being dropped.
7113+ @param[in] ctx In-place ALTER TABLE context
7114+ @param[in, out] drop_col_list list which will be set, containing columns
7115+ which is part of index being dropped */
7116+ static
7117+ void
7118+ get_col_list_to_be_dropped (
7119+ ha_innobase_inplace_ctx* ctx,
7120+ std::set<ulint>& drop_col_list)
7121+ {
7122+ for (ulint index_count = 0 ; index_count < ctx->num_to_drop_index ;
7123+ index_count++) {
7124+ dict_index_t * index = ctx->drop_index [index_count];
7125+
7126+ for (ulint col = 0 ; col < index->n_user_defined_cols ; col++) {
7127+ ulint col_no = dict_index_get_nth_col_no (index, col);
7128+ drop_col_list.insert (col_no);
7129+ }
7130+ }
7131+ }
7132+
7133+ /* * For each column, which is part of an index which is not going to be
7134+ dropped, it checks if the column number of the column is same as col_no
7135+ argument passed.
7136+ @param[in] table table object
7137+ @param[in] col_no column number of the column which is to be checked
7138+ @retval true column exists
7139+ @retval false column does not exist. */
7140+ static
7141+ bool
7142+ check_col_exists_in_indexes (
7143+ const dict_table_t * table,
7144+ ulint col_no)
7145+ {
7146+ for (dict_index_t * index = dict_table_get_first_index (table); index;
7147+ index = dict_table_get_next_index (index)) {
7148+
7149+ if (index->to_be_dropped ) {
7150+ continue ;
7151+ }
7152+
7153+ for (ulint col = 0 ; col < index->n_user_defined_cols ; col++) {
7154+
7155+ ulint index_col_no = dict_index_get_nth_col_no (
7156+ index, col);
7157+ if (col_no == index_col_no) {
7158+ return (true );
7159+ }
7160+ }
7161+ }
7162+
7163+ return (false );
7164+ }
7165+
71117166/* * Commit the changes made during prepare_inplace_alter_table()
71127167and inplace_alter_table() inside the data dictionary tables,
71137168when not rebuilding the table.
@@ -7141,6 +7196,21 @@ commit_try_norebuild(
71417196 || ctx->num_to_drop_vcol
71427197 == ha_alter_info->alter_info ->drop_list .elements );
71437198
7199+
7200+ std::set<ulint> drop_list;
7201+ std::set<ulint>::iterator col_no;
7202+
7203+ /* Check if the column, part of an index to be dropped is part of any
7204+ other index which is not being dropped. If it so, then set the ord_part
7205+ of the column to 0. */
7206+ get_col_list_to_be_dropped (ctx, drop_list);
7207+
7208+ for (col_no = drop_list.begin (); col_no != drop_list.end (); ++col_no) {
7209+ if (!check_col_exists_in_indexes (ctx->new_table , *col_no)) {
7210+ ctx->new_table ->cols [*col_no].ord_part = 0 ;
7211+ }
7212+ }
7213+
71447214 for (ulint i = 0 ; i < ctx->num_to_add_index ; i++) {
71457215 dict_index_t * index = ctx->add_index [i];
71467216 DBUG_ASSERT (dict_index_get_online_status (index)
0 commit comments