List:Commits« Previous MessageNext Message »
From:Martin Hansson Date:March 16 2010 4:21pm
Subject:bzr commit into mysql-5.1-bugteam branch (martin.hansson:3402) Bug#47762
View as plain text  
#At file:///data0/martin/bzr/bug47762/5.1bt/ based on revid:martin.hansson@stripped

 3402 Martin Hansson	2010-03-16 [merge]
      Merge of fix for Bug#47762.

    added:
      mysql-test/suite/rpl/r/rpl_stm_sql_mode.result
      mysql-test/suite/rpl/t/rpl_stm_sql_mode.test
    modified:
      mysql-test/r/partition_error.result
      mysql-test/r/partition_innodb.result
      mysql-test/r/partition_pruning.result
      mysql-test/r/partition_range.result
      mysql-test/r/type_date.result
      mysql-test/suite/parts/inc/partition_auto_increment.inc
      mysql-test/suite/parts/r/partition_auto_increment_archive.result
      mysql-test/suite/parts/r/partition_auto_increment_blackhole.result
      mysql-test/suite/parts/r/partition_auto_increment_innodb.result
      mysql-test/suite/parts/r/partition_auto_increment_memory.result
      mysql-test/suite/parts/r/partition_auto_increment_myisam.result
      mysql-test/suite/parts/r/partition_auto_increment_ndb.result
      mysql-test/t/partition_error.test
      mysql-test/t/partition_innodb.test
      mysql-test/t/partition_pruning.test
      mysql-test/t/partition_range.test
      mysql-test/t/type_date.test
      sql/ha_partition.cc
      sql/item.h
      sql/log.cc
      sql/sql_partition.cc
=== modified file 'mysql-test/r/partition_error.result'
--- a/mysql-test/r/partition_error.result	2009-12-13 20:29:50 +0000
+++ b/mysql-test/r/partition_error.result	2010-03-04 17:16:10 +0000
@@ -1,4 +1,46 @@
 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));
 INSERT INTO t1 VALUES (1),(1);
 ERROR 23000: Duplicate entry '1' for key 'PRIMARY'

=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2010-01-18 16:49:18 +0000
+++ b/mysql-test/r/partition_innodb.result	2010-03-12 10:52:38 +0000
@@ -1,4 +1,73 @@
-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,
 b datetime not null,
 primary key (a,b))

=== modified file 'mysql-test/r/partition_pruning.result'
--- a/mysql-test/r/partition_pruning.result	2010-01-17 21:00:37 +0000
+++ b/mysql-test/r/partition_pruning.result	2010-03-12 10:52:38 +0000
@@ -270,7 +270,7 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 7;
 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;
 a
 2
@@ -327,13 +327,13 @@ a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
 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;
 a
 8
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 7;
 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;
 CREATE TABLE t1 (a INT PRIMARY KEY)
 PARTITION BY RANGE (a) (
@@ -556,7 +556,7 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a >= 6;
 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;
 a
 2
@@ -601,13 +601,13 @@ a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 5;
 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;
 a
 7
 EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a > 6;
 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;
 # test of RANGE and index
 CREATE TABLE t1 (a DATE, KEY(a))
@@ -757,10 +757,10 @@ id	select_type	table	partitions	type	pos
 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';
 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';
 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';
 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
@@ -1086,10 +1086,10 @@ id	select_type	table	partitions	type	pos
 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';
 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';
 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';
 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
@@ -1101,7 +1101,7 @@ id	select_type	table	partitions	type	pos
 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';
 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';
 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
@@ -2101,6 +2101,21 @@ insert into t7 values (10),(30),(50);
 explain partitions select * from t7 where a < 5;
 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	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;
 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
@@ -2110,9 +2125,33 @@ id	select_type	table	partitions	type	pos
 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	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;
 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;
+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;
 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
@@ -2122,6 +2161,9 @@ id	select_type	table	partitions	type	pos
 explain partitions select * from t7 where a >= 90;
 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 > 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;
 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
@@ -2137,6 +2179,21 @@ insert into t7 values (10),(30),(50);
 explain partitions select * from t7 where a < 5;
 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	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;
 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
@@ -2146,9 +2203,33 @@ id	select_type	table	partitions	type	pos
 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	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;
 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;
+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;
 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
@@ -2158,6 +2239,9 @@ id	select_type	table	partitions	type	pos
 explain partitions select * from t7 where a >= 90;
 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 > 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;
 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

=== modified file 'mysql-test/r/partition_range.result'
--- a/mysql-test/r/partition_range.result	2009-08-26 10:59:49 +0000
+++ b/mysql-test/r/partition_range.result	2010-03-04 11:09:09 +0000
@@ -1,4 +1,18 @@
 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)
 partition by range (a)
 ( partition p0 values less than (maxvalue));

