diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2017-04-04 14:47:58 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2017-04-07 13:23:01 +0200 |
commit | b3ff3a6333853a4dc55fdebc3e80332559266270 (patch) | |
tree | c06dd4202cc0f3cd1e68182f536386880f98cf34 | |
parent | 85da56bf2dc983b346089f463f2cce1552b0d3bf (diff) | |
download | mariadb-git-bb-10.2-MDEV-12395.tar.gz |
MDEV-12395: DROP PARTITION does not work as expected when table has DEFAULT LIST partitionbb-10.2-MDEV-12395
Data loss in case of partituon removing is documented => do not try to prevent it
-rw-r--r-- | mysql-test/r/partition_default.result | 48 | ||||
-rw-r--r-- | mysql-test/t/partition_default.test | 32 | ||||
-rw-r--r-- | sql/sql_partition.cc | 3 |
3 files changed, 67 insertions, 16 deletions
diff --git a/mysql-test/r/partition_default.result b/mysql-test/r/partition_default.result index 2833d92de32..bb0a5d4061b 100644 --- a/mysql-test/r/partition_default.result +++ b/mysql-test/r/partition_default.result @@ -921,9 +921,6 @@ explain partitions select * from t1 where a=10 and b=10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0 system NULL NULL NULL NULL 1 alter table t1 drop partition p2; -ERROR HY000: Table has no partition for value 2 -delete from t1 where a=2; -alter table t1 drop partition p2; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1069,9 +1066,6 @@ explain partitions select * from t1 where a=10 and b=10; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0 system NULL NULL NULL NULL 1 alter table t1 drop partition p2; -ERROR HY000: Table has no partition for value from column_list -delete from t1 where a=2; -alter table t1 drop partition p2; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -1125,10 +1119,10 @@ alter table t1 add partition (partition p0 VALUES IN (2,3)); select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table_name='t1'; partition_name table_rows -p0 2 +p0 0 p1 1 p2 1 -pd 0 +pd 2 drop table t1; create table t1 (a int, b int) PARTITION BY LIST COLUMNS(a,b) @@ -1233,3 +1227,41 @@ select * from t1 where i is null; id select_type table partitions type possible_keys key key_len ref rows Extra 1 SIMPLE t1 p0 system NULL NULL NULL NULL 1 drop table t1; +# +# MDEV-12395: DROP PARTITION does not work as expected when +# table has DEFAULT LIST partition +# +CREATE TABLE t1 (i INT) +PARTITION BY LIST (i) +(PARTITION p VALUES IN (1,2,3,4), +PARTITION pdef DEFAULT); +INSERT INTO t1 VALUES (1),(10); +ALTER TABLE t1 DROP PARTITION p; +SELECT * FROM t1; +i +10 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY LIST (i) +(PARTITION pdef DEFAULT ENGINE = MyISAM) +DROP TABLE t1; +CREATE TABLE t1 (i INT) +PARTITION BY LIST (i) +(PARTITION p VALUES IN (1,2,3,4), +PARTITION pdef DEFAULT); +INSERT INTO t1 VALUES (1),(10); +ALTER TABLE t1 DROP PARTITION pdef; +SELECT * FROM t1; +i +1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `i` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY LIST (i) +(PARTITION p VALUES IN (1,2,3,4) ENGINE = MyISAM) +DROP TABLE t1; diff --git a/mysql-test/t/partition_default.test b/mysql-test/t/partition_default.test index 1110b311c29..b0424f567e4 100644 --- a/mysql-test/t/partition_default.test +++ b/mysql-test/t/partition_default.test @@ -326,9 +326,6 @@ select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table explain partitions select * from t1 where a=2 and b=5; explain partitions select * from t1 where a=10 and b=10; ---error ER_NO_PARTITION_FOR_GIVEN_VALUE -alter table t1 drop partition p2; -delete from t1 where a=2; alter table t1 drop partition p2; show create table t1; select * from t1; @@ -395,9 +392,6 @@ select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table explain partitions select * from t1 where a=2 and b=5; explain partitions select * from t1 where a=10 and b=10; ---error ER_NO_PARTITION_FOR_GIVEN_VALUE -alter table t1 drop partition p2; -delete from t1 where a=2; alter table t1 drop partition p2; show create table t1; select * from t1; @@ -520,3 +514,29 @@ explain partitions select * from t1 where i is null; drop table t1; + + +--echo # +--echo # MDEV-12395: DROP PARTITION does not work as expected when +--echo # table has DEFAULT LIST partition +--echo # + +CREATE TABLE t1 (i INT) + PARTITION BY LIST (i) + (PARTITION p VALUES IN (1,2,3,4), + PARTITION pdef DEFAULT); +INSERT INTO t1 VALUES (1),(10); +ALTER TABLE t1 DROP PARTITION p; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 (i INT) + PARTITION BY LIST (i) + (PARTITION p VALUES IN (1,2,3,4), + PARTITION pdef DEFAULT); +INSERT INTO t1 VALUES (1),(10); +ALTER TABLE t1 DROP PARTITION pdef; +SELECT * FROM t1; +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 4e71e792a08..0a146aeb12b 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -4842,8 +4842,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0)); goto err; } - if ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0 && - !tab_part_info->has_default_partititon()) + if ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0) { /* "Fast" change of partitioning is supported in this case. |