diff --git a/mysql-test/suite/parts/r/alter_table.result b/mysql-test/suite/parts/r/alter_table.result index ac8eba12f1b..5f532455219 100644 --- a/mysql-test/suite/parts/r/alter_table.result +++ b/mysql-test/suite/parts/r/alter_table.result @@ -59,4 +59,18 @@ index_name comment PRIMARY i2 disabled drop table t1; +# +# MDEV-34813 ALGORITHM=INSTANT does not work for partitioned tables on indexed column +# +CREATE TABLE `t1` ( +`f1` datetime , +`f2` VARCHAR(2) , +`f3` VARCHAR(200) , +`f4` VARCHAR(100) , +INDEX `i3` (`f4`) ) +PARTITION BY RANGE COLUMNS(`f2`) +(PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB, +PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB); +ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE; +drop table t1; # End of 10.5 tests diff --git a/mysql-test/suite/parts/t/alter_table.test b/mysql-test/suite/parts/t/alter_table.test index 37adb424d75..00ac3f0265e 100644 --- a/mysql-test/suite/parts/t/alter_table.test +++ b/mysql-test/suite/parts/t/alter_table.test @@ -52,4 +52,23 @@ alter table t1 add partition (partition p4); select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1'; drop table t1; +--echo # +--echo # MDEV-34813 ALGORITHM=INSTANT does not work for partitioned tables on indexed column +--echo # + +--source include/have_innodb.inc +CREATE TABLE `t1` ( + `f1` datetime , + `f2` VARCHAR(2) , + `f3` VARCHAR(200) , + `f4` VARCHAR(100) , + INDEX `i3` (`f4`) ) + PARTITION BY RANGE COLUMNS(`f2`) + (PARTITION `p_01` VALUES LESS THAN ('02') ENGINE = InnoDB, + PARTITION `p_31` VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB); + +ALTER online TABLE t1 MODIFY COLUMN `f4` VARCHAR(500) , ALGORITHM=INSTANT, LOCK=NONE; + +drop table t1; + --echo # End of 10.5 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 197f4fa51d6..95763eaf477 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -3178,6 +3178,24 @@ err1: DBUG_RETURN(true); } +Compare_keys ha_partition::compare_key_parts( + const Field &old_field, + const Column_definition &new_field, + const KEY_PART_INFO &old_part, + const KEY_PART_INFO &new_part) const +{ + Compare_keys res= m_file[0]->compare_key_parts(old_field, new_field, + old_part, new_part); + /* + Partitions have the same storage engine (until MDEV-22168) so the + calls should all return the same value for now. + */ + for (uint i= 1; i < m_tot_parts; i++) + if (res != m_file[i]->compare_key_parts(old_field, new_field, + old_part, new_part)) + return Compare_keys::NotEqual; + return res; +} /** Setup m_engine_array diff --git a/sql/ha_partition.h b/sql/ha_partition.h index b0321578d30..b8524dd15fb 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -481,6 +481,11 @@ public: m_part_info= part_info; m_is_sub_partitioned= part_info->is_sub_partitioned(); } + Compare_keys compare_key_parts( + const Field &old_field, + const Column_definition &new_field, + const KEY_PART_INFO &old_part, + const KEY_PART_INFO &new_part) const override; void return_record_by_parent() override;