=== modified file 'mysql-test/r/type_date.result'
--- a/mysql-test/r/type_date.result	2009-01-13 14:04:28 +0000
+++ b/mysql-test/r/type_date.result	2010-03-16 09:20:07 +0000
@@ -275,4 +275,25 @@ select * from t1 where a between '0000-0
 a
 0000-00-01
 drop table t1;
+#
+# Bug#50918: Date columns treated differently in Views than in Base
+# Tables
+#
+CREATE TABLE t1 ( the_date DATE, the_time TIME );
+INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' );
+SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = 
+addtime( t12.the_date, t12.the_time );
+the_date	the_time	the_date	the_time
+2010-01-01	01:01:01	2010-01-01	01:01:01
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = 
+addtime( v1.the_date, v1.the_time );
+the_date	the_time	the_date	the_time
+2010-01-01	01:01:01	2010-01-01	01:01:01
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = 
+addtime( cast(v1.the_date AS DATETIME), v1.the_time );
+the_date	the_time	the_date	the_time
+2010-01-01	01:01:01	2010-01-01	01:01:01
+DROP TABLE t1;
+DROP VIEW v1;
 End of 5.1 tests

=== modified file 'mysql-test/suite/parts/inc/partition_auto_increment.inc'
--- a/mysql-test/suite/parts/inc/partition_auto_increment.inc	2009-09-04 03:57:11 +0000
+++ b/mysql-test/suite/parts/inc/partition_auto_increment.inc	2010-03-04 17:16:10 +0000
@@ -42,6 +42,15 @@ if ($mysql_errno)
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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)
 {
 # InnoDB Does not handle this correctly, see bug#14793, bug#21641
@@ -601,6 +610,15 @@ SET INSERT_ID = 23;
 SHOW CREATE TABLE t1;
 INSERT INTO t1 (c1) VALUES (NULL);
 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;
 DROP TABLE t1;
 

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_archive.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_archive.result	2008-11-05 20:13:54 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_archive.result	2010-03-04 17:16:10 +0000
@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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;
 c1
 2
@@ -46,6 +49,7 @@ c1
 21
 22
 30
+31
 DROP TABLE t1;
 CREATE TABLE t1 (
 c1 INT NOT NULL AUTO_INCREMENT,
@@ -751,10 +755,15 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=ARCHIVE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
+SET INSERT_ID = 22;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1 ORDER BY c1;
 c1
 1
+22
 23
+24
 DROP TABLE t1;
 # Testing with FLUSH TABLE
 CREATE TABLE t1 (

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_blackhole.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result	2009-02-18 21:35:28 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_blackhole.result	2010-03-04 17:16:10 +0000
@@ -35,6 +35,11 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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 = 51 WHERE c1 = 19;
 FLUSH TABLES;
@@ -597,6 +602,11 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=BLACKHOLE AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 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;
 c1
 DROP TABLE t1;

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_innodb.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_innodb.result	2009-09-04 03:57:11 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_innodb.result	2010-03-04 17:16:10 +0000
@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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 = 51 WHERE c1 = 19;
 FLUSH TABLES;
@@ -40,7 +43,7 @@ UPDATE t1 SET c1 = 40 WHERE c1 = 50;
 SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='test'
   AND TABLE_NAME='t1';
 AUTO_INCREMENT
-31
+32
 UPDATE t1 SET c1 = NULL WHERE c1 = 4;
 Warnings:
 Warning	1048	Column 'c1' cannot be null
@@ -60,6 +63,7 @@ c1
 30
 31
 32
+33
 40
 51
 DROP TABLE t1;
@@ -771,10 +775,14 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
+SET INSERT_ID = 22;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1 ORDER BY c1;
 c1
 1
 23
+24
 DROP TABLE t1;
 # Testing with FLUSH TABLE
 CREATE TABLE t1 (

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_memory.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_memory.result	2009-09-04 03:57:11 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_memory.result	2010-03-04 17:16:10 +0000
@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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 = 51 WHERE c1 = 19;
 FLUSH TABLES;
@@ -57,7 +60,9 @@ c1
 21
 22
 23
+29
 30
+31
 40
 51
 52
@@ -797,10 +802,15 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MEMORY AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
+SET INSERT_ID = 22;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1 ORDER BY c1;
 c1
 1
+22
 23
+24
 DROP TABLE t1;
 # Testing with FLUSH TABLE
 CREATE TABLE t1 (

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_myisam.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_myisam.result	2009-09-04 03:57:11 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_myisam.result	2010-03-04 17:16:10 +0000
@@ -33,6 +33,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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 = 51 WHERE c1 = 19;
 FLUSH TABLES;
@@ -57,7 +60,9 @@ c1
 21
 22
 23
+29
 30
+31
 40
 51
 52
@@ -816,10 +821,15 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
+SET INSERT_ID = 22;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1 ORDER BY c1;
 c1
 1
+22
 23
+24
 DROP TABLE t1;
 # Testing with FLUSH TABLE
 CREATE TABLE t1 (

=== modified file 'mysql-test/suite/parts/r/partition_auto_increment_ndb.result'
--- a/mysql-test/suite/parts/r/partition_auto_increment_ndb.result	2009-09-04 03:57:11 +0000
+++ b/mysql-test/suite/parts/r/partition_auto_increment_ndb.result	2010-03-04 17:16:10 +0000
@@ -34,6 +34,9 @@ INSERT INTO t1 VALUES (NULL), (10), (NUL
 INSERT INTO t1 VALUES (NULL);
 SET INSERT_ID = 30;
 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 = 51 WHERE c1 = 19;
 FLUSH TABLES;
@@ -58,6 +61,7 @@ c1
 21
 22
 23
+24
 30
 40
 51
@@ -792,9 +796,13 @@ t1	CREATE TABLE `t1` (
 ) ENGINE=ndbcluster DEFAULT CHARSET=latin1
 /*!50100 PARTITION BY HASH (c1)
 PARTITIONS 2 */
+SET INSERT_ID = 22;
+INSERT INTO t1 VALUES (NULL), (NULL), (NULL);
+INSERT INTO t1 VALUES (NULL);
 SELECT * FROM t1 ORDER BY c1;
 c1
 1
+2
 23
 DROP TABLE t1;
 # Testing with FLUSH TABLE

=== added file 'mysql-test/suite/rpl/r/rpl_stm_sql_mode.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_sql_mode.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_sql_mode.result	2010-03-04 10:18:06 +0000
@@ -0,0 +1,18 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+CREATE TABLE t1 (pk integer auto_increment , primary key (pk));
+SET SESSION SQL_MODE='traditional';
+# **** [MASTER] *****
+# action: raise DUP KEY error (error code should be set in the 
+#                              query log event)
+INSERT INTO t1 (`pk`) VALUES (1), (1);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+DROP TABLE t1;
+# **** [ sync slave with master ] ****
+# assertion: sync slave with master makes slave not to stop with
+#            duplicate key error (because it has received event
+#            with expected error code).

=== added file 'mysql-test/suite/rpl/t/rpl_stm_sql_mode.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_sql_mode.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_sql_mode.test	2010-03-04 10:18:06 +0000
@@ -0,0 +1,24 @@
+-- source include/master-slave.inc
+-- source include/have_binlog_format_statement.inc
+
+#
+# Bug #51055    Replication failure on duplicate key + traditional SQL mode
+#
+
+CREATE TABLE t1 (pk integer auto_increment , primary key (pk));
+
+SET SESSION SQL_MODE='traditional';
+
+-- echo # **** [MASTER] *****
+-- echo # action: raise DUP KEY error (error code should be set in the 
+-- echo #                              query log event)
+-- error ER_DUP_ENTRY
+INSERT INTO t1 (`pk`) VALUES (1), (1);
+
+DROP TABLE t1;
+
+-- echo # **** [ sync slave with master ] ****
+-- echo # assertion: sync slave with master makes slave not to stop with
+-- echo #            duplicate key error (because it has received event
+-- echo #            with expected error code).
+-- sync_slave_with_master

=== modified file 'mysql-test/t/partition_error.test'
--- a/mysql-test/t/partition_error.test	2009-12-13 20:29:50 +0000
+++ b/mysql-test/t/partition_error.test	2010-03-04 17:16:10 +0000
@@ -8,6 +8,30 @@
 drop table if exists t1;
 --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
 # duplicate key error

=== modified file 'mysql-test/t/partition_innodb.test'
--- a/mysql-test/t/partition_innodb.test	2010-01-18 16:49:18 +0000
+++ b/mysql-test/t/partition_innodb.test	2010-03-12 10:52:38 +0000
@@ -2,11 +2,70 @@
 --source include/have_innodb.inc
 
 --disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
 --enable_warnings
 
 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
 #

=== modified file 'mysql-test/t/partition_pruning.test'
--- a/mysql-test/t/partition_pruning.test	2009-12-22 17:59:37 +0000
+++ b/mysql-test/t/partition_pruning.test	2010-03-10 11:56:05 +0000
@@ -702,15 +702,29 @@ insert into t7 values (10),(30),(50);
 
 # leftmost intervals
 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;
 
 #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 > 91;
 
 # misc intervals
 explain partitions select * from t7 where a > 11 and a < 29;
@@ -728,15 +742,29 @@ insert into t7 values (10),(30),(50);
 
 # leftmost intervals
 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;
 
 #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 > 91;
 
 # misc intervals
 explain partitions select * from t7 where a > 11 and a < 29;

=== modified file 'mysql-test/t/partition_range.test'
--- a/mysql-test/t/partition_range.test	2008-09-18 19:49:34 +0000
+++ b/mysql-test/t/partition_range.test	2010-03-04 11:09:09 +0000
@@ -9,6 +9,24 @@
 drop table if exists t1, t2;
 --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
 #

=== modified file 'mysql-test/t/type_date.test'
--- a/mysql-test/t/type_date.test	2009-01-13 14:04:28 +0000
+++ b/mysql-test/t/type_date.test	2010-03-16 09:20:07 +0000
@@ -246,4 +246,24 @@ insert into t1 values ('0000-01-01'), ('
 select * from t1 where a between '0000-00-01' and '0000-00-02';
 drop table t1;
 
+--echo #
+--echo # Bug#50918: Date columns treated differently in Views than in Base
+--echo # Tables
+--echo #
+CREATE TABLE t1 ( the_date DATE, the_time TIME );
+INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' );
+
+SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = 
+                                    addtime( t12.the_date, t12.the_time );
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = 
+                            addtime( v1.the_date, v1.the_time );
+
+SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = 
+                            addtime( cast(v1.the_date AS DATETIME), v1.the_time );
+
+DROP TABLE t1;
+DROP VIEW v1;
+
 --echo End of 5.1 tests

=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc	2010-02-12 09:03:10 +0000
+++ b/sql/ha_partition.cc	2010-03-12 10:14:40 +0000
@@ -5090,6 +5090,7 @@ int ha_partition::info(uint flag)
 
     file= m_file[handler_instance];
     file->info(HA_STATUS_CONST);
+    stats.block_size= file->stats.block_size;
     stats.create_time= file->stats.create_time;
     ref_length= m_ref_length;
   }
@@ -6454,9 +6455,22 @@ void ha_partition::release_auto_incremen
     ulonglong next_auto_inc_val;
     lock_auto_increment();
     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 &&
         auto_inc_interval_for_cur_row.maximum() >= next_auto_inc_val)
-      ha_data->next_auto_inc_val= next_insert_id;
+    {
+      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;
+    }
     DBUG_PRINT("info", ("ha_data->next_auto_inc_val: %lu",
                         (ulong) ha_data->next_auto_inc_val));
 

=== modified file 'sql/item.h'
--- a/sql/item.h	2010-03-14 16:01:45 +0000
+++ b/sql/item.h	2010-03-16 09:20:07 +0000
@@ -2320,6 +2320,11 @@ public:
     if (ref && result_type() == ROW_RESULT)
       (*ref)->bring_value();
   }
+  bool get_time(MYSQL_TIME *ltime)
+  {
+    DBUG_ASSERT(fixed);
+    return (*ref)->get_time(ltime);
+  }
 
 };
 

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2010-02-05 17:01:09 +0000
+++ b/sql/log.cc	2010-03-04 10:18:06 +0000
@@ -4679,7 +4679,7 @@ int query_error_code(THD *thd, bool not_
 {
   int error;
   
-  if (not_killed)
+  if (not_killed || (thd->killed == THD::KILL_BAD_DATA))
   {
     error= thd->is_error() ? thd->main_da.sql_errno() : 0;
 

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-01-24 07:03:23 +0000
+++ b/sql/sql_partition.cc	2010-03-12 10:52:38 +0000
@@ -2876,6 +2876,7 @@ int get_partition_id_range(partition_inf
   *func_value= part_func_value;
   if (unsigned_flag)
     part_func_value-= 0x8000000000000000ULL;
+  /* Search for the partition containing part_func_value */
   while (max_part_id > min_part_id)
   {
     loc_part_id= (max_part_id + min_part_id) / 2;
@@ -3015,11 +3016,17 @@ uint32 get_partition_id_range_for_endpoi
   part_end_val= range_array[loc_part_id];
   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
-      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++;
   }
@@ -4273,6 +4280,12 @@ uint prep_alter_part_table(THD *thd, TAB
 {
   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
     so we need to ensure that the data structure of the table object


Attachment: [text/bzr-bundle] bzr/martin.hansson@sun.com-20100316162138-u9724fhm54cj3or0.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (martin.hansson:3402) Bug#47762Martin Hansson16 Mar