summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Mathew <jacob.mathew@mariadb.com>2018-05-11 14:45:09 -0700
committerJacob Mathew <jacob.mathew@mariadb.com>2018-05-14 13:25:41 -0700
commit8e015986200241e300c07dfff331ecbb22b51335 (patch)
tree56b78596bfe3e8fcbd4f5ba360cbcb736371e8b4
parent1d30a23fcc38bc11f928f59a6c69ddebcf523870 (diff)
downloadmariadb-git-8e015986200241e300c07dfff331ecbb22b51335.tar.gz
MDEV-16101: ADD PARTITION on table partitioned by list does not work with more than 32 list values.bb-10.3-MDEV-16101
This problem occured because the reorganization of the list of values when the number of elements exceeds 32 was not handled correctly. I have fixed the problem by fixing the way that the list values are reorganized when the number of list values exceeds 32. Author: Jacob Mathew. Reviewer: Alexey Botchkov.
-rw-r--r--mysql-test/main/partition_list.result210
-rw-r--r--mysql-test/main/partition_list.test41
-rw-r--r--sql/partition_info.cc4
3 files changed, 254 insertions, 1 deletions
diff --git a/mysql-test/main/partition_list.result b/mysql-test/main/partition_list.result
index 91c1c106cea..f4cd1c9da43 100644
--- a/mysql-test/main/partition_list.result
+++ b/mysql-test/main/partition_list.result
@@ -334,3 +334,213 @@ f
1
drop table t1;
#end of 10.2 tests
+#
+# Bug MDEV-16101: More than MAX_REF_PARTS values in a list on ALTER TABLE.
+# Currently MAX_REF_PARTS = 32.
+CREATE TABLE ts1 (a INT, PRIMARY KEY (`a`))
+PARTITION BY LIST (`a`)
+(PARTITION `p ts_0` VALUES IN (101,102,103,104,105,106,107,108,109,110,
+111,112,113,114,115,116,117,118,119,120,
+121,122,123,124,125,126,127,128,129,130,
+131,132,133));
+INSERT INTO ts1
+VALUES (101), (102), (103), (104), (105), (106), (107), (108), (109), (110),
+(111), (112), (113), (114), (115), (116), (117), (118), (119), (120),
+(121), (122), (123), (124), (125), (126), (127), (128), (129), (130),
+(131), (132), (133);
+INSERT INTO ts1 VALUES (134);
+ERROR HY000: Table has no partition for value 134
+SELECT * FROM ts1;
+a
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+ALTER TABLE ts1 ADD PARTITION
+(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10,
+11,12,13,14,15,16,17,18,19,20,
+21,22,23,24,25,26,27,28,29,30,
+31,32,33));
+INSERT INTO ts1
+VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
+(11), (12), (13), (14), (15), (16), (17), (18), (19), (20),
+(21), (22), (23), (24), (25), (26), (27), (28), (29), (30),
+(31), (32), (33);
+INSERT INTO ts1 VALUES(34);
+ERROR HY000: Table has no partition for value 34
+SELECT * FROM ts1;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+ALTER TABLE ts1 REORGANIZE PARTITION `p ts_1` INTO
+(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10,
+11,12,13,14,15,16,17,18,19,20,
+21,22,23,24,25,26,27,28,29,30,
+31,32,33,34,35));
+INSERT INTO ts1 VALUES (34), (35);
+INSERT INTO ts1 VALUES (36);
+ERROR HY000: Table has no partition for value 36
+SELECT * FROM ts1;
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+DROP TABLE ts1;
diff --git a/mysql-test/main/partition_list.test b/mysql-test/main/partition_list.test
index e2b6aff300f..5eadb72a932 100644
--- a/mysql-test/main/partition_list.test
+++ b/mysql-test/main/partition_list.test
@@ -209,3 +209,44 @@ select * from t1 where f = 1;
drop table t1;
--echo #end of 10.2 tests
+
+--echo #
+--echo # Bug MDEV-16101: More than MAX_REF_PARTS values in a list on ALTER TABLE.
+--echo # Currently MAX_REF_PARTS = 32.
+CREATE TABLE ts1 (a INT, PRIMARY KEY (`a`))
+PARTITION BY LIST (`a`)
+(PARTITION `p ts_0` VALUES IN (101,102,103,104,105,106,107,108,109,110,
+ 111,112,113,114,115,116,117,118,119,120,
+ 121,122,123,124,125,126,127,128,129,130,
+ 131,132,133));
+INSERT INTO ts1
+VALUES (101), (102), (103), (104), (105), (106), (107), (108), (109), (110),
+ (111), (112), (113), (114), (115), (116), (117), (118), (119), (120),
+ (121), (122), (123), (124), (125), (126), (127), (128), (129), (130),
+ (131), (132), (133);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO ts1 VALUES (134);
+SELECT * FROM ts1;
+ALTER TABLE ts1 ADD PARTITION
+(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33));
+INSERT INTO ts1
+VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10),
+ (11), (12), (13), (14), (15), (16), (17), (18), (19), (20),
+ (21), (22), (23), (24), (25), (26), (27), (28), (29), (30),
+ (31), (32), (33);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO ts1 VALUES(34);
+SELECT * FROM ts1;
+ALTER TABLE ts1 REORGANIZE PARTITION `p ts_1` INTO
+(PARTITION `p ts_1` VALUES IN (1,2,3,4,5,6,7,8,9,10,
+ 11,12,13,14,15,16,17,18,19,20,
+ 21,22,23,24,25,26,27,28,29,30,
+ 31,32,33,34,35));
+INSERT INTO ts1 VALUES (34), (35);
+--error ER_NO_PARTITION_FOR_GIVEN_VALUE
+INSERT INTO ts1 VALUES (36);
+SELECT * FROM ts1;
+DROP TABLE ts1;
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 746d00ef8d1..946b800cca8 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -1800,9 +1800,11 @@ part_column_list_val *partition_info::add_column_value(THD *thd)
into the structure used for 1 column. After this we call
ourselves recursively which should always succeed.
*/
+ num_columns= curr_list_object;
if (!reorganize_into_single_field_col_val(thd))
{
- DBUG_RETURN(add_column_value(thd));
+ if (!init_column_part(thd))
+ DBUG_RETURN(add_column_value(thd));
}
DBUG_RETURN(NULL);
}