Commit 072c13d9 authored by Mikael Ronstrom's avatar Mikael Ronstrom

Merged WL#3352 into mysql-next-mr

parents cd6e1598 10fed1ac
......@@ -420,14 +420,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),
......@@ -1421,7 +1419,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),
......
This diff is collapsed.
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 ('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
1 SIMPLE t1 p0 system NULL NULL NULL NULL 1
select * from t1 where a = 'a' AND c = 'd';
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 (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);
create table t2 (a int not null) partition by range(a) (
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 t2 values (5),(15),(25),(35),(45),(55),(65);
insert into t2 values (5),(15),(25),(35),(45),(55),(65);
explain partitions select * from t1 where a > 35 and a < 45;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p3,p4 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t2 where a > 35 and a < 45;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t2 p3,p4 ALL NULL NULL NULL NULL 4 Using where
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 (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);
insert into t1 select * from t1;
explain partitions select * from t1 where a=2;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p01,p02,p03,p11 ALL NULL NULL NULL NULL 13 Using where
explain partitions select * from t1 where a=4;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p11,p12,p13,p21 ALL NULL NULL NULL NULL 16 Using where
explain partitions select * from t1 where a=2 and b < 22;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p01,p02,p03 ALL NULL NULL NULL NULL 16 Using where
drop table t1;
......@@ -273,7 +273,7 @@ select * from t1 where a = 'y';
a
y
drop table t1;
create table t1 (a varchar(65531)) partition by key (a);
create table t1 (a varchar(3068)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
......@@ -286,7 +286,7 @@ select * from t1 where a = 'bbbb';
a
bbbb
drop table t1;
create table t1 (a varchar(65532)) partition by key (a);
create table t1 (a varchar(3069)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
......@@ -299,7 +299,7 @@ select * from t1 where a = 'bbbb';
a
bbbb
drop table t1;
create table t1 (a varchar(65533) not null) partition by key (a);
create table t1 (a varchar(3070) not null) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
......@@ -312,6 +312,8 @@ select * from t1 where a = 'bbbb';
a
bbbb
drop table t1;
create table t1 (a varchar(3070)) partition by key (a);
ERROR HY000: The total length of the partitioning fields is too large
create table t1 (a varchar(65533)) partition by key (a);
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
create table t1 (a varchar(65534) not null) partition by key (a);
......
......@@ -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,
......
drop table if exists t1;
create table t1 (a varchar(5))
engine=memory
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=myisam
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=innodb
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a int not null,
b datetime not null,
primary key (a,b))
......
......@@ -54,6 +54,17 @@ subpartitions 2
partition p1 values in (1),
partition pnull values in (null, 2),
partition p3 values in (3));
select partition_method, partition_expression, partition_description
from information_schema.partitions where table_name = "t1";
partition_method partition_expression partition_description
LIST a 0
LIST a 0
LIST a 1
LIST a 1
LIST a NULL,2
LIST a NULL,2
LIST a 3
LIST a 3
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
insert into t1 values (2,0),(2,1),(3,0),(3,1);
explain partitions select * from t1 where a is null;
......
......@@ -41,7 +41,7 @@ ERROR HY000: Reorganize of range partitions cannot change total ranges except fo
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (4),
PARTITION x11 VALUES LESS THAN (2));
ERROR HY000: Reorganize of range partitions cannot change total ranges except for last partition where it can extend the range
ERROR HY000: VALUES LESS THAN value must be strictly increasing for each partition
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (6),
PARTITION x11 VALUES LESS THAN (4));
......
This diff is collapsed.
drop table if exists t1, t2;
create table t1 (a int)
partition by range (a)
( partition p0 values less than (NULL),
partition p1 values less than (MAXVALUE));
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')),
partition p1 VALUES LESS THAN (TO_SECONDS('2007-04-01 00:00:00')));
select partition_method, partition_expression, partition_description
from information_schema.partitions where table_name = "t1";
partition_method partition_expression partition_description
RANGE TO_SECONDS(a) 63340531200
RANGE TO_SECONDS(a) 63342604800
INSERT INTO t1 VALUES ('2007-03-01 12:00:00'), ('2007-03-07 12:00:00');
INSERT INTO t1 VALUES ('2007-03-08 12:00:00'), ('2007-03-15 12:00:00');
explain partitions select * from t1 where a < '2007-03-08 00:00:00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 2 Using where
explain partitions select * from t1 where a < '2007-03-08 00:00:01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a <= '2007-03-08 00:00:00';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a <= '2007-03-07 23:59:59';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
explain partitions select * from t1 where a < '2007-03-07 23:59:59';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
drop table t1;
create table t1 (a date)
partition by range(to_seconds(a))
(partition p0 values less than (to_seconds('2004-01-01')),
partition p1 values less than (to_seconds('2005-01-01')));
insert into t1 values ('2003-12-30'),('2004-12-31');
select * from t1;
a
2003-12-30
2004-12-31
explain partitions select * from t1 where a <= '2003-12-31';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 system NULL NULL NULL NULL 1
select * from t1 where a <= '2003-12-31';
a
2003-12-30
explain partitions select * from t1 where a <= '2005-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where
select * from t1 where a <= '2005-01-01';
a
2003-12-30
2004-12-31
drop table t1;
create table t1 (a datetime)
partition by range(to_seconds(a))
(partition p0 values less than (to_seconds('2004-01-01 12:00:00')),
partition p1 values less than (to_seconds('2005-01-01 12:00:00')));
insert into t1 values ('2004-01-01 11:59:29'),('2005-01-01 11:59:59');
select * from t1;
a
2004-01-01 11:59:29
2005-01-01 11:59:59
explain partitions select * from t1 where a <= '2004-01-01 11:59.59';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 system NULL NULL NULL NULL 1
select * from t1 where a <= '2004-01-01 11:59:59';
a
2004-01-01 11:59:29
explain partitions select * from t1 where a <= '2005-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0,p1 ALL NULL NULL NULL NULL 2 Using where
select * from t1 where a <= '2005-01-01';
a
2004-01-01 11:59:29
drop table t1;
create table t1 (a int, b char(20))
partition by range column_list(a,b)
(partition p0 values less than (1));
ERROR 42000: Inconsistency in usage of column lists for partitioning near '))' at line 3
create table t1 (a int, b char(20))
partition by range(a)
(partition p0 values less than (1,"b"));
ERROR HY000: Cannot have more than one value for this type of RANGE partitioning
create table t1 (a int, b char(20))
partition by range(a)
(partition p0 values less than (1,"b"));
ERROR HY000: Cannot have more than one value for this type of RANGE partitioning
create table t1 (a int, b char(20))
partition by range column_list(b)
(partition p0 values less than ("b"));
drop table t1;
create table t1 (a int)
partition by range (a)
( partition p0 values less than (maxvalue));
alter table t1 add partition (partition p1 values less than (100000));
ERROR HY000: MAXVALUE can only be used in last partition definition
......
--error ER_TOO_MANY_KEY_PARTS
--error ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, a2 date not null, b2 varchar(50) not null, c2 varchar(50) not null, d2 enum('m', 'w') not null, e2 int not null, f2 decimal (18,2) not null, g2 bigint not null, h2 tinyint not null, a3 date not null, b3 varchar(50) not null, c3 varchar(50) not null, d3 enum('m', 'w') not null, e3 int not null, f3 decimal (18,2) not null, g3 bigint not null, h3 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a2,b2,c2,d2,e2,f2,g2,h2,a3,b3,c3,d3,e3,f3,g3,h3)) engine=$engine
partition by key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a2,b2,c2,d2,e2,f2,g2,h2,a3,b3,c3,d3,e3,f3,g3,h3) (
partition pa1 max_rows=20 min_rows=2,
......
......@@ -312,7 +312,7 @@ PARTITION BY RANGE(f_int1)
--echo #------------------------------------------------------------------------
--echo # 3.5.1 NULL in RANGE partitioning clause
--echo # 3.5.1.1 VALUE LESS THAN (NULL) is not allowed
--error ER_PARSE_ERROR
--error ER_NULL_IN_VALUES_LESS_THAN
eval CREATE TABLE t1 (
$column_list
)
......@@ -320,7 +320,7 @@ PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (NULL),
PARTITION part2 VALUES LESS THAN (1000));
--echo # 3.5.1.2 VALUE LESS THAN (NULL) is not allowed
--error ER_PARSE_ERROR
--error ER_NULL_IN_VALUES_LESS_THAN
eval CREATE TABLE t1 (
$column_list
)
......
......@@ -133,7 +133,7 @@ partition pa1 max_rows=20 min_rows=2,
partition pa2 max_rows=30 min_rows=3,
partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
ERROR 42000: Too many key parts specified; max 16 parts allowed
ERROR HY000: Too many fields in 'list of partition fields'
create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, a2 date not null, b2 varchar(50) not null, c2 varchar(50) not null, d2 enum('m', 'w') not null, e2 int not null, f2 decimal (18,2) not null, g2 bigint not null, h2 tinyint not null, a3 date not null, b3 varchar(50) not null, c3 varchar(50) not null, d3 enum('m', 'w') not null, e3 int not null, f3 decimal (18,2) not null, g3 bigint not null, h3 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1)) engine='InnoDB'
partition by key(a,b,c,d,e,f,g,h) (
partition pa1 max_rows=20 min_rows=2,
......
......@@ -133,7 +133,7 @@ partition pa1 max_rows=20 min_rows=2,
partition pa2 max_rows=30 min_rows=3,
partition pa3 max_rows=30 min_rows=4,
partition pa4 max_rows=40 min_rows=2);
ERROR 42000: Too many key parts specified; max 16 parts allowed
ERROR HY000: Too many fields in 'list of partition fields'
create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, a2 date not null, b2 varchar(50) not null, c2 varchar(50) not null, d2 enum('m', 'w') not null, e2 int not null, f2 decimal (18,2) not null, g2 bigint not null, h2 tinyint not null, a3 date not null, b3 varchar(50) not null, c3 varchar(50) not null, d3 enum('m', 'w') not null, e3 int not null, f3 decimal (18,2) not null, g3 bigint not null, h3 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1)) engine='MyISAM'
partition by key(a,b,c,d,e,f,g,h) (
partition pa1 max_rows=20 min_rows=2,
......
......@@ -610,8 +610,7 @@ f_charbig VARCHAR(1000)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (NULL),
PARTITION part2 VALUES LESS THAN (1000));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '),
PARTITION part2 VALUES LESS THAN (1000))' at line 9
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
# 3.5.1.2 VALUE LESS THAN (NULL) is not allowed
CREATE TABLE t1 (
f_int1 INTEGER,
......@@ -623,8 +622,7 @@ f_charbig VARCHAR(1000)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (NULL),
PARTITION part2 VALUES LESS THAN (1000));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '),
PARTITION part2 VALUES LESS THAN (1000))' at line 9
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
# 3.5.2 NULL in LIST partitioning clause
# 3.5.2.1 VALUE IN (NULL)
CREATE TABLE t1 (
......
......@@ -610,8 +610,7 @@ f_charbig VARCHAR(1000)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (NULL),
PARTITION part2 VALUES LESS THAN (1000));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '),
PARTITION part2 VALUES LESS THAN (1000))' at line 9
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
# 3.5.1.2 VALUE LESS THAN (NULL) is not allowed
CREATE TABLE t1 (
f_int1 INTEGER,
......@@ -623,8 +622,7 @@ f_charbig VARCHAR(1000)
PARTITION BY RANGE(f_int1)
( PARTITION part1 VALUES LESS THAN (NULL),
PARTITION part2 VALUES LESS THAN (1000));
ERROR 42000: Not allowed to use NULL value in VALUES LESS THAN near '),
PARTITION part2 VALUES LESS THAN (1000))' at line 9
ERROR HY000: Not allowed to use NULL value in VALUES LESS THAN
# 3.5.2 NULL in LIST partitioning clause
# 3.5.2.1 VALUE IN (NULL)
CREATE TABLE t1 (
......
......@@ -352,12 +352,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),
......@@ -1390,7 +1390,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));
......
This diff is collapsed.
#
# Partition pruning tests for new COLUMN LIST feature
#
-- source include/have_partition.inc
--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
create table t1 (a char, b char, c char)
partition by range 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';
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 (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);
create table t2 (a int not null) partition by range(a) (
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 t2 values (5),(15),(25),(35),(45),(55),(65);
insert into t2 values (5),(15),(25),(35),(45),(55),(65);
explain partitions select * from t1 where a > 35 and a < 45;
explain partitions select * from t2 where a > 35 and a < 45;
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 (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);
insert into t1 select * from t1;
explain partitions select * from t1 where a=2;
explain partitions select * from t1 where a=4;
explain partitions select * from t1 where a=2 and b < 22;
drop table t1;
......@@ -4,6 +4,7 @@
# as partition by key
# Created to verify the fix for Bug#31705
# Partitions: crash if varchar length > 65530
# BUG#48164 limited size to 3072 bytes
#
-- source include/have_partition.inc
......@@ -192,27 +193,29 @@ create table t1 (a set('y','n')) partition by key (a);
insert into t1 values ('y');
select * from t1 where a = 'y';
drop table t1;
create table t1 (a varchar(65531)) partition by key (a);
create table t1 (a varchar(3068)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
create table t1 (a varchar(65532)) partition by key (a);
create table t1 (a varchar(3069)) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
create table t1 (a varchar(65533) not null) partition by key (a);
create table t1 (a varchar(3070) not null) partition by key (a);
insert into t1 values ('bbbb');
insert into t1 values ('aaaa');
select * from t1 where a = 'aaaa';
select * from t1 where a like 'aaa%';
select * from t1 where a = 'bbbb';
drop table t1;
-- error ER_PARTITION_FIELDS_TOO_LONG
create table t1 (a varchar(3070)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
create table t1 (a varchar(65533)) partition by key (a);
-- error ER_TOO_BIG_ROWSIZE
......
......@@ -180,7 +180,7 @@ partitions 3
(partition x1, partition x2);
#
# Partition by key specified 3 partitions but only defined 2 => error
# Partition by hash, random function
#
--error 1064
CREATE TABLE t1 (
......@@ -193,7 +193,7 @@ partitions 2
(partition x1, partition x2);
#
# Partition by key specified 3 partitions but only defined 2 => error
# Partition by range, random function
#
--error 1064
CREATE TABLE t1 (
......@@ -206,7 +206,7 @@ partitions 2
(partition x1 values less than (0), partition x2 values less than (2));
#
# Partition by key specified 3 partitions but only defined 2 => error
# Partition by list, random function
#
--error 1064
CREATE TABLE t1 (
......@@ -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,
......
......@@ -5,6 +5,36 @@
drop table if exists t1;
--enable_warnings
#
# BUG#47776, Failed to update for MEMORY engine, crash for InnoDB and success for MyISAM
#
create table t1 (a varchar(5))
engine=memory
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=myisam
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
create table t1 (a varchar(5))
engine=innodb
partition by range column_list(a)
( partition p0 values less than ('m'),
partition p1 values less than ('za'));
insert into t1 values ('j');
update t1 set a = 'z' where (a >= 'j');
drop table t1;
#
# Bug#47029: Crash when reorganize partition with subpartition
#
......
......@@ -40,6 +40,8 @@ subpartitions 2
partition p1 values in (1),
partition pnull values in (null, 2),
partition p3 values in (3));
select partition_method, partition_expression, partition_description
from information_schema.partitions where table_name = "t1";
insert into t1 values (0,0),(0,1),(1,0),(1,1),(null,0),(null,1);
insert into t1 values (2,0),(2,1),(3,0),(3,1);
......
......@@ -61,7 +61,7 @@ ALTER TABLE t1 REORGANIZE PARTITION x0, x1, x1 INTO
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (5));
--error ER_REORG_OUTSIDE_RANGE
--error ER_RANGE_NOT_INCREASING_ERROR
ALTER TABLE t1 REORGANIZE PARTITION x0,x1 INTO
(PARTITION x01 VALUES LESS THAN (4),
PARTITION x11 VALUES LESS THAN (2));
......
......@@ -51,6 +51,26 @@ INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'),
ALTER TABLE t1 DROP KEY a;
--source include/partition_date_range.inc
DROP TABLE t1;
--echo # TO_SECONDS, test of LIST and index
CREATE TABLE t1 (a DATE, KEY(a))
PARTITION BY LIST (TO_SECONDS(a))
(PARTITION `p0001-01-01` VALUES IN (TO_SECONDS('0001-01-01')),
PARTITION `p2001-01-01` VALUES IN (TO_SECONDS('2001-01-01')),
PARTITION `pNULL` VALUES IN (NULL),
PARTITION `p0000-01-02` VALUES IN (TO_SECONDS('0000-01-02')),
PARTITION `p1001-01-01` VALUES IN (TO_SECONDS('1001-01-01')));
if ($verify_without_partitions)
{
ALTER TABLE t1 REMOVE PARTITIONING;
}
INSERT INTO t1 VALUES ('0000-00-00'), ('0000-01-02'), ('0001-01-01'),
('1001-00-00'), ('1001-01-01'), ('1002-00-00'), ('2001-01-01');
--source include/partition_date_range.inc
--echo # test without index
ALTER TABLE t1 DROP KEY a;
--source include/partition_date_range.inc
DROP TABLE t1;
#
# Bug#46362: Endpoint should be set to false for TO_DAYS(DATE)
......
......@@ -9,6 +9,78 @@
drop table if exists t1, t2;
--enable_warnings
--error ER_NULL_IN_VALUES_LESS_THAN
create table t1 (a int)
partition by range (a)
( partition p0 values less than (NULL),
partition p1 values less than (MAXVALUE));
#
# Merge fix of bug#27927 for TO_SECONDS function
#
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')),
partition p1 VALUES LESS THAN (TO_SECONDS('2007-04-01 00:00:00')));
select partition_method, partition_expression, partition_description
from information_schema.partitions where table_name = "t1";
INSERT INTO t1 VALUES ('2007-03-01 12:00:00'), ('2007-03-07 12:00:00');
INSERT INTO t1 VALUES ('2007-03-08 12:00:00'), ('2007-03-15 12:00:00');
explain partitions select * from t1 where a < '2007-03-08 00:00:00';
explain partitions select * from t1 where a < '2007-03-08 00:00:01';
explain partitions select * from t1 where a <= '2007-03-08 00:00:00';
explain partitions select * from t1 where a <= '2007-03-07 23:59:59';
explain partitions select * from t1 where a < '2007-03-07 23:59:59';
drop table t1;
#
# New test cases for new function to_seconds
#
create table t1 (a date)
partition by range(to_seconds(a))
(partition p0 values less than (to_seconds('2004-01-01')),
partition p1 values less than (to_seconds('2005-01-01')));
insert into t1 values ('2003-12-30'),('2004-12-31');
select * from t1;
explain partitions select * from t1 where a <= '2003-12-31';
select * from t1 where a <= '2003-12-31';
explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01';
drop table t1;
create table t1 (a datetime)
partition by range(to_seconds(a))
(partition p0 values less than (to_seconds('2004-01-01 12:00:00')),
partition p1 values less than (to_seconds('2005-01-01 12:00:00')));
insert into t1 values ('2004-01-01 11:59:29'),('2005-01-01 11:59:59');
select * from t1;
explain partitions select * from t1 where a <= '2004-01-01 11:59.59';
select * from t1 where a <= '2004-01-01 11:59:59';
explain partitions select * from t1 where a <= '2005-01-01';
select * from t1 where a <= '2005-01-01';
drop table t1;
#
# Adding new test cases for column list variant for partitioning
#
--error 1064
create table t1 (a int, b char(20))
partition by range column_list(a,b)
(partition p0 values less than (1));
--error ER_TOO_MANY_VALUES_ERROR
create table t1 (a int, b char(20))
partition by range(a)
(partition p0 values less than (1,"b"));
--error ER_TOO_MANY_VALUES_ERROR
create table t1 (a int, b char(20))
partition by range(a)
(partition p0 values less than (1,"b"));
create table t1 (a int, b char(20))
partition by range column_list(b)
(partition p0 values less than ("b"));
drop table t1;
#
# BUG 33429: Succeeds in adding partition when maxvalue on last partition
#
......
......@@ -8,13 +8,13 @@ SET SQL_WARNINGS=1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
min_value decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
max_value decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
valuename varchar(20),
forecolor int(11),
backcolor int(11),
PRIMARY KEY (id),
UNIQUE datatype_id (datatype_id, minvalue, maxvalue)
UNIQUE datatype_id (datatype_id, min_value, max_value)
);
INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
......@@ -148,8 +148,8 @@ INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine
INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720');
INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024');
INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024');
select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16;
select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16;
select * from t1 where min_value<=1 and max_value>=-1 and datatype_id=16;
select * from t1 where min_value<=-1 and max_value>=-1 and datatype_id=16;
drop table t1;
#
......
......@@ -9783,7 +9783,7 @@ void ha_ndbcluster::set_auto_partitions(partition_info *part_info)
int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
{
NDBTAB *tab= (NDBTAB*)tab_ref;
int32 *range_data= (int32*)my_malloc(part_info->no_parts*sizeof(int32),
int32 *range_data= (int32*)my_malloc(part_info->num_parts*sizeof(int32),
MYF(0));
uint i;
int error= 0;
......@@ -9792,17 +9792,17 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
if (!range_data)
{
mem_alloc_error(part_info->no_parts*sizeof(int32));
mem_alloc_error(part_info->num_parts*sizeof(int32));
DBUG_RETURN(1);
}
for (i= 0; i < part_info->no_parts; i++)
for (i= 0; i < part_info->num_parts; i++)
{
longlong range_val= part_info->range_int_array[i];
if (unsigned_flag)
range_val-= 0x8000000000000000ULL;
if (range_val < INT_MIN32 || range_val >= INT_MAX32)
{
if ((i != part_info->no_parts - 1) ||
if ((i != part_info->num_parts - 1) ||
(range_val != LONGLONG_MAX))
{
my_error(ER_LIMITED_PART_RANGE, MYF(0), "NDB");
......@@ -9813,7 +9813,7 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
}
range_data[i]= (int32)range_val;
}
tab->setRangeListData(range_data, sizeof(int32)*part_info->no_parts);
tab->setRangeListData(range_data, sizeof(int32)*part_info->num_parts);
error:
my_free((char*)range_data, MYF(0));
DBUG_RETURN(error);
......@@ -9822,7 +9822,7 @@ int ha_ndbcluster::set_range_data(void *tab_ref, partition_info *part_info)
int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info)
{
NDBTAB *tab= (NDBTAB*)tab_ref;
int32 *list_data= (int32*)my_malloc(part_info->no_list_values * 2
int32 *list_data= (int32*)my_malloc(part_info->num_list_values * 2
* sizeof(int32), MYF(0));
uint32 *part_id, i;
int error= 0;
......@@ -9831,10 +9831,10 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info)
if (!list_data)
{
mem_alloc_error(part_info->no_list_values*2*sizeof(int32));
mem_alloc_error(part_info->num_list_values*2*sizeof(int32));
DBUG_RETURN(1);
}
for (i= 0; i < part_info->no_list_values; i++)
for (i= 0; i < part_info->num_list_values; i++)
{
LIST_PART_ENTRY *list_entry= &part_info->list_array[i];
longlong list_val= list_entry->list_value;
......@@ -9850,7 +9850,7 @@ int ha_ndbcluster::set_list_data(void *tab_ref, partition_info *part_info)
part_id= (uint32*)&list_data[2*i+1];
*part_id= list_entry->partition_id;
}
tab->setRangeListData(list_data, 2*sizeof(int32)*part_info->no_list_values);
tab->setRangeListData(list_data, 2*sizeof(int32)*part_info->num_list_values);
error:
my_free((char*)list_data, MYF(0));
DBUG_RETURN(error);
......@@ -9972,11 +9972,11 @@ uint ha_ndbcluster::set_up_partition_info(partition_info *part_info,
ng= 0;
ts_names[fd_index]= part_elem->tablespace_name;
frag_data[fd_index++]= ng;
} while (++j < part_info->no_subparts);
} while (++j < part_info->num_subparts);
}
first= FALSE;
} while (++i < part_info->no_parts);
tab->setDefaultNoPartitionsFlag(part_info->use_default_no_partitions);
} while (++i < part_info->num_parts);
tab->setDefaultNoPartitionsFlag(part_info->use_default_num_partitions);
tab->setLinearFlag(part_info->linear_hash_ind);
{
ha_rows max_rows= table_share->max_rows;
......@@ -10370,7 +10370,7 @@ int ndbcluster_alter_tablespace(handlerton *hton,
}
bool ha_ndbcluster::get_no_parts(const char *name, uint *no_parts)
bool ha_ndbcluster::get_no_parts(const char *name, uint *num_parts)
{
Ndb *ndb;
NDBDICT *dict;
......@@ -10392,7 +10392,7 @@ bool ha_ndbcluster::get_no_parts(const char *name, uint *no_parts)
Ndb_table_guard ndbtab_g(dict= ndb->getDictionary(), m_tabname);
if (!ndbtab_g.get_table())
ERR_BREAK(dict->getNdbError(), err);
*no_parts= ndbtab_g.get_table()->getFragmentCount();
*num_parts= ndbtab_g.get_table()->getFragmentCount();
DBUG_RETURN(FALSE);
}
......
This diff is collapsed.
#ifndef HA_PARTITION_INCLUDED
#define HA_PARTITION_INCLUDED
/* Copyright 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc.
/* Copyright 2005-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
......@@ -22,7 +22,8 @@
enum partition_keywords
{
PKW_HASH= 0, PKW_RANGE, PKW_LIST, PKW_KEY, PKW_MAXVALUE, PKW_LINEAR
PKW_HASH= 0, PKW_RANGE, PKW_LIST, PKW_KEY, PKW_MAXVALUE, PKW_LINEAR,
PKW_COLUMNS
};
/*
......@@ -114,7 +115,7 @@ class ha_partition :public handler
uint m_reorged_parts; // Number of reorganised parts
uint m_tot_parts; // Total number of partitions;
uint m_no_locks; // For engines like ha_blackhole, which needs no locks
uint m_num_locks; // For engines like ha_blackhole, which needs no locks
uint m_last_part; // Last file that we update,write,read
int m_lock_type; // Remembers type of last
// external_lock
......@@ -246,10 +247,10 @@ class ha_partition :public handler
size_t pack_frm_len);
virtual int drop_partitions(const char *path);
virtual int rename_partitions(const char *path);
bool get_no_parts(const char *name, uint *no_parts)
bool get_no_parts(const char *name, uint *num_parts)
{
DBUG_ENTER("ha_partition::get_no_parts");
*no_parts= m_tot_parts;
*num_parts= m_tot_parts;
DBUG_RETURN(0);
}
virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share);
......
......@@ -2052,6 +2052,18 @@ class Create_func_to_days : public Create_func_arg1
virtual ~Create_func_to_days() {}
};
class Create_func_to_seconds : public Create_func_arg1
{
public:
virtual Item* create(THD *thd, Item *arg1);
static Create_func_to_seconds s_singleton;
protected:
Create_func_to_seconds() {}
virtual ~Create_func_to_seconds() {}
};
#ifdef HAVE_SPATIAL
class Create_func_touches : public Create_func_arg2
......@@ -4505,6 +4517,15 @@ Create_func_to_days::create(THD *thd, Item *arg1)
}
Create_func_to_seconds Create_func_to_seconds::s_singleton;
Item*
Create_func_to_seconds::create(THD *thd, Item *arg1)
{
return new (thd->mem_root) Item_func_to_seconds(arg1);
}
#ifdef HAVE_SPATIAL
Create_func_touches Create_func_touches::s_singleton;
......@@ -4942,6 +4963,7 @@ static Native_func_registry func_array[] =
{ { C_STRING_WITH_LEN("TIME_TO_SEC") }, BUILDER(Create_func_time_to_sec)},
{ { C_STRING_WITH_LEN("TOUCHES") }, GEOM_BUILDER(Create_func_touches)},
{ { C_STRING_WITH_LEN("TO_DAYS") }, BUILDER(Create_func_to_days)},
{ { C_STRING_WITH_LEN("TO_SECONDS") }, BUILDER(Create_func_to_seconds)},
{ { C_STRING_WITH_LEN("UCASE") }, BUILDER(Create_func_ucase)},
{ { C_STRING_WITH_LEN("UNCOMPRESS") }, BUILDER(Create_func_uncompress)},
{ { C_STRING_WITH_LEN("UNCOMPRESSED_LENGTH") }, BUILDER(Create_func_uncompressed_length)},
......
......@@ -936,6 +936,48 @@ longlong Item_func_to_days::val_int()
}
longlong Item_func_to_seconds::val_int_endpoint(bool left_endp,
bool *incl_endp)
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
longlong seconds;
longlong days;
int dummy; /* unused */
if (get_arg0_date(&ltime, TIME_FUZZY_DATE))
{
/* got NULL, leave the incl_endp intact */
return LONGLONG_MIN;
}
seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second;
seconds= ltime.neg ? -seconds : seconds;
days= (longlong) calc_daynr(ltime.year, ltime.month, ltime.day);
seconds+= days * 24L * 3600L;
/* Set to NULL if invalid date, but keep the value */
null_value= check_date(&ltime,
(ltime.year || ltime.month || ltime.day),
(TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE),
&dummy);
/*
Even if the evaluation return NULL, seconds is useful for pruning
*/
return seconds;
}
longlong Item_func_to_seconds::val_int()
{
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
longlong seconds;
longlong days;
if (get_arg0_date(&ltime, TIME_NO_ZERO_DATE))
return 0;
seconds= ltime.hour * 3600L + ltime.minute * 60 + ltime.second;
seconds=ltime.neg ? -seconds : seconds;
days= (longlong) calc_daynr(ltime.year, ltime.month, ltime.day);
return seconds + days * 24L * 3600L;
}
/*
Get information about this Item tree monotonicity
......@@ -962,6 +1004,17 @@ enum_monotonicity_info Item_func_to_days::get_monotonicity_info() const
return NON_MONOTONIC;
}
enum_monotonicity_info Item_func_to_seconds::get_monotonicity_info() const
{
if (args[0]->type() == Item::FIELD_ITEM)
{
if (args[0]->field_type() == MYSQL_TYPE_DATE ||
args[0]->field_type() == MYSQL_TYPE_DATETIME)
return MONOTONIC_STRICT_INCREASING_NOT_NULL;
}
return NON_MONOTONIC;
}
longlong Item_func_to_days::val_int_endpoint(bool left_endp, bool *incl_endp)
{
......
......@@ -76,6 +76,24 @@ class Item_func_to_days :public Item_int_func
};
class Item_func_to_seconds :public Item_int_func
{
public:
Item_func_to_seconds(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "to_seconds"; }
void fix_length_and_dec()
{
decimals=0;
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
maybe_null=1;
}
enum_monotonicity_info get_monotonicity_info() const;
longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool check_partition_func_processor(uchar *bool_arg) { return FALSE;}
};
class Item_func_dayofmonth :public Item_int_func
{
public:
......
......@@ -119,6 +119,7 @@ static SYMBOL symbols[] = {
{ "COLUMN", SYM(COLUMN_SYM)},
{ "COLUMN_NAME", SYM(COLUMN_NAME_SYM)},
{ "COLUMNS", SYM(COLUMNS)},
{ "COLUMN_LIST", SYM(COLUMN_LIST_SYM)},
{ "COMMENT", SYM(COMMENT_SYM)},
{ "COMMIT", SYM(COMMIT_SYM)},
{ "COMMITTED", SYM(COMMITTED_SYM)},
......
......@@ -1153,6 +1153,8 @@ int prepare_create_field(Create_field *sql_field,
uint *blob_columns,
int *timestamps, int *timestamps_with_niladic,
longlong table_flags);
CHARSET_INFO* get_sql_field_charset(Create_field *sql_field,
HA_CREATE_INFO *create_info);
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
Alter_info *alter_info,
......@@ -1542,6 +1544,11 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
handlerton *old_db_type,
bool *partition_changed,
uint *fast_alter_partition);
char *generate_partition_syntax(partition_info *part_info,
uint *buf_length, bool use_sql_alloc,
bool show_partition_options,
HA_CREATE_INFO *create_info,
Alter_info *alter_info);
#endif
/* bits for last argument to remove_table_from_cache() */
......
This diff is collapsed.
#ifndef PARTITION_ELEMENT_INCLUDED
#define PARTITION_ELEMENT_INCLUDED
/* Copyright (C) 2006 MySQL AB
/* Copyright (C) 2006-2008 MySQL AB, Sun Microsystems Inc. 2008-2009
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
......@@ -39,6 +39,35 @@ enum partition_state {
PART_ADMIN= 9
};
/*
This struct is used to keep track of column expressions as part
of the COLUMNS concept in conjunction with RANGE and LIST partitioning.
The value can be either of MINVALUE, MAXVALUE and an expression that
must be constant and evaluate to the same type as the column it
represents.
The data in this fixed in two steps. The parser will only fill in whether
it is a max_value or provide an expression. Filling in
column_value, part_info, partition_id, null_value is done by the
function fix_column_value_function. However the item tree needs
fixed also before writing it into the frm file (in add_column_list_values).
To distinguish between those two variants, fixed= 1 after the
fixing in add_column_list_values and fixed= 2 otherwise. This is
since the fixing in add_column_list_values isn't a complete fixing.
*/
typedef struct p_column_list_val
{
void* column_value;
Item* item_expression;
partition_info *part_info;
uint partition_id;
bool max_value;
bool null_value;
char fixed;
} part_column_list_val;
/*
This struct is used to contain the value of an element
in the VALUES IN struct. It needs to keep knowledge of
......@@ -49,8 +78,10 @@ enum partition_state {
typedef struct p_elem_val
{
longlong value;
uint added_items;
bool null_value;
bool unsigned_flag;
part_column_list_val *col_val_array;
} part_elem_value;
struct st_ddl_log_memory_entry;
......@@ -72,8 +103,9 @@ class partition_element :public Sql_alloc {
enum partition_state part_state;
uint16 nodegroup_id;
bool has_null_value;
bool signed_flag;/* Indicate whether this partition uses signed constants */
bool max_value; /* Indicate whether this partition uses MAXVALUE */
/* signed_flag and max_value only relevant for subpartitions */
bool signed_flag;
bool max_value;
partition_element()
: part_max_rows(0), part_min_rows(0), range_value(0),
......
This diff is collapsed.
This diff is collapsed.
......@@ -6240,4 +6240,21 @@ ER_UNKNOWN_LOCALE
ER_SLAVE_IGNORE_SERVER_IDS
eng "The requested server id %d clashes with the slave startup option --replicate-same-server-id"
ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name '%-.192s'"
ER_PARTITION_COLUMN_LIST_ERROR
eng "Inconsistency in usage of column lists for partitioning"
ER_WRONG_TYPE_COLUMN_VALUE_ERROR
eng "Partition column values of incorrect type"
ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
eng "Too many fields in '%-.192s'"
ER_MAXVALUE_IN_VALUES_IN
eng "Cannot use MAXVALUE as value in VALUES IN"
ER_TOO_MANY_VALUES_ERROR
eng "Cannot have more than one value for this type of %-.64s partitioning"
ER_ROW_SINGLE_PARTITION_FIELD_ERROR
eng "Row expressions in VALUES IN only allowed for multi-field column partitioning"
ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
eng "Field '%-.192s' is of a not allowed type for this type of partitioning"
ER_PARTITION_FIELDS_TOO_LONG
eng "The total length of the partitioning fields is too large"
......@@ -6241,3 +6241,21 @@ ER_UNKNOWN_LOCALE
ER_SLAVE_IGNORE_SERVER_IDS
eng "The requested server id %d clashes with the slave startup option --replicate-same-server-id"
ER_SAME_NAME_PARTITION_FIELD
eng "Duplicate partition field name '%-.192s'"
ER_PARTITION_COLUMN_LIST_ERROR
eng "Inconsistency in usage of column lists for partitioning"
ER_WRONG_TYPE_COLUMN_VALUE_ERROR
eng "Partition column values of incorrect type"
ER_TOO_MANY_PARTITION_FUNC_FIELDS_ERROR
eng "Too many fields in '%-.192s'"
ER_MAXVALUE_IN_VALUES_IN
eng "Cannot use MAXVALUE as value in VALUES IN"
ER_TOO_MANY_VALUES_ERROR
eng "Cannot have more than one value for this type of %-.64s partitioning"
ER_ROW_SINGLE_PARTITION_FIELD_ERROR
eng "Row expressions in VALUES IN only allowed for multi-field column partitioning"
ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_FIELD
eng "Field '%-.192s' is of a not allowed type for this type of partitioning"
ER_PARTITION_FIELDS_TOO_LONG
eng "The total length of the partitioning fields is too large"
......@@ -1497,7 +1497,7 @@ Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root)
keys_onoff(rhs.keys_onoff),
tablespace_op(rhs.tablespace_op),
partition_names(rhs.partition_names, mem_root),
no_parts(rhs.no_parts),
num_parts(rhs.num_parts),
change_level(rhs.change_level),
datetime_field(rhs.datetime_field),
error_if_not_empty(rhs.error_if_not_empty)
......
......@@ -899,7 +899,7 @@ class Alter_info
enum enum_enable_or_disable keys_onoff;
enum tablespace_op_type tablespace_op;
List<char> partition_names;
uint no_parts;
uint num_parts;
enum_alter_table_change_level change_level;
Create_field *datetime_field;
bool error_if_not_empty;
......@@ -909,7 +909,7 @@ class Alter_info
flags(0),
keys_onoff(LEAVE_AS_IS),
tablespace_op(NO_TABLESPACE_OP),
no_parts(0),
num_parts(0),
change_level(ALTER_TABLE_METADATA_ONLY),
datetime_field(NULL),
error_if_not_empty(FALSE)
......@@ -924,7 +924,7 @@ class Alter_info
flags= 0;
keys_onoff= LEAVE_AS_IS;
tablespace_op= NO_TABLESPACE_OP;
no_parts= 0;
num_parts= 0;
partition_names.empty();
change_level= ALTER_TABLE_METADATA_ONLY;
datetime_field= 0;
......
This diff is collapsed.
#ifndef SQL_PARTITION_INCLUDED
#define SQL_PARTITION_INCLUDED
/* Copyright (C) 2006 MySQL AB
/* Copyright (C) 2006-2008 MySQL AB, Sun Microsystems Inc. 2008-2009
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
......@@ -68,15 +68,13 @@ int get_part_for_delete(const uchar *buf, const uchar *rec0,
void prune_partition_set(const TABLE *table, part_id_range *part_spec);
bool check_partition_info(partition_info *part_info,handlerton **eng_type,
TABLE *table, handler *file, HA_CREATE_INFO *info);
void set_linear_hash_mask(partition_info *part_info, uint no_parts);
void set_linear_hash_mask(partition_info *part_info, uint num_parts);
bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind);
char *generate_partition_syntax(partition_info *part_info,
uint *buf_length, bool use_sql_alloc,
bool show_partition_options);
bool partition_key_modified(TABLE *table, const MY_BITMAP *fields);
void get_partition_set(const TABLE *table, uchar *buf, const uint index,
const key_range *key_spec,
part_id_range *part_spec);
uint get_partition_field_store_length(Field *field);
void get_full_part_id_from_key(const TABLE *table, uchar *buf,
KEY *key_info,
const key_range *key_spec,
......@@ -99,6 +97,7 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
bool check_part_func_fields(Field **ptr, bool ok_with_charsets);
bool field_is_partition_charset(Field *field);
Item* convert_charset_partition_constant(Item *item, CHARSET_INFO *cs);
/*
A "Get next" function for partition iterator.
......@@ -176,11 +175,14 @@ typedef struct st_partition_iter
SYNOPSIS
get_partitions_in_range_iter()
part_info Partitioning info
is_subpart
min_val Left edge, field value in opt_range_key format.
max_val Right edge, field value in opt_range_key format.
is_subpart
store_length_array Length of fields packed in opt_range_key format
min_val Left edge, field value in opt_range_key format
max_val Right edge, field value in opt_range_key format
min_len Length of minimum value
max_len Length of maximum value
flags Some combination of NEAR_MIN, NEAR_MAX, NO_MIN_RANGE,
NO_MAX_RANGE.
NO_MAX_RANGE
part_iter Iterator structure to be initialized
DESCRIPTION
......@@ -194,8 +196,9 @@ typedef struct st_partition_iter
The set of partitions is returned by initializing an iterator in *part_iter
NOTES
There are currently two functions of this type:
There are currently three functions of this type:
- get_part_iter_for_interval_via_walking
- get_part_iter_for_interval_cols_via_map
- get_part_iter_for_interval_via_mapping
RETURN
......@@ -206,7 +209,9 @@ typedef struct st_partition_iter
typedef int (*get_partitions_in_range_iter)(partition_info *part_info,
bool is_subpart,
uint32 *store_length_array,
uchar *min_val, uchar *max_val,
uint min_len, uint max_len,
uint flags,
PARTITION_ITERATOR *part_iter);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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