Commit bbd922b0 authored by Mikael Ronstrom's avatar Mikael Ronstrom

Removed column_list and fixed all issues relating to this change

parent aaa79d95
......@@ -405,14 +405,12 @@ create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
partition p1 values less than (10));
ERROR 42000: VALUES value must be of same type as partition function near '),
partition p1 values less than (10))' at line 3
ERROR HY000: VALUES value must be of same type as partition function
create table t1 (a bigint)
partition by list (a)
(partition p0 values in (0xFFFFFFFFFFFFFFFF),
partition p1 values in (10));
ERROR 42000: VALUES value must be of same type as partition function near '),
partition p1 values in (10))' at line 3
ERROR HY000: VALUES value must be of same type as partition function
create table t1 (a bigint unsigned)
partition by range (a)
(partition p0 values less than (100),
......@@ -1407,7 +1405,7 @@ DROP TABLE t1;
CREATE TABLE t1 (a int)
PARTITION BY RANGE(a)
(PARTITION p0 VALUES LESS THAN (NULL));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '))' at line 3
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
create table t1 (s1 int auto_increment primary key)
partition by list (s1)
(partition p1 values in (1),
......
......@@ -4,7 +4,7 @@ partition by key (a,a);
ERROR HY000: Duplicate partition field name a
create table t1 (a int, b int)
partition by list column_list(a,a)
( partition p values in (column_list(1,1)));
( partition p values in ((1,1)));
ERROR HY000: Duplicate partition field name a
create table t1 (a int signed)
partition by list (a)
......@@ -26,10 +26,8 @@ a
drop table t1;
create table t1 (a int signed)
partition by list column_list(a)
( partition p0 values in (column_list(1), column_list(3), column_list(5),
column_list(7), column_list(9), column_list(NULL)),
partition p1 values in (column_list(2), column_list(4), column_list(6),
column_list(8), column_list(0)));
( partition p0 values in (1, 3, 5, 7, 9, NULL),
partition p1 values in (2, 4, 6, 8, 0));
insert into t1 values (NULL),(0),(1),(2),(2),(4),(4),(4),(8),(8);
select * from t1 where a <= NULL;
a
......@@ -46,10 +44,9 @@ a
drop table t1;
create table t1 (a int, b int)
partition by list column_list(a,b)
( partition p0 values in (column_list(1, NULL), column_list(2, NULL),
column_list(NULL, NULL)),
partition p1 values in (column_list(1,1), column_list(2,2)),
partition p2 values in (column_list(3, NULL), column_list(NULL, 1)));
( partition p0 values in ((1, NULL), (2, NULL), (NULL, NULL)),
partition p1 values in ((1,1), (2,2)),
partition p2 values in ((3, NULL), (NULL, 1)));
insert into t1 values (3, NULL);
insert into t1 values (NULL, 1);
insert into t1 values (NULL, NULL);
......@@ -81,9 +78,9 @@ t1 CREATE TABLE `t1` (
`b` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMN_LIST(a,b)
(PARTITION p0 VALUES IN ( COLUMN_LIST(1,NULL), COLUMN_LIST(2,NULL), COLUMN_LIST(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ( COLUMN_LIST(1,1), COLUMN_LIST(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ( COLUMN_LIST(3,NULL), COLUMN_LIST(NULL,1)) ENGINE = MyISAM) */
(PARTITION p0 VALUES IN ((1,NULL),(2,NULL),(NULL,NULL)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ((1,1),(2,2)) ENGINE = MyISAM,
PARTITION p2 VALUES IN ((3,NULL),(NULL,1)) ENGINE = MyISAM) */
drop table t1;
create table t1 (a int)
partition by list (a)
......@@ -104,8 +101,13 @@ ERROR HY000: Table has no partition for value 5
drop table t1;
create table t1 (a int)
partition by list column_list(a)
( partition p0 values in (column_list(2), column_list(1)),
partition p1 values in (column_list(4), column_list(NULL), column_list(3)));
( partition p0 values in (2, 1),
partition p1 values in ((4), (NULL), (3)));
ERROR 42000: Row expressions in VALUES IN only allowed for multi-field column partitioning near '))' at line 4
create table t1 (a int)
partition by list column_list(a)
( partition p0 values in (2, 1),
partition p1 values in (4, NULL, 3));
insert into t1 values (1);
insert into t1 values (2);
insert into t1 values (3);
......@@ -119,26 +121,26 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
/*!50100 PARTITION BY LIST COLUMN_LIST(a)
(PARTITION p0 VALUES IN ( COLUMN_LIST(2), COLUMN_LIST(1)) ENGINE = MyISAM,
PARTITION p1 VALUES IN ( COLUMN_LIST(4), COLUMN_LIST(NULL), COLUMN_LIST(3)) ENGINE = MyISAM) */
(PARTITION p0 VALUES IN (2,1) ENGINE = MyISAM,
PARTITION p1 VALUES IN (4,NULL,3) ENGINE = MyISAM) */
drop table t1;
create table t1 (a int, b char(10), c varchar(25), d datetime)
partition by range column_list(a,b,c,d)
subpartition by hash (to_seconds(d))
subpartitions 4
( partition p0 values less than (column_list(1, NULL, MAXVALUE, NULL)),
partition p1 values less than (column_list(1, 'a', MAXVALUE, TO_DAYS('1999-01-01'))),
partition p2 values less than (column_list(1, 'a', MAXVALUE, MAXVALUE)),
partition p3 values less than (column_list(1, MAXVALUE, MAXVALUE, MAXVALUE)));
( partition p0 values less than (1, NULL, MAXVALUE, NULL),
partition p1 values less than (1, 'a', MAXVALUE, TO_DAYS('1999-01-01')),
partition p2 values less than (1, 'a', MAXVALUE, MAXVALUE),
partition p3 values less than (1, MAXVALUE, MAXVALUE, MAXVALUE));
drop table t1;
create table t1 (a int, b char(10), c varchar(5), d int)
partition by range column_list(a,b,c)
subpartition by key (c,d)
subpartitions 3
( partition p0 values less than (column_list(1,'abc','abc')),
partition p1 values less than (column_list(2,'abc','abc')),
partition p2 values less than (column_list(3,'abc','abc')),
partition p3 values less than (column_list(4,'abc','abc')));
( partition p0 values less than (1,'abc','abc'),
partition p1 values less than (2,'abc','abc'),
partition p2 values less than (3,'abc','abc'),
partition p3 values less than (4,'abc','abc'));
insert into t1 values (1,'a','b',1),(2,'a','b',2),(3,'a','b',3);
insert into t1 values (1,'b','c',1),(2,'b','c',2),(3,'b','c',3);
insert into t1 values (1,'c','d',1),(2,'c','d',2),(3,'c','d',3);
......@@ -151,8 +153,8 @@ a b c d
drop table t1;
create table t1 (a int, b varchar(2), c int)
partition by range column_list (a, b, c)
(partition p0 values less than (column_list(1, 'A', 1)),
partition p1 values less than (column_list(1, 'B', 1)));
(partition p0 values less than (1, 'A', 1),
partition p1 values less than (1, 'B', 1));
insert into t1 values (1, 'A', 1);
explain partitions select * from t1 where a = 1 AND b <= 'A' and c = 1;
id select_type table partitions type possible_keys key key_len ref rows Extra
......@@ -163,7 +165,7 @@ a b c
drop table t1;
create table t1 (a char, b char, c char)
partition by list column_list(a)
( partition p0 values in (column_list('a')));
( partition p0 values in ('a'));
insert into t1 (a) values ('a');
select * from t1 where a = 'a';
a b c
......@@ -171,32 +173,32 @@ a NULL NULL
drop table t1;
create table t1 (d timestamp)
partition by range column_list(d)
( partition p0 values less than (column_list('2000-01-01')),
partition p1 values less than (column_list('2040-01-01')));
( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2040-01-01'));
ERROR HY000: Partition column values of incorrect type
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (column_list(null, 10)));
(partition p0 values less than (null, 10));
drop table t1;
create table t1 (d date)
partition by range column_list(d)
( partition p0 values less than (column_list('2000-01-01')),
partition p1 values less than (column_list('2009-01-01')));
( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('2009-01-01'));
drop table t1;
create table t1 (d date)
partition by range column_list(d)
( partition p0 values less than (column_list('1999-01-01')),
partition p1 values less than (column_list('2000-01-01')));
( partition p0 values less than ('1999-01-01'),
partition p1 values less than ('2000-01-01'));
drop table t1;
create table t1 (d date)
partition by range column_list(d)
( partition p0 values less than (column_list('2000-01-01')),
partition p1 values less than (column_list('3000-01-01')));
( partition p0 values less than ('2000-01-01'),
partition p1 values less than ('3000-01-01'));
drop table t1;
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p2 values less than (column_list(99,99)),
partition p1 values less than (column_list(99,999)));
(partition p2 values less than (99,99),
partition p1 values less than (99,999));
insert into t1 values (99,998);
select * from t1 where b = 998;
a b
......@@ -210,23 +212,23 @@ int
drop table t1;
create table t1 (a int, b int)
partition by list column_list(a,b)
(partition p0 values in (column_list(maxvalue,maxvalue)));
(partition p0 values in ((maxvalue,maxvalue)));
ERROR 42000: Cannot use MAXVALUE as value in List partitioning near 'maxvalue,maxvalue)))' at line 3
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (column_list(maxvalue,maxvalue)));
(partition p0 values less than (maxvalue,maxvalue));
drop table t1;
create table t1 (a int)
partition by list column_list(a)
(partition p0 values in (column_list(0)));
(partition p0 values in (0));
select partition_method from information_schema.partitions where table_name='t1';
partition_method
LIST COLUMN_LIST
drop table t1;
create table t1 (a char(6))
partition by range column_list(a)
(partition p0 values less than (column_list('H23456')),
partition p1 values less than (column_list('M23456')));
(partition p0 values less than ('H23456'),
partition p1 values less than ('M23456'));
insert into t1 values ('F23456');
select * from t1;
a
......@@ -234,13 +236,13 @@ F23456
drop table t1;
create table t1 (a char(6))
partition by range column_list(a)
(partition p0 values less than (column_list(H23456)),
partition p1 values less than (column_list(M23456)));
(partition p0 values less than (H23456),
partition p1 values less than (M23456));
ERROR 42S22: Unknown column 'H23456' in 'field list'
create table t1 (a char(6))
partition by range column_list(a)
(partition p0 values less than (column_list(23456)),
partition p1 values less than (column_list(23456)));
(partition p0 values less than (23456),
partition p1 values less than (23456));
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
create table t1 (a int, b int)
partition by range column_list(a,b)
......@@ -248,14 +250,14 @@ partition by range column_list(a,b)
ERROR 42000: Inconsistency in usage of column lists for partitioning near '))' at line 3
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (column_list(1,1,1));
(partition p0 values less than (1,1,1);
ERROR HY000: Inconsistency in usage of column lists for partitioning
create table t1 (a int, b int)
partition by range column_list(a,b)
(partition p0 values less than (column_list(1, NULL)),
partition p1 values less than (column_list(2, maxvalue)),
partition p2 values less than (column_list(3, 3)),
partition p3 values less than (column_list(10, NULL)));
(partition p0 values less than (1, NULL),
partition p1 values less than (2, maxvalue),
partition p2 values less than (3, 3),
partition p3 values less than (10, NULL));
insert into t1 values (10,0);
ERROR HY000: Table has no partition for value from column_list
insert into t1 values (0,1),(1,1),(2,1),(3,1),(3,4),(4,9),(9,1);
......@@ -270,9 +272,9 @@ a b
9 1
alter table t1
partition by range column_list(b,a)
(partition p0 values less than (column_list(1,2)),
partition p1 values less than (column_list(3,3)),
partition p2 values less than (column_list(9,5)));
(partition p0 values less than (1,2),
partition p1 values less than (3,3),
partition p2 values less than (9,5));
explain partitions select * from t1 where b < 2;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 7 Using where
......@@ -294,21 +296,21 @@ a b
3 1
9 1
alter table t1 reorganize partition p1 into
(partition p11 values less than (column_list(2,2)),
partition p12 values less than (column_list(3,3)));
(partition p11 values less than (2,2),
partition p12 values less than (3,3));
alter table t1 reorganize partition p0 into
(partition p01 values less than (column_list(0,3)),
partition p02 values less than (column_list(1,1)));
(partition p01 values less than (0,3),
partition p02 values less than (1,1));
ERROR HY000: Reorganize of range partitions cannot change total ranges except for last partition where it can extend the range
alter table t1 reorganize partition p2 into
(partition p2 values less than(column_list(9,6,1)));
(partition p2 values less than(9,6,1));
ERROR HY000: Inconsistency in usage of column lists for partitioning
alter table t1 reorganize partition p2 into
(partition p2 values less than (10));
ERROR HY000: Inconsistency in usage of column lists for partitioning
alter table t1 reorganize partition p2 into
(partition p21 values less than (column_list(4,7)),
partition p22 values less than (column_list(9,5)));
(partition p21 values less than (4,7),
partition p22 values less than (9,5));
explain partitions select * from t1 where b < 4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p11,p12,p21 ALL NULL NULL NULL NULL 7 Using where
......@@ -324,13 +326,13 @@ create table t1 (a int, b int)
partition by list column_list(a,b)
subpartition by hash (b)
subpartitions 2
(partition p0 values in (column_list(0,0), column_list(1,1)),
partition p1 values in (column_list(1000,1000)));
(partition p0 values in ((0,0), (1,1)),
partition p1 values in ((1000,1000)));
insert into t1 values (1000,1000);
drop table t1;
create table t1 (a char, b char, c char)
partition by range column_list(a,b,c)
( partition p0 values less than (column_list('a','b','c')));
( partition p0 values less than ('a','b','c'));
alter table t1 add partition
(partition p1 values less than (column_list('b','c','d')));
(partition p1 values less than ('b','c','d'));
drop table t1;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
create table t1 (a char, b char, c char)
partition by range column_list(a,b,c)
( partition p0 values less than (column_list('a','b','c')));
( partition p0 values less than ('a','b','c'));
insert into t1 values ('a', NULL, 'd');
explain partitions select * from t1 where a = 'a' AND c = 'd';
id select_type table partitions type possible_keys key key_len ref rows Extra
......@@ -11,13 +11,13 @@ a b c
a NULL d
drop table t1;
create table t1 (a int not null) partition by range column_list(a) (
partition p0 values less than (column_list(10)),
partition p1 values less than (column_list(20)),
partition p2 values less than (column_list(30)),
partition p3 values less than (column_list(40)),
partition p4 values less than (column_list(50)),
partition p5 values less than (column_list(60)),
partition p6 values less than (column_list(70))
partition p0 values less than (10),
partition p1 values less than (20),
partition p2 values less than (30),
partition p3 values less than (40),
partition p4 values less than (50),
partition p5 values less than (60),
partition p6 values less than (70)
);
insert into t1 values (5),(15),(25),(35),(45),(55),(65);
insert into t1 values (5),(15),(25),(35),(45),(55),(65);
......@@ -41,15 +41,15 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
drop table t1, t2;
create table t1 (a int not null, b int not null )
partition by range column_list(a,b) (
partition p01 values less than (column_list(2,10)),
partition p02 values less than (column_list(2,20)),
partition p03 values less than (column_list(2,30)),
partition p11 values less than (column_list(4,10)),
partition p12 values less than (column_list(4,20)),
partition p13 values less than (column_list(4,30)),
partition p21 values less than (column_list(6,10)),
partition p22 values less than (column_list(6,20)),
partition p23 values less than (column_list(6,30))
partition p01 values less than (2,10),
partition p02 values less than (2,20),
partition p03 values less than (2,30),
partition p11 values less than (4,10),
partition p12 values less than (4,20),
partition p13 values less than (4,30),
partition p21 values less than (6,10),
partition p22 values less than (6,20),
partition p23 values less than (6,30)
);
insert into t1 values (2,5), (2,15), (2,25),
(4,5), (4,15), (4,25), (6,5), (6,15), (6,25);
......
......@@ -361,8 +361,7 @@ partition by range (a)
partitions 2
(partition x1 values less than (4.0) tablespace ts1,
partition x2 values less than (8) tablespace ts2);
ERROR 42000: VALUES value must be of same type as partition function near ') tablespace ts1,
partition x2 values less than (8) tablespace ts2)' at line 8
ERROR HY000: VALUES value must be of same type as partition function
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -412,8 +411,7 @@ partition by list (a)
partitions 2
(partition x1 values less than 4,
partition x2 values less than (5));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '4,
partition x2 values less than (5))' at line 8
ERROR HY000: Only RANGE PARTITIONING can use VALUES LESS THAN in partition definition
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -423,7 +421,7 @@ partition by range (a)
partitions 2
(partition x1 values less than maxvalue,
partition x2 values less than (5));
ERROR 42000: MAXVALUE can only be used in last partition definition near '))' at line 9
ERROR HY000: MAXVALUE can only be used in last partition definition
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -433,7 +431,7 @@ partition by range (a)
partitions 2
(partition x1 values less than maxvalue,
partition x2 values less than maxvalue);
ERROR 42000: MAXVALUE can only be used in last partition definition near 'maxvalue)' at line 9
ERROR HY000: MAXVALUE can only be used in last partition definition
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -602,8 +600,7 @@ partition by list (a)
partitions 2
(partition x1 values in (4.0, 12+8),
partition x2 values in (3, 21));
ERROR 42000: VALUES value must be of same type as partition function near ' 12+8),
partition x2 values in (3, 21))' at line 8
ERROR HY000: VALUES value must be of same type as partition function
CREATE TABLE t1 (
a int not null,
b int not null,
......
......@@ -24,8 +24,8 @@ data directory='/not/existing'
index directory='/not/existing'
);
Warnings:
Warning 1619 <DATA DIRECTORY> option ignored
Warning 1619 <INDEX DIRECTORY> option ignored
Warning 1618 <DATA DIRECTORY> option ignored
Warning 1618 <INDEX DIRECTORY> option ignored
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
......
......@@ -3,8 +3,7 @@ create table t1 (a int)
partition by range (a)
( partition p0 values less than (NULL),
partition p1 values less than (MAXVALUE));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '),
partition p1 values less than (MAXVALUE))' at line 3
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
create table t1 (a datetime not null)
partition by range (TO_SECONDS(a))
( partition p0 VALUES LESS THAN (TO_SECONDS('2007-03-08 00:00:00')),
......
......@@ -101,8 +101,8 @@ data directory='/not/existing'
index directory='/not/existing'
);
Warnings:
Warning 1619 <DATA DIRECTORY> option ignored
Warning 1619 <INDEX DIRECTORY> option ignored
Warning 1618 <DATA DIRECTORY> option ignored
Warning 1618 <INDEX DIRECTORY> option ignored
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
......
......@@ -13,4 +13,3 @@ kill : Bug#37780 2008-12-03 HHunger need some changes to be
innodb_bug39438 : Bug#42383 2009-01-28 lsoares "This fails in embedded and on windows. Note that this test is not run on windows and on embedded in PB for main trees currently"
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
init_connect : Bug#44920 2009-07-06 pcrews MTR not processing master.opt input properly on Windows. *Must be done this way due to the nature of the bug*
......@@ -339,12 +339,12 @@ drop table t1;
#
# BUG 16002: Handle unsigned integer functions properly
#
--error ER_PARSE_ERROR
--error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
create table t1 (a bigint)
partition by range (a)
(partition p0 values less than (0xFFFFFFFFFFFFFFFF),
partition p1 values less than (10));
--error ER_PARSE_ERROR
--error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
create table t1 (a bigint)
partition by list (a)
(partition p0 values in (0xFFFFFFFFFFFFFFFF),
......@@ -1377,7 +1377,7 @@ PARTITION BY LIST (a)
SHOW CREATE TABLE t1;
DROP TABLE t1;
--error ER_PARSE_ERROR
--error ER_NULL_IN_VALUES_LESS_THAN
CREATE TABLE t1 (a int)
PARTITION BY RANGE(a)
(PARTITION p0 VALUES LESS THAN (NULL));
......
......@@ -9,7 +9,7 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
create table t1 (a char, b char, c char)
partition by range column_list(a,b,c)
( partition p0 values less than (column_list('a','b','c')));
( partition p0 values less than ('a','b','c'));
insert into t1 values ('a', NULL, 'd');
explain partitions select * from t1 where a = 'a' AND c = 'd';
select * from t1 where a = 'a' AND c = 'd';
......@@ -17,13 +17,13 @@ drop table t1;
## COLUMN_LIST partition pruning tests
create table t1 (a int not null) partition by range column_list(a) (
partition p0 values less than (column_list(10)),
partition p1 values less than (column_list(20)),
partition p2 values less than (column_list(30)),
partition p3 values less than (column_list(40)),
partition p4 values less than (column_list(50)),
partition p5 values less than (column_list(60)),
partition p6 values less than (column_list(70))
partition p0 values less than (10),
partition p1 values less than (20),
partition p2 values less than (30),
partition p3 values less than (40),
partition p4 values less than (50),
partition p5 values less than (60),
partition p6 values less than (70)
);
insert into t1 values (5),(15),(25),(35),(45),(55),(65);
insert into t1 values (5),(15),(25),(35),(45),(55),(65);
......@@ -47,17 +47,17 @@ drop table t1, t2;
create table t1 (a int not null, b int not null )
partition by range column_list(a,b) (
partition p01 values less than (column_list(2,10)),
partition p02 values less than (column_list(2,20)),
partition p03 values less than (column_list(2,30)),
partition p01 values less than (2,10),
partition p02 values less than (2,20),
partition p03 values less than (2,30),
partition p11 values less than (column_list(4,10)),
partition p12 values less than (column_list(4,20)),
partition p13 values less than (column_list(4,30)),
partition p11 values less than (4,10),
partition p12 values less than (4,20),
partition p13 values less than (4,30),
partition p21 values less than (column_list(6,10)),
partition p22 values less than (column_list(6,20)),
partition p23 values less than (column_list(6,30))
partition p21 values less than (6,10),
partition p22 values less than (6,20),
partition p23 values less than (6,30)
);
insert into t1 values (2,5), (2,15), (2,25),
......
......@@ -452,7 +452,7 @@ partitions 2
#
# Partition by range, inconsistent partition function and constants
#
--error 1064
--error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -522,7 +522,7 @@ partitions 2
#
# Partition by range, missing parenthesis
#
--error 1064
--error ER_PARTITION_WRONG_VALUES_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -536,7 +536,7 @@ partitions 2
#
# Partition by range, maxvalue in wrong place
#
--error 1064
--error ER_PARTITION_MAXVALUE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -550,7 +550,7 @@ partitions 2
#
# Partition by range, maxvalue in several places
#
--error 1064
--error ER_PARTITION_MAXVALUE_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
......@@ -765,7 +765,7 @@ partitions 2
#
# Partition by list, wrong constant result type (not INT)
#
--error 1064
--error ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR
CREATE TABLE t1 (
a int not null,
b int not null,
......
......@@ -9,7 +9,7 @@
drop table if exists t1, t2;
--enable_warnings
--error ER_PARSE_ERROR
--error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int)
partition by range (a)
( partition p0 values less than (NULL),
......
......@@ -1577,11 +1577,58 @@ part_column_list_val *partition_info::add_column_value()
}
DBUG_RETURN(NULL);
}
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
if (column_list)
{
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
}
else
{
if (part_type == RANGE_PARTITION)
my_error(ER_TOO_MANY_VALUES_ERROR, MYF(0), "RANGE");
else
my_error(ER_TOO_MANY_VALUES_ERROR, MYF(0), "LIST");
}
DBUG_RETURN(NULL);
}
/*
Initialise part_elem_value object at setting of a new object
(Helper functions to functions called by parser)
SYNOPSIS
init_col_val
col_val Column value object to be initialised
item Item object representing column value
RETURN VALUES
TRUE Failure
FALSE Success
*/
void partition_info::init_col_val(part_column_list_val *col_val, Item *item)
{
DBUG_ENTER("partition_info::init_col_val");
col_val->item_expression= item;
col_val->null_value= item->null_value;
if (item->result_type() == INT_RESULT)
{
/*
This could be both column_list partitioning and function
partitioning, but it doesn't hurt to set the function
partitioning flags about unsignedness.
*/
curr_list_val->value= item->val_int();
curr_list_val->unsigned_flag= TRUE;
if (!item->unsigned_flag &&
curr_list_val->value < 0)
curr_list_val->unsigned_flag= FALSE;
if (!curr_list_val->unsigned_flag)
curr_part_elem->signed_flag= TRUE;
}
col_val->part_info= NULL;
DBUG_VOID_RETURN;
}
/*
Add a column value in VALUES LESS THAN or VALUES IN
(Called from parser)
......@@ -1589,15 +1636,19 @@ part_column_list_val *partition_info::add_column_value()
SYNOPSIS
add_column_list_value()
lex Parser's lex object
thd Thread object
item Item object representing column value
RETURN VALUES
TRUE Failure
FALSE Success
*/
bool partition_info::add_column_list_value(Item *item)
bool partition_info::add_column_list_value(THD *thd, Item *item)
{
part_column_list_val *col_val;
Name_resolution_context *context= &thd->lex->current_select->context;
TABLE_LIST *save_list= context->table_list;
const char *save_where= thd->where;
DBUG_ENTER("partition_info::add_column_list_value");
if (part_type == LIST_PARTITION &&
......@@ -1608,12 +1659,35 @@ bool partition_info::add_column_list_value(Item *item)
DBUG_RETURN(TRUE);
}
}
context->table_list= 0;
if (column_list)
thd->where= "field list";
else
thd->where= "partition function";
if (item->walk(&Item::check_partition_func_processor, 0,
NULL))
{
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
DBUG_RETURN(TRUE);
}
if (item->fix_fields(thd, (Item**)0) ||
((context->table_list= save_list), FALSE) ||
(!item->const_item()))
{
context->table_list= save_list;
thd->where= save_where;
my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
thd->where= save_where;
if (!(col_val= add_column_value()))
{
DBUG_RETURN(TRUE);
}
col_val->item_expression= item;
col_val->part_info= NULL;
init_col_val(col_val, item);
DBUG_RETURN(FALSE);
}
......@@ -1686,25 +1760,32 @@ bool partition_info::init_column_part()
*/
int partition_info::reorganize_into_single_field_col_val()
{
part_column_list_val *col_val;
Item *part_expr;
part_column_list_val *col_val, *new_col_val;
part_elem_value *val= curr_list_val;
uint loc_num_columns= num_columns;
uint i;
DBUG_ENTER("partition_info::reorganize_into_single_field_col_val");
num_columns= 1;
curr_list_val->added_items= 1U;
val->added_items= 1U;
col_val= &val->col_val_array[0];
init_col_val(col_val, col_val->item_expression);
for (i= 1; i < loc_num_columns; i++)
{
col_val= &curr_list_val->col_val_array[i];
part_expr= col_val->item_expression;
if ((part_type != LIST_PARTITION &&
init_column_part()) ||
add_column_list_value(part_expr))
col_val= &val->col_val_array[i];
DBUG_ASSERT(part_type == LIST_PARTITION);
if (init_column_part())
{
DBUG_RETURN(TRUE);
}
if (!(new_col_val= add_column_value()))
{
DBUG_RETURN(TRUE);
}
memcpy(new_col_val, col_val, sizeof(*col_val));
init_col_val(new_col_val, col_val->item_expression);
}
curr_list_val= val;
DBUG_RETURN(FALSE);
}
......@@ -1719,6 +1800,7 @@ int partition_info::reorganize_into_single_field_col_val()
thd Thread object
col_val Array of one value
part_elem The partition instance
part_id Id of partition instance
RETURN VALUES
TRUE Failure
......@@ -1726,9 +1808,9 @@ int partition_info::reorganize_into_single_field_col_val()
*/
int partition_info::fix_func_partition(THD *thd,
part_elem_value *val,
partition_element *part_elem)
partition_element *part_elem,
uint part_id)
{
uint i;
part_column_list_val *col_val= val->col_val_array;
DBUG_ENTER("partition_info::fix_func_partition");
......@@ -1750,7 +1832,7 @@ int partition_info::fix_func_partition(THD *thd,
my_error(ER_PARTITION_MAXVALUE_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
if (i == (num_parts - 1))
if (part_id == (num_parts - 1))
{
defined_max_value= TRUE;
part_elem->max_value= TRUE;
......@@ -1764,43 +1846,8 @@ int partition_info::fix_func_partition(THD *thd,
}
else
{
part_elem_value *value_ptr;
Name_resolution_context *context= &thd->lex->current_select->context;
TABLE_LIST *save_list= context->table_list;
const char *save_where= thd->where;
Item *item_expr= col_val->item_expression;
context->table_list= 0;
thd->where= "partition function";
value_ptr= (part_elem_value*)sql_alloc(sizeof(part_elem_value));
if (!value_ptr)
{
mem_alloc_error(sizeof(part_elem_value));
DBUG_RETURN(TRUE);
}
if (item_expr->walk(&Item::check_partition_func_processor, 0,
NULL))
{
my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
DBUG_RETURN(TRUE);
}
if (item_expr->fix_fields(thd, (Item**)0) ||
((context->table_list= save_list), FALSE) ||
(!item_expr->const_item()))
{
context->table_list= save_list;
thd->where= save_where;
my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
thd->where= save_where;
value_ptr->value= part_expr->val_int();
value_ptr->unsigned_flag= TRUE;
if (!item_expr->unsigned_flag &&
value_ptr->value < 0)
value_ptr->unsigned_flag= FALSE;
if ((value_ptr->null_value= item_expr->null_value))
if ((val->null_value= item_expr->null_value))
{
if (part_elem->has_null_value)
{
......@@ -1814,8 +1861,6 @@ int partition_info::fix_func_partition(THD *thd,
my_error(ER_INCONSISTENT_TYPE_OF_FUNCTIONS_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
if (!value_ptr->unsigned_flag)
part_elem->signed_flag= TRUE;
if (part_type == RANGE_PARTITION)
{
if (part_elem->has_null_value)
......@@ -1823,16 +1868,7 @@ int partition_info::fix_func_partition(THD *thd,
my_error(ER_NULL_IN_VALUES_LESS_THAN, MYF(0));
DBUG_RETURN(TRUE);
}
part_elem->range_value= value_ptr->value;
}
else if (part_type == LIST_PARTITION)
{
if (!value_ptr->null_value &&
part_elem->list_val_list.push_back(value_ptr))
{
mem_alloc_error(sizeof(part_elem_value));
DBUG_RETURN(TRUE);
}
part_elem->range_value= val->value;
}
}
col_val->fixed= 2;
......@@ -1860,11 +1896,8 @@ bool partition_info::fix_column_value_functions(THD *thd,
uint part_id)
{
uint num_columns= part_field_list.elements;
Name_resolution_context *context= &thd->lex->current_select->context;
TABLE_LIST *save_list= context->table_list;
bool result= FALSE;
uint i;
const char *save_where= thd->where;
part_column_list_val *col_val= val->col_val_array;
DBUG_ENTER("partition_info::fix_column_value_functions");
......@@ -1872,13 +1905,6 @@ bool partition_info::fix_column_value_functions(THD *thd,
{
DBUG_RETURN(FALSE);
}
if (val->added_items != num_columns)
{
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
context->table_list= 0;
thd->where= "partition function";
for (i= 0; i < num_columns; col_val++, i++)
{
Item *column_item= col_val->item_expression;
......@@ -1889,15 +1915,6 @@ bool partition_info::fix_column_value_functions(THD *thd,
col_val->column_value= NULL;
else
{
if (!col_val->fixed &&
(column_item->fix_fields(thd, (Item**)0) ||
(!column_item->const_item())))
{
my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
result= TRUE;
goto end;
}
col_val->null_value= column_item->null_value;
col_val->column_value= NULL;
if (!col_val->null_value)
{
......@@ -1922,8 +1939,6 @@ bool partition_info::fix_column_value_functions(THD *thd,
col_val->fixed= 2;
}
end:
thd->where= save_where;
context->table_list= save_list;
DBUG_RETURN(result);
}
......@@ -1989,22 +2004,40 @@ int partition_info::fix_parser_data(THD *thd)
do
{
part_elem= it++;
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
j= 0;
num_elements= part_elem->list_val_list.elements;
DBUG_ASSERT(part_type == RANGE_PARTITION ?
num_elements == 1U : TRUE);
do
{
List_iterator<part_elem_value> list_val_it(part_elem->list_val_list);
part_elem_value *val= list_val_it++;
result= column_list ?
fix_column_value_functions(thd, val, i) :
fix_func_partition(thd, val, part_elem);
if (result)
if (column_list)
{
DBUG_RETURN(TRUE);
if (val->added_items != num_columns)
{
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
}
else
{
if (fix_func_partition(thd, val, part_elem, i))
{
DBUG_RETURN(TRUE);
}
if (val->null_value)
{
/*
Null values aren't required in the value part, they are kept per
partition instance, only LIST partitions have NULL values.
*/
list_val_it.remove();
}
}
} while (++j < num_elements);
} while (++i < num_parts);
DBUG_RETURN(FALSE);
}
void partition_info::print_debug(const char *str, uint *value)
......
......@@ -283,12 +283,14 @@ public:
void print_debug(const char *str, uint*);
int fix_func_partition(THD *thd,
part_elem_value *val,
partition_element *part_elem);
partition_element *part_elem,
uint part_id);
bool fix_column_value_functions(THD *thd,
part_elem_value *val,
uint part_id);
int fix_parser_data(THD *thd);
int add_max_value();
void init_col_val(part_column_list_val *col_val, Item *item);
int reorganize_into_single_field_col_val();
part_column_list_val *add_column_value();
bool set_part_expr(char *start_token, Item *item_ptr,
......@@ -296,7 +298,7 @@ public:
static int compare_column_values(const void *a, const void *b);
bool set_up_charset_field_preps();
bool init_column_part();
bool add_column_list_value(Item *item);
bool add_column_list_value(THD *thd, Item *item);
private:
static int list_part_cmp(const void* a, const void* b);
bool set_up_default_partitions(handler *file, HA_CREATE_INFO *info,
......
......@@ -2007,14 +2007,6 @@ static int add_column_list_values(File fptr, partition_info *part_info,
char buffer[MAX_STR_SIZE_PF];
String str(buffer, sizeof(buffer), &my_charset_bin);
Item *item_expr= col_val->item_expression;
if (!col_val->fixed &&
(item_expr->fix_fields(current_thd, (Item**)0) ||
(!item_expr->const_item())))
{
my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
return 1;
}
col_val->fixed= 1;
if (item_expr->null_value)
err+= add_string(fptr, "NULL");
else
......@@ -4340,38 +4332,63 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
if ((alter_info->flags & ALTER_ADD_PARTITION) ||
(alter_info->flags & ALTER_REORGANIZE_PARTITION))
{
if ((tab_part_info->column_list &&
alt_part_info->num_columns != tab_part_info->num_columns) ||
(!tab_part_info->column_list && alt_part_info->num_columns))
if (thd->work_part_info->part_type != tab_part_info->part_type)
{
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
if ((thd->work_part_info->part_type != tab_part_info->part_type) &&
(thd->work_part_info->part_type != NOT_A_PARTITION))
{
if (thd->work_part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN");
}
else if (thd->work_part_info->part_type == LIST_PARTITION)
{
DBUG_ASSERT(thd->work_part_info->part_type == LIST_PARTITION);
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"LIST", "IN");
}
else if (tab_part_info->part_type == RANGE_PARTITION)
if (thd->work_part_info->part_type == NOT_A_PARTITION)
{
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN");
if (tab_part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "RANGE");
DBUG_RETURN(TRUE);
}
else if (tab_part_info->part_type == LIST_PARTITION)
{
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0), "LIST");
DBUG_RETURN(TRUE);
}
/*
Hash partitions can be altered without parser finds out about
that it is HASH partitioned. So no error here.
*/
}
else
{
DBUG_ASSERT(tab_part_info->part_type == LIST_PARTITION);
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"LIST", "IN");
if (thd->work_part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN");
}
else if (thd->work_part_info->part_type == LIST_PARTITION)
{
DBUG_ASSERT(thd->work_part_info->part_type == LIST_PARTITION);
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"LIST", "IN");
}
else if (tab_part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"RANGE", "LESS THAN");
}
else
{
DBUG_ASSERT(tab_part_info->part_type == LIST_PARTITION);
my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0),
"LIST", "IN");
}
DBUG_RETURN(TRUE);
}
}
if ((tab_part_info->column_list &&
alt_part_info->num_columns != tab_part_info->num_columns) ||
(!tab_part_info->column_list &&
(tab_part_info->part_type == RANGE_PARTITION ||
tab_part_info->part_type == LIST_PARTITION) &&
alt_part_info->num_columns != 1U) ||
(!tab_part_info->column_list &&
tab_part_info->part_type == HASH_PARTITION &&
alt_part_info->num_columns != 0))
{
my_error(ER_PARTITION_COLUMN_LIST_ERROR, MYF(0));
DBUG_RETURN(TRUE);
}
alt_part_info->column_list= tab_part_info->column_list;
......
/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -3870,6 +3870,7 @@ part_func:
partition_info *part_info= Lex->part_info;
if (part_info->set_part_expr($2+1, $3, $4, FALSE))
{ MYSQL_YYABORT; }
part_info->num_columns= 1;
part_info->column_list= FALSE;
}
;
......@@ -3972,7 +3973,21 @@ opt_num_subparts:
part_defs:
/* empty */
{}
{
partition_info *part_info= Lex->part_info;
if (part_info->part_type == RANGE_PARTITION)
{
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0),
"RANGE");
MYSQL_YYABORT;
}
else if (part_info->part_type == LIST_PARTITION)
{
my_error(ER_PARTITIONS_MUST_BE_DEFINED_ERROR, MYF(0),
"LIST");
MYSQL_YYABORT;
}
}
| '(' part_def_list ')'
{
partition_info *part_info= Lex->part_info;
......@@ -4081,7 +4096,7 @@ opt_part_values:
if (part_info->part_type != LIST_PARTITION)
{
my_error(ER_PARTITION_WRONG_VALUES_ERROR, MYF(0),
"LIST", "IN");
"LIST", "IN");
MYSQL_YYABORT;
}
}
......@@ -4099,6 +4114,7 @@ part_func_max:
if (part_info->num_columns &&
part_info->num_columns != 1U)
{
part_info->print_debug("Kilroy II", NULL);
my_parse_error(ER(ER_PARTITION_COLUMN_LIST_ERROR));
MYSQL_YYABORT;
}
......@@ -4121,6 +4137,7 @@ part_values_in:
{
LEX *lex= Lex;
partition_info *part_info= lex->part_info;
part_info->print_debug("part_values_in: part_value_item", NULL);
if (part_info->num_columns != 1U)
{
......@@ -4128,6 +4145,7 @@ part_values_in:
part_info->num_columns == 0 ||
part_info->num_columns > MAX_REF_PARTS)
{
part_info->print_debug("Kilroy III", NULL);
my_parse_error(ER(ER_PARTITION_COLUMN_LIST_ERROR));
MYSQL_YYABORT;
}
......@@ -4135,7 +4153,8 @@ part_values_in:
Reorganize the current large array into a list of small
arrays with one entry in each array. This can happen
in the first partition of an ALTER TABLE statement where
we ADD or REORGANIZE partitions.
we ADD or REORGANIZE partitions. Also can only happen
for LIST partitions.
*/
if (part_info->reorganize_into_single_field_col_val())
{
......@@ -4163,9 +4182,9 @@ part_value_item:
'('
{
partition_info *part_info= Lex->part_info;
part_info->print_debug("( part_value_item", NULL);
/* Initialisation code needed for each list of value expressions */
if (!(part_info->column_list &&
part_info->part_type == LIST_PARTITION &&
if (!(part_info->part_type == LIST_PARTITION &&
part_info->num_columns == 1U) &&
part_info->init_column_part())
{
......@@ -4177,7 +4196,7 @@ part_value_item:
{
LEX *lex= Lex;
partition_info *part_info= Lex->part_info;
part_info->print_debug(") part_value_item", NULL);
if (part_info->num_columns == 0)
part_info->num_columns= part_info->curr_list_object;
if (part_info->num_columns != part_info->curr_list_object)
......@@ -4189,6 +4208,7 @@ part_value_item:
ensures that we only report errors when we know we have an
error.
*/
part_info->print_debug("Kilroy I", NULL);
my_parse_error(ER(ER_PARTITION_COLUMN_LIST_ERROR));
MYSQL_YYABORT;
}
......@@ -4227,7 +4247,7 @@ part_value_expr_item:
my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
MYSQL_YYABORT;
}
if (part_info->add_column_list_value(part_expr))
if (part_info->add_column_list_value(YYTHD, part_expr))
{
MYSQL_YYABORT;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment