diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index bb0284a8f06..482e70fd8ec 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -1021,7 +1021,7 @@ insert into t2 values (0), (2); update t1 left join t2 on a > b set b= 2 order by b; drop table t1, t2; # -# MDEV-22153 ALTER add default history partitions breaks table +# MDEV-22153 ALTER add default history partitions makes table inaccessible # create or replace table t1 (x int) with system versioning partition by system_time; alter table t1 add partition partitions 1; @@ -1080,7 +1080,30 @@ pk f update t1 set f=pk; delete from t1; drop table t1; -# End of 10.5 tests -# Test cleanup -drop database test; -create database test; +# +# MDEV-22207 Drop default history partitions renders table inaccessible +# +create or replace table t1 (i int) with system versioning +partition by system_time limit 1 partitions 5; +alter table t1 drop partition p0, p2; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING + PARTITION BY SYSTEM_TIME LIMIT 1 +(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE, + PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE, + PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE) +alter table t1 add partition partitions 1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=DEFAULT_ENGINE DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING + PARTITION BY SYSTEM_TIME LIMIT 1 +(PARTITION `p1` HISTORY ENGINE = DEFAULT_ENGINE, + PARTITION `p3` HISTORY ENGINE = DEFAULT_ENGINE, + PARTITION `p2` HISTORY ENGINE = DEFAULT_ENGINE, + PARTITION `pn` CURRENT ENGINE = DEFAULT_ENGINE) +drop tables t1; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 417052c2bb1..c3825590ef2 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -854,7 +854,7 @@ update t1 left join t2 on a > b set b= 2 order by b; drop table t1, t2; --echo # ---echo # MDEV-22153 ALTER add default history partitions breaks table +--echo # MDEV-22153 ALTER add default history partitions makes table inaccessible --echo # create or replace table t1 (x int) with system versioning partition by system_time; alter table t1 add partition partitions 1; @@ -868,7 +868,6 @@ alter table t1 add partition partitions 3; show create table t1; drop tables t1; ---source suite/versioning/common_finish.inc --echo # --echo # MDEV-17091 Assertion `old_part_id == m_last_part' failed in --echo # ha_partition::update_row or `part_id == m_last_part' in @@ -890,8 +889,19 @@ update t1 set f=pk; delete from t1; drop table t1; ---echo # End of 10.5 tests +--echo # +--echo # MDEV-22207 Drop default history partitions renders table inaccessible +--echo # +create or replace table t1 (i int) with system versioning +partition by system_time limit 1 partitions 5; ---echo # Test cleanup -drop database test; -create database test; +alter table t1 drop partition p0, p2; +--replace_result $default_engine DEFAULT_ENGINE +show create table t1; +alter table t1 add partition partitions 1; +--replace_result $default_engine DEFAULT_ENGINE +show create table t1; + +drop tables t1; + +--source suite/versioning/common_finish.inc diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index d6c7066e655..66860762f08 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -5379,6 +5379,7 @@ that are reorganised. my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str); goto err; } + tab_part_info->use_default_partitions= false; } else {