Commit 9ecdd588 authored by Mattias Jonsson's avatar Mattias Jonsson

merge

parents 6eff1091 6654e2a5
drop table if exists t1; drop table if exists t1;
#
# Bug#50392: insert_id is not reset for partitioned tables
# auto_increment on duplicate entry
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
SET INSERT_ID= 13;
INSERT INTO t1 VALUES (NULL);
SET INSERT_ID= 12;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`a`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
a
12
13
14
DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY(a);
SET INSERT_ID= 13;
INSERT INTO t1 VALUES (NULL);
SET INSERT_ID= 12;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
ERROR 23000: Duplicate entry '13' for key 'PRIMARY'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`a`)
) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (a) */
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
a
12
13
14
DROP TABLE t1;
CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a)); CREATE TABLE t1 (a INTEGER NOT NULL, PRIMARY KEY (a));
INSERT INTO t1 VALUES (1),(1); INSERT INTO t1 VALUES (1),(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY' ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
......
drop table if exists t1; drop table if exists t1, t2;
#
# Bug#51830: Incorrect partition pruning on range partition (regression)
#
CREATE TABLE t1 (a INT NOT NULL)
ENGINE = InnoDB
PARTITION BY RANGE(a)
(PARTITION p10 VALUES LESS THAN (10),
PARTITION p30 VALUES LESS THAN (30),
PARTITION p50 VALUES LESS THAN (50),
PARTITION p70 VALUES LESS THAN (70),
PARTITION p90 VALUES LESS THAN (90));
INSERT INTO t1 VALUES (10),(30),(50);
INSERT INTO t1 VALUES (70);
INSERT INTO t1 VALUES (80);
INSERT INTO t1 VALUES (89);
INSERT INTO t1 VALUES (90);
ERROR HY000: Table has no partition for value 90
INSERT INTO t1 VALUES (100);
ERROR HY000: Table has no partition for value 100
insert INTO t1 VALUES (110);
ERROR HY000: Table has no partition for value 110
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 7 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p90 ALL NULL NULL NULL NULL 7 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where
DROP TABLE t1;
#
# Bug#50104: Partitioned table with just 1 partion works with fk
#
CREATE TABLE t2 (
id INT,
PRIMARY KEY (id)
) ENGINE=InnoDB ;
CREATE TABLE t1 (
id INT NOT NULL AUTO_INCREMENT,
parent_id INT DEFAULT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id)
) ENGINE=InnoDB;
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
DROP TABLE t1, t2;
create table t1 (a int not null, create table t1 (a int not null,
b datetime not null, b datetime not null,
primary key (a,b)) primary key (a,b))
......
...@@ -270,7 +270,7 @@ a ...@@ -270,7 +270,7 @@ a
8 8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 1; SELECT * FROM t1 WHERE a > 1;
a a
2 2
...@@ -327,13 +327,13 @@ a ...@@ -327,13 +327,13 @@ a
8 8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
SELECT * FROM t1 WHERE a > 7; SELECT * FROM t1 WHERE a > 7;
a a
8 8
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 10 Using where; Using index
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY) CREATE TABLE t1 (a INT PRIMARY KEY)
PARTITION BY RANGE (a) ( PARTITION BY RANGE (a) (
...@@ -556,7 +556,7 @@ a ...@@ -556,7 +556,7 @@ a
7 7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 1; SELECT * FROM t1 WHERE a > 1;
a a
2 2
...@@ -601,13 +601,13 @@ a ...@@ -601,13 +601,13 @@ a
7 7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
SELECT * FROM t1 WHERE a > 6; SELECT * FROM t1 WHERE a > 6;
a a
7 7
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 max range PRIMARY PRIMARY 4 NULL 2 Using where; Using index 1 SIMPLE t1 max index PRIMARY PRIMARY 4 NULL 9 Using where; Using index
DROP TABLE t1; DROP TABLE t1;
# test of RANGE and index # test of RANGE and index
CREATE TABLE t1 (a DATE, KEY(a)) CREATE TABLE t1 (a DATE, KEY(a))
...@@ -757,10 +757,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -757,10 +757,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index 1 SIMPLE t1 pNULL,p0001-01-01,p1001-01-01,p2001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index 1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p2001-01-01 range a a 4 NULL 2 Using where; Using index 1 SIMPLE t1 pNULL,p2001-01-01 index a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index 1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index
...@@ -1086,10 +1086,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -1086,10 +1086,10 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index 1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 5 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index 1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p2001-01-01,pNULL range a a 4 NULL 2 Using where; Using index 1 SIMPLE t1 p2001-01-01,pNULL index a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = '1999-02-31';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index 1 SIMPLE t1 pNULL ref a a 4 const 1 Using where; Using index
...@@ -1101,7 +1101,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -1101,7 +1101,7 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index 1 SIMPLE t1 p0001-01-01,pNULL,p0000-01-02,p1001-01-01 range a a 4 NULL 4 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-02' AND '1002-00-00';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 pNULL,p1001-01-01 range a a 4 NULL 2 Using where; Using index 1 SIMPLE t1 pNULL,p1001-01-01 index a a 4 NULL 7 Using where; Using index
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01'; EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a BETWEEN '0001-01-01' AND '1001-01-01';
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index 1 SIMPLE t1 p0001-01-01,pNULL,p1001-01-01 range a a 4 NULL 3 Using where; Using index
...@@ -2101,6 +2101,21 @@ insert into t7 values (10),(30),(50); ...@@ -2101,6 +2101,21 @@ insert into t7 values (10),(30),(50);
explain partitions select * from t7 where a < 5; explain partitions select * from t7 where a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a < 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a <= 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a = 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a >= 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a > 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a < 10; explain partitions select * from t7 where a < 10;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
...@@ -2110,9 +2125,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -2110,9 +2125,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t7 where a = 10; explain partitions select * from t7 where a = 10;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30 system NULL NULL NULL NULL 1 1 SIMPLE t7 p30 system NULL NULL NULL NULL 1
explain partitions select * from t7 where a >= 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a > 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a < 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a <= 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a = 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a >= 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a < 90; explain partitions select * from t7 where a < 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a <= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a = 90; explain partitions select * from t7 where a = 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
...@@ -2122,6 +2161,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -2122,6 +2161,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t7 where a >= 90; explain partitions select * from t7 where a >= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 91;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 11 and a < 29; explain partitions select * from t7 where a > 11 and a < 29;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
...@@ -2137,6 +2179,21 @@ insert into t7 values (10),(30),(50); ...@@ -2137,6 +2179,21 @@ insert into t7 values (10),(30),(50);
explain partitions select * from t7 where a < 5; explain partitions select * from t7 where a < 5;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a < 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a <= 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a = 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a >= 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a > 9;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a < 10; explain partitions select * from t7 where a < 10;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
...@@ -2146,9 +2203,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -2146,9 +2203,33 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t7 where a = 10; explain partitions select * from t7 where a = 10;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30 system NULL NULL NULL NULL 1 1 SIMPLE t7 p30 system NULL NULL NULL NULL 1
explain partitions select * from t7 where a >= 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a > 10;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a < 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a <= 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a = 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a >= 89;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a < 90; explain partitions select * from t7 where a < 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where 1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a <= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t7 p10,p30,p50,p70,p90 ALL NULL NULL NULL NULL 3 Using where
explain partitions select * from t7 where a = 90; explain partitions select * from t7 where a = 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
...@@ -2158,6 +2239,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra ...@@ -2158,6 +2239,9 @@ id select_type table partitions type possible_keys key key_len ref rows Extra
explain partitions select * from t7 where a >= 90; explain partitions select * from t7 where a >= 90;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 91;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain partitions select * from t7 where a > 11 and a < 29; explain partitions select * from t7 where a > 11 and a < 29;
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
......
drop table if exists t1, t2; drop table if exists t1, t2;
#
# Bug#48229: group by performance issue of partitioned table
#
CREATE TABLE t1 (
a INT,
b INT,
KEY a (a,b)
)
PARTITION BY HASH (a) PARTITIONS 1;
INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020);
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
DROP TABLE t1;
create table t1 (a int) create table t1 (a int)
partition by range (a) partition by range (a)
( partition p0 values less than (maxvalue)); ( partition p0 values less than (maxvalue));
......
...@@ -42,6 +42,15 @@ if ($mysql_errno) ...@@ -42,6 +42,15 @@ if ($mysql_errno)
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (NULL);
if (!$skip_update) if (!$skip_update)
{ {
# InnoDB Does not handle this correctly, see bug#14793, bug#21641 # InnoDB Does not handle this correctly, see bug#14793, bug#21641
...@@ -601,6 +610,15 @@ SET INSERT_ID = 23; ...@@ -601,6 +610,15 @@ SET INSERT_ID = 23;
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
INSERT INTO t1 (c1) VALUES (NULL); INSERT INTO t1 (c1) VALUES (NULL);
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
SET INSERT_ID = 22;
-- error 0, ER_DUP_ENTRY, ER_DUP_KEY
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
if (!$mysql_errno)
{
echo # ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY;
echo # mysql_errno: $mysql_errno;
}
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
DROP TABLE t1; DROP TABLE t1;
......
...@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
2 2
...@@ -46,6 +49,7 @@ c1 ...@@ -46,6 +49,7 @@ c1
21 21
22 22
30 30
31
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
c1 INT NOT NULL AUTO_INCREMENT, c1 INT NOT NULL AUTO_INCREMENT,
...@@ -751,10 +755,15 @@ t1 CREATE TABLE `t1` ( ...@@ -751,10 +755,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=ARCHIVE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=ARCHIVE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 1
22
23 23
24
DROP TABLE t1; DROP TABLE t1;
# Testing with FLUSH TABLE # Testing with FLUSH TABLE
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -35,6 +35,11 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -35,6 +35,11 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
# mysql_errno: 0
INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; UPDATE t1 SET c1 = 51 WHERE c1 = 19;
FLUSH TABLES; FLUSH TABLES;
...@@ -597,6 +602,11 @@ t1 CREATE TABLE `t1` ( ...@@ -597,6 +602,11 @@ t1 CREATE TABLE `t1` (
) ENGINE=BLACKHOLE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=BLACKHOLE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
# ERROR (only OK if Blackhole) should give ER_DUP_KEY or ER_DUP_ENTRY
# mysql_errno: 0
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
DROP TABLE t1; DROP TABLE t1;
......
...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; UPDATE t1 SET c1 = 51 WHERE c1 = 19;
FLUSH TABLES; FLUSH TABLES;
...@@ -40,7 +43,7 @@ UPDATE t1 SET c1 = 40 WHERE c1 = 50; ...@@ -40,7 +43,7 @@ UPDATE t1 SET c1 = 40 WHERE c1 = 50;
SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test' SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
AND TABLE_NAME='t1'; AND TABLE_NAME='t1';
AUTO_INCREMENT AUTO_INCREMENT
31 32
UPDATE t1 SET c1 = NULL WHERE c1 = 4; UPDATE t1 SET c1 = NULL WHERE c1 = 4;
Warnings: Warnings:
Warning 1048 Column 'c1' cannot be null Warning 1048 Column 'c1' cannot be null
...@@ -60,6 +63,7 @@ c1 ...@@ -60,6 +63,7 @@ c1
30 30
31 31
32 32
33
40 40
51 51
DROP TABLE t1; DROP TABLE t1;
...@@ -771,10 +775,14 @@ t1 CREATE TABLE `t1` ( ...@@ -771,10 +775,14 @@ t1 CREATE TABLE `t1` (
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 1
23 23
24
DROP TABLE t1; DROP TABLE t1;
# Testing with FLUSH TABLE # Testing with FLUSH TABLE
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; UPDATE t1 SET c1 = 51 WHERE c1 = 19;
FLUSH TABLES; FLUSH TABLES;
...@@ -57,7 +60,9 @@ c1 ...@@ -57,7 +60,9 @@ c1
21 21
22 22
23 23
29
30 30
31
40 40
51 51
52 52
...@@ -797,10 +802,15 @@ t1 CREATE TABLE `t1` ( ...@@ -797,10 +802,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MEMORY AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=MEMORY AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 1
22
23 23
24
DROP TABLE t1; DROP TABLE t1;
# Testing with FLUSH TABLE # Testing with FLUSH TABLE
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; UPDATE t1 SET c1 = 51 WHERE c1 = 19;
FLUSH TABLES; FLUSH TABLES;
...@@ -57,7 +60,9 @@ c1 ...@@ -57,7 +60,9 @@ c1
21 21
22 22
23 23
29
30 30
31
40 40
51 51
52 52
...@@ -816,10 +821,15 @@ t1 CREATE TABLE `t1` ( ...@@ -816,10 +821,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=latin1 ) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 1
22
23 23
24
DROP TABLE t1; DROP TABLE t1;
# Testing with FLUSH TABLE # Testing with FLUSH TABLE
CREATE TABLE t1 ( CREATE TABLE t1 (
......
...@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL); ...@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NULL);
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 30; SET INSERT_ID = 30;
INSERT INTO t1 VALUES (NULL); INSERT INTO t1 VALUES (NULL);
SET INSERT_ID = 29;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
UPDATE t1 SET c1 = 50 WHERE c1 = 17; UPDATE t1 SET c1 = 50 WHERE c1 = 17;
UPDATE t1 SET c1 = 51 WHERE c1 = 19; UPDATE t1 SET c1 = 51 WHERE c1 = 19;
FLUSH TABLES; FLUSH TABLES;
...@@ -58,6 +61,7 @@ c1 ...@@ -58,6 +61,7 @@ c1
21 21
22 22
23 23
24
30 30
40 40
51 51
...@@ -792,9 +796,13 @@ t1 CREATE TABLE `t1` ( ...@@ -792,9 +796,13 @@ t1 CREATE TABLE `t1` (
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY HASH (c1) /*!50100 PARTITION BY HASH (c1)
PARTITIONS 2 */ PARTITIONS 2 */
SET INSERT_ID = 22;
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1 ORDER BY c1; SELECT * FROM t1 ORDER BY c1;
c1 c1
1 1
2
23 23
DROP TABLE t1; DROP TABLE t1;
# Testing with FLUSH TABLE # Testing with FLUSH TABLE
......
...@@ -8,6 +8,30 @@ ...@@ -8,6 +8,30 @@
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
--echo #
--echo # Bug#50392: insert_id is not reset for partitioned tables
--echo # auto_increment on duplicate entry
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
SET INSERT_ID= 13;
INSERT INTO t1 VALUES (NULL);
SET INSERT_ID= 12;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t1;
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY) PARTITION BY KEY(a);
SET INSERT_ID= 13;
INSERT INTO t1 VALUES (NULL);
SET INSERT_ID= 12;
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES (NULL);
SELECT * FROM t1;
DROP TABLE t1;
# #
# Bug#38719: Partitioning returns a different error code for a # Bug#38719: Partitioning returns a different error code for a
# duplicate key error # duplicate key error
......
...@@ -2,11 +2,70 @@ ...@@ -2,11 +2,70 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1, t2;
--enable_warnings --enable_warnings
let $MYSQLD_DATADIR= `SELECT @@datadir`; let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
--echo # Bug#51830: Incorrect partition pruning on range partition (regression)
--echo #
CREATE TABLE t1 (a INT NOT NULL)
ENGINE = InnoDB
PARTITION BY RANGE(a)
(PARTITION p10 VALUES LESS THAN (10),
PARTITION p30 VALUES LESS THAN (30),
PARTITION p50 VALUES LESS THAN (50),
PARTITION p70 VALUES LESS THAN (70),
PARTITION p90 VALUES LESS THAN (90));
INSERT INTO t1 VALUES (10),(30),(50);
INSERT INTO t1 VALUES (70);
INSERT INTO t1 VALUES (80);
INSERT INTO t1 VALUES (89);
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
INSERT INTO t1 VALUES (90);
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
INSERT INTO t1 VALUES (100);
--error ER_NO_PARTITION_FOR_GIVEN_VALUE
insert INTO t1 VALUES (110);
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 90;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 90;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 90;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 89;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 89;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 89;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a = 100;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 100;
EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 100;
DROP TABLE t1;
--echo #
--echo # Bug#50104: Partitioned table with just 1 partion works with fk
--echo #
CREATE TABLE t2 (
id INT,
PRIMARY KEY (id)
) ENGINE=InnoDB ;
CREATE TABLE t1 (
id INT NOT NULL AUTO_INCREMENT,
parent_id INT DEFAULT NULL,
PRIMARY KEY (id),
KEY parent_id (parent_id)
) ENGINE=InnoDB;
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
--error ER_FOREIGN_KEY_ON_PARTITIONED
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
--error ER_FOREIGN_KEY_ON_PARTITIONED
ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
DROP TABLE t1, t2;
# #
# Bug#47029: Crash when reorganize partition with subpartition # Bug#47029: Crash when reorganize partition with subpartition
# #
......
...@@ -702,15 +702,29 @@ insert into t7 values (10),(30),(50); ...@@ -702,15 +702,29 @@ insert into t7 values (10),(30),(50);
# leftmost intervals # leftmost intervals
explain partitions select * from t7 where a < 5; explain partitions select * from t7 where a < 5;
explain partitions select * from t7 where a < 9;
explain partitions select * from t7 where a <= 9;
explain partitions select * from t7 where a = 9;
explain partitions select * from t7 where a >= 9;
explain partitions select * from t7 where a > 9;
explain partitions select * from t7 where a < 10; explain partitions select * from t7 where a < 10;
explain partitions select * from t7 where a <= 10; explain partitions select * from t7 where a <= 10;
explain partitions select * from t7 where a = 10; explain partitions select * from t7 where a = 10;
explain partitions select * from t7 where a >= 10;
explain partitions select * from t7 where a > 10;
#rightmost intervals #rightmost intervals
explain partitions select * from t7 where a < 89;
explain partitions select * from t7 where a <= 89;
explain partitions select * from t7 where a = 89;
explain partitions select * from t7 where a > 89;
explain partitions select * from t7 where a >= 89;
explain partitions select * from t7 where a < 90; explain partitions select * from t7 where a < 90;
explain partitions select * from t7 where a <= 90;
explain partitions select * from t7 where a = 90; explain partitions select * from t7 where a = 90;
explain partitions select * from t7 where a > 90; explain partitions select * from t7 where a > 90;
explain partitions select * from t7 where a >= 90; explain partitions select * from t7 where a >= 90;
explain partitions select * from t7 where a > 91;
# misc intervals # misc intervals
explain partitions select * from t7 where a > 11 and a < 29; explain partitions select * from t7 where a > 11 and a < 29;
...@@ -728,15 +742,29 @@ insert into t7 values (10),(30),(50); ...@@ -728,15 +742,29 @@ insert into t7 values (10),(30),(50);
# leftmost intervals # leftmost intervals
explain partitions select * from t7 where a < 5; explain partitions select * from t7 where a < 5;
explain partitions select * from t7 where a < 9;
explain partitions select * from t7 where a <= 9;
explain partitions select * from t7 where a = 9;
explain partitions select * from t7 where a >= 9;
explain partitions select * from t7 where a > 9;
explain partitions select * from t7 where a < 10; explain partitions select * from t7 where a < 10;
explain partitions select * from t7 where a <= 10; explain partitions select * from t7 where a <= 10;
explain partitions select * from t7 where a = 10; explain partitions select * from t7 where a = 10;
explain partitions select * from t7 where a >= 10;
explain partitions select * from t7 where a > 10;
#rightmost intervals #rightmost intervals
explain partitions select * from t7 where a < 89;
explain partitions select * from t7 where a <= 89;
explain partitions select * from t7 where a = 89;
explain partitions select * from t7 where a > 89;
explain partitions select * from t7 where a >= 89;
explain partitions select * from t7 where a < 90; explain partitions select * from t7 where a < 90;
explain partitions select * from t7 where a <= 90;
explain partitions select * from t7 where a = 90; explain partitions select * from t7 where a = 90;
explain partitions select * from t7 where a > 90; explain partitions select * from t7 where a > 90;
explain partitions select * from t7 where a >= 90; explain partitions select * from t7 where a >= 90;
explain partitions select * from t7 where a > 91;
# misc intervals # misc intervals
explain partitions select * from t7 where a > 11 and a < 29; explain partitions select * from t7 where a > 11 and a < 29;
......
...@@ -9,6 +9,24 @@ ...@@ -9,6 +9,24 @@
drop table if exists t1, t2; drop table if exists t1, t2;
--enable_warnings --enable_warnings
--echo #
--echo # Bug#48229: group by performance issue of partitioned table
--echo #
CREATE TABLE t1 (
a INT,
b INT,
KEY a (a,b)
)
PARTITION BY HASH (a) PARTITIONS 1;
# insert some rows (i.e. so that rows/blocks > 1)
INSERT INTO t1 VALUES (0, 580092), (3, 894076), (4, 805483), (4, 913540), (6, 611137), (8, 171602), (9, 599495), (9, 746305), (10, 272829), (10, 847519), (12, 258869), (12, 929028), (13, 288970), (15, 20971), (15, 105839), (16, 788272), (17, 76914), (18, 827274), (19, 802258), (20, 123677), (20, 587729), (22, 701449), (25, 31565), (25, 230782), (25, 442887), (25, 733139), (25, 851020);
# Before the fix the 'Extra' column showed 'Using index for group-by'
EXPLAIN SELECT a, MAX(b) FROM t1 WHERE a IN (10, 100, 3) GROUP BY a;
DROP TABLE t1;
# #
# BUG 33429: Succeeds in adding partition when maxvalue on last partition # BUG 33429: Succeeds in adding partition when maxvalue on last partition
# #
......
...@@ -5090,6 +5090,7 @@ int ha_partition::info(uint flag) ...@@ -5090,6 +5090,7 @@ int ha_partition::info(uint flag)
file= m_file[handler_instance]; file= m_file[handler_instance];
file->info(HA_STATUS_CONST); file->info(HA_STATUS_CONST);
stats.block_size= file->stats.block_size;
stats.create_time= file->stats.create_time; stats.create_time= file->stats.create_time;
ref_length= m_ref_length; ref_length= m_ref_length;
} }
...@@ -6454,9 +6455,22 @@ void ha_partition::release_auto_increment() ...@@ -6454,9 +6455,22 @@ void ha_partition::release_auto_increment()
ulonglong next_auto_inc_val; ulonglong next_auto_inc_val;
lock_auto_increment(); lock_auto_increment();
next_auto_inc_val= ha_data->next_auto_inc_val; next_auto_inc_val= ha_data->next_auto_inc_val;
/*
If the current auto_increment values is lower than the reserved
value, and the reserved value was reserved by this thread,
we can lower the reserved value.
*/
if (next_insert_id < next_auto_inc_val && if (next_insert_id < next_auto_inc_val &&
auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val) auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val)
{
THD *thd= ha_thd();
/*
Check that we do not lower the value because of a failed insert
with SET INSERT_ID, i.e. forced/non generated values.
*/
if (thd->auto_inc_intervals_forced.maximum() < next_insert_id)
ha_data->next_auto_inc_val= next_insert_id; ha_data->next_auto_inc_val= next_insert_id;
}
DBUG_PRINT("info", ("ha_data->next_auto_inc_val: %lu", DBUG_PRINT("info", ("ha_data->next_auto_inc_val: %lu",
(ulong) ha_data->next_auto_inc_val)); (ulong) ha_data->next_auto_inc_val));
......
...@@ -2876,6 +2876,7 @@ int get_partition_id_range(partition_info *part_info, ...@@ -2876,6 +2876,7 @@ int get_partition_id_range(partition_info *part_info,
*func_value= part_func_value; *func_value= part_func_value;
if (unsigned_flag) if (unsigned_flag)
part_func_value-= 0x8000000000000000ULL; part_func_value-= 0x8000000000000000ULL;
/* Search for the partition containing part_func_value */
while (max_part_id > min_part_id) while (max_part_id > min_part_id)
{ {
loc_part_id= (max_part_id + min_part_id) / 2; loc_part_id= (max_part_id + min_part_id) / 2;
...@@ -3015,11 +3016,17 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info, ...@@ -3015,11 +3016,17 @@ uint32 get_partition_id_range_for_endpoint(partition_info *part_info,
part_end_val= range_array[loc_part_id]; part_end_val= range_array[loc_part_id];
if (left_endpoint) if (left_endpoint)
{ {
DBUG_ASSERT(part_func_value > part_end_val ?
(loc_part_id == max_partition &&
!part_info->defined_max_value) :
1);
/* /*
In case of PARTITION p VALUES LESS THAN MAXVALUE In case of PARTITION p VALUES LESS THAN MAXVALUE
the maximum value is in the current partition. the maximum value is in the current (last) partition.
If value is equal or greater than the endpoint,
the range starts from the next partition.
*/ */
if (part_func_value == part_end_val && if (part_func_value >= part_end_val &&
(loc_part_id < max_partition || !part_info->defined_max_value)) (loc_part_id < max_partition || !part_info->defined_max_value))
loc_part_id++; loc_part_id++;
} }
...@@ -4273,6 +4280,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, ...@@ -4273,6 +4280,12 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
{ {
DBUG_ENTER("prep_alter_part_table"); DBUG_ENTER("prep_alter_part_table");
/* Foreign keys on partitioned tables are not supported, waits for WL#148 */
if (table->part_info && (alter_info->flags & ALTER_FOREIGN_KEY))
{
my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0));
DBUG_RETURN(TRUE);
}
/* /*
We are going to manipulate the partition info on the table object We are going to manipulate the partition info on the table object
so we need to ensure that the data structure of the table object so we need to ensure that the data structure of the table object
......
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