[Commits] 76d6fe1: Fixed problem of default partititon reorganizing

Oleksandr Byelkin sanja at mariadb.com
Tue Sep 6 23:52:11 EEST 2016


revision-id: 76d6fe1a0e37795d74dbc40661afb017bb7651f8 (mariadb-10.2.1-54-g76d6fe1)
parent(s): 531984686d9cd92da2b0f61cd362f220c5c2c012
committer: Oleksandr Byelkin
timestamp: 2016-09-06 22:52:11 +0200
message:

Fixed problem of default partititon reorganizing

---
 mysql-test/r/partition_default.result | 29 +++++++++++++++++++++++++++++
 mysql-test/t/partition_default.test   | 28 ++++++++++++++++++++++++++++
 sql/sql_partition.cc                  |  7 +++++--
 3 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/mysql-test/r/partition_default.result b/mysql-test/r/partition_default.result
index 51a8e44..09d7a65 100644
--- a/mysql-test/r/partition_default.result
+++ b/mysql-test/r/partition_default.result
@@ -866,6 +866,9 @@ 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` (
@@ -992,6 +995,9 @@ 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` (
@@ -1023,3 +1029,26 @@ alter table t1 add partition (PARTITION pdd DEFAULT,
 PARTITION pd DEFAULT);
 ERROR HY000: Only one DEFAULT partition allowed
 drop table t1;
+create table t1 (a int)
+PARTITION BY LIST (a)
+(
+PARTITION p2 VALUES IN (4,5,6),
+PARTITION p1 VALUES IN (1),
+PARTITION pd DEFAULT
+)
+;
+insert into t1 values (1),(2),(3),(4);
+select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table_name='t1';
+partition_name	table_rows
+p2	1
+p1	1
+pd	2
+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
+p2	1
+p1	1
+pd	0
+p0	2
+drop table t1;
diff --git a/mysql-test/t/partition_default.test b/mysql-test/t/partition_default.test
index dc4c58c..07f85fe 100644
--- a/mysql-test/t/partition_default.test
+++ b/mysql-test/t/partition_default.test
@@ -303,6 +303,9 @@ select * from t1;
 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;
@@ -361,6 +364,9 @@ select * from t1;
 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;
@@ -374,3 +380,25 @@ alter table t1 drop partition pd;
 alter table t1 add partition (PARTITION pdd DEFAULT,
                               PARTITION pd DEFAULT);
 drop table t1;
+
+
+#
+# Problem of reorganizing DEFAULT partition
+#
+create table t1 (a int)
+  PARTITION BY LIST (a)
+  (
+    PARTITION p2 VALUES IN (4,5,6),
+    PARTITION p1 VALUES IN (1),
+    PARTITION pd DEFAULT
+  )
+;
+insert into t1 values (1),(2),(3),(4);
+select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table_name='t1';
+
+alter table t1 add partition
+ (partition p0 VALUES IN (2,3));
+
+select partition_name, table_rows from INFORMATION_SCHEMA.PARTITIONS where table_name='t1';
+
+drop table t1;
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index f6246f9..fdbce23 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -4837,7 +4837,8 @@ 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)
+    if ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0 &&
+        !tab_part_info->has_default_partititon())
     {
       /*
         "Fast" change of partitioning is supported in this case.
@@ -4953,7 +4954,9 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
         my_error(ER_NO_BINLOG_ERROR, MYF(0));
         goto err;
       }
-      if (tab_part_info->defined_max_value)
+      if (tab_part_info->defined_max_value &&
+          (tab_part_info->part_type == RANGE_PARTITION ||
+           alt_part_info->defined_max_value))
       {
         my_error((tab_part_info->part_type == RANGE_PARTITION?
                   ER_PARTITION_MAXVALUE_ERROR:


More information about the commits mailing list