[Commits] Rev 2881: Merge 5.3-subquery-bugfixing -> 5.3 in file:///home/psergey/dev2/5.3/

Sergey Petrunya psergey at askmonty.org
Mon Jan 17 23:26:08 EET 2011


At file:///home/psergey/dev2/5.3/

------------------------------------------------------------
revno: 2881 [merge]
revision-id: psergey at askmonty.org-20110117212604-lsmczh8j985h3qc5
parent: igor at askmonty.org-20110116073951-5zw0krluls6blv2l
parent: psergey at askmonty.org-20110117120930-12pdu1ltxo8dxvbq
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.3
timestamp: Tue 2011-01-18 00:26:04 +0300
message:
  Merge 5.3-subquery-bugfixing -> 5.3
added:
  mysql-test/include/icp_tests.inc icp_tests.inc-20110114133659-4wued877rff62t1v-1
  mysql-test/r/innodb_icp.result innodb_icp.result-20110114133659-4wued877rff62t1v-2
  mysql-test/r/maria_icp.result  maria_icp.result-20110114133659-4wued877rff62t1v-3
  mysql-test/r/myisam_icp.result myisam_icp.result-20110114133659-4wued877rff62t1v-4
  mysql-test/t/innodb_icp.test   innodb_icp.test-20110114133659-4wued877rff62t1v-5
  mysql-test/t/maria_icp.test    maria_icp.test-20110114133659-4wued877rff62t1v-6
  mysql-test/t/myisam_icp.test   myisam_icp.test-20110114133659-4wued877rff62t1v-7
modified:
  mysql-test/r/innodb_mrr.result innodb_mrr.result-20091215071342-e3drfbiqqrmxrpri-1
  mysql-test/r/subselect4.result subselect4.result-20090903150316-1sul3u8k29ooxm3r-2
  mysql-test/r/subselect_mat.result subselect_mat.result-20100117143924-r0jv32dj80dg3b5h-1
  mysql-test/r/subselect_sj.result subselect_sj.result-20100117143926-nrop4ku355g3kv8b-1
  mysql-test/r/subselect_sj_jcl6.result subselect_sj_jcl6.re-20100117143928-7vzk51yaf29cdavp-1
  mysql-test/suite/optimizer_unfixed_bugs/r/bug49129.result bug49129.result-20091215071412-kzlc04eu5ip4om0u-30
  mysql-test/suite/optimizer_unfixed_bugs/t/disabled.def disabled.def-20091215071412-kzlc04eu5ip4om0u-54
  mysql-test/t/innodb_mrr.test   innodb_mrr.test-20091215071348-pq1qyz18e54ao399-1
  mysql-test/t/subselect4.test   subselect4.test-20090903150316-1sul3u8k29ooxm3r-1
  mysql-test/t/subselect_mat.test subselect_mat.test-20100117143929-iif102ysgna1tyj0-1
  mysql-test/t/subselect_sj.test subselect_sj.test-20100117143931-qp396ufpe3k0scre-1
  sql/opt_subselect.cc           opt_subselect.cc-20100215190428-nekkl8wisp0k6nlk-1
  sql/structs.h                  sp1f-structs.h-19700101030959-dqulhwijezc2pwv2x4g32qdggnybj2nc
  sql/table.cc                   sp1f-table.cc-19700101030959-nsxtem2adyqzwe6nz4cgrpcmts3o54v7
=== added file 'mysql-test/include/icp_tests.inc'
--- a/mysql-test/include/icp_tests.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/icp_tests.inc	2011-01-14 14:30:27 +0000
@@ -0,0 +1,168 @@
+--echo #
+--echo # Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for
+--echo #             null-safe operator <=> NULL
+--echo #
+
+CREATE TABLE t1(
+  c1 DATE NOT NULL,
+  c2 DATE NULL,
+  c3 DATETIME,
+  c4 TIMESTAMP,
+  PRIMARY KEY(c1),
+  UNIQUE(c2)
+);
+
+--echo
+INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05');
+INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26');
+INSERT INTO t1 VALUES('2008-01-01', NULL        , '2008-01-02', '2008-01-03');
+INSERT INTO t1 VALUES('2008-01-17', NULL        , NULL        , '2009-01-29');
+INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29');
+
+--echo
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2;
+--echo
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2;
+
+--echo
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on
+--echo #
+
+CREATE TABLE t (
+  dummy INT PRIMARY KEY, 
+  a INT UNIQUE, 
+  b INT
+);
+
+INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5);
+
+SELECT * FROM t WHERE a > 2 FOR UPDATE;
+
+DROP TABLE t;
+
+--echo #
+--echo # Bug#35080 - Innodb crash at mem_block_get_len line 72
+--echo #
+
+CREATE TABLE t1 (
+  t1_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+  uuid VARCHAR(36) DEFAULT NULL,
+  PRIMARY KEY (t1_autoinc),
+  KEY k (uuid)
+);
+
+CREATE TABLE t2 (
+  t2_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+  uuid VARCHAR(36) DEFAULT NULL,
+  date DATETIME DEFAULT NULL,
+  PRIMARY KEY (t2_autoinc),
+  KEY k (uuid)
+);
+
+CREATE VIEW v1 AS 
+  SELECT t1_autoinc, uuid
+  FROM t1
+  WHERE (ISNULL(uuid) OR (uuid like '%-%'));
+
+CREATE VIEW v2 AS 
+  SELECT t2_autoinc, uuid, date 
+  FROM t2
+  WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36));
+
+CREATE PROCEDURE delete_multi (IN uuid CHAR(36))
+  DELETE v1, v2 FROM v1 INNER JOIN v2
+  ON v1.uuid = v2.uuid
+  WHERE v1.uuid = @uuid;
+
+SET @uuid = UUID();
+
+INSERT INTO v1 (uuid) VALUES (@uuid);
+INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09');
+
+CALL delete_multi(@uuid);
+
+DROP procedure delete_multi;
+DROP table t1,t2;
+DROP view v1,v2;
+
+--echo #
+--echo # Bug#41996 - multi-table delete crashes server (InnoDB table)
+--echo #
+
+CREATE TABLE t1 (
+  b BIGINT,
+  i INT, 
+  KEY (b)
+);
+
+INSERT INTO t1 VALUES (2, 2);
+
+DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug#43448 - Server crashes on multi table delete with Innodb
+--echo #
+
+CREATE TABLE t1 (
+  id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+  t CHAR(12)
+);
+
+CREATE TABLE t2 (
+  id2 INT NOT NULL, 
+  t CHAR(12)
+);
+
+CREATE TABLE t3(
+  id3 INT NOT NULL, 
+  t CHAR(12), 
+  INDEX(id3)
+);
+
+delimiter |;
+
+CREATE PROCEDURE insert_data ()
+BEGIN
+  DECLARE i1 INT DEFAULT 20;
+  DECLARE i2 INT;
+  DECLARE i3 INT;
+
+  WHILE (i1 > 0) DO
+    INSERT INTO t1(t) VALUES (i1);
+    SET i2 = 2;
+    WHILE (i2 > 0) DO
+      INSERT INTO t2(id2, t) VALUES (i1, i2);
+      SET i3 = 2;
+      WHILE (i3 > 0) DO
+        INSERT INTO t3(id3, t) VALUES (i1, i2);
+        SET i3 = i3 -1;
+      END WHILE;
+      SET i2 = i2 -1;
+    END WHILE;
+    SET i1 = i1 - 1;
+  END WHILE;
+END |
+
+delimiter ;|
+
+CALL insert_data();
+
+SELECT COUNT(*) FROM t1 WHERE id1 > 10;
+SELECT COUNT(*) FROM t2 WHERE id2 > 10;
+SELECT COUNT(*) FROM t3 WHERE id3 > 10;
+
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3;
+
+SELECT COUNT(*) FROM t1;
+SELECT COUNT(*) FROM t2;
+SELECT COUNT(*) FROM t3;
+
+DROP PROCEDURE insert_data;
+DROP TABLE t1, t2, t3;

=== added file 'mysql-test/r/innodb_icp.result'
--- a/mysql-test/r/innodb_icp.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/innodb_icp.result	2011-01-14 14:30:27 +0000
@@ -0,0 +1,153 @@
+set @save_storage_engine= @@storage_engine;
+set storage_engine=InnoDB;
+#
+# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for
+#             null-safe operator <=> NULL
+#
+CREATE TABLE t1(
+c1 DATE NOT NULL,
+c2 DATE NULL,
+c3 DATETIME,
+c4 TIMESTAMP,
+PRIMARY KEY(c1),
+UNIQUE(c2)
+);
+
+INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05');
+INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26');
+INSERT INTO t1 VALUES('2008-01-01', NULL        , '2008-01-02', '2008-01-03');
+INSERT INTO t1 VALUES('2008-01-17', NULL        , NULL        , '2009-01-29');
+INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29');
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+DROP TABLE t1;
+#
+# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on
+#
+CREATE TABLE t (
+dummy INT PRIMARY KEY, 
+a INT UNIQUE, 
+b INT
+);
+INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5);
+SELECT * FROM t WHERE a > 2 FOR UPDATE;
+dummy	a	b
+3	3	3
+5	5	5
+DROP TABLE t;
+#
+# Bug#35080 - Innodb crash at mem_block_get_len line 72
+#
+CREATE TABLE t1 (
+t1_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+PRIMARY KEY (t1_autoinc),
+KEY k (uuid)
+);
+CREATE TABLE t2 (
+t2_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+date DATETIME DEFAULT NULL,
+PRIMARY KEY (t2_autoinc),
+KEY k (uuid)
+);
+CREATE VIEW v1 AS 
+SELECT t1_autoinc, uuid
+FROM t1
+WHERE (ISNULL(uuid) OR (uuid like '%-%'));
+CREATE VIEW v2 AS 
+SELECT t2_autoinc, uuid, date 
+FROM t2
+WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36));
+CREATE PROCEDURE delete_multi (IN uuid CHAR(36))
+DELETE v1, v2 FROM v1 INNER JOIN v2
+ON v1.uuid = v2.uuid
+WHERE v1.uuid = @uuid;
+SET @uuid = UUID();
+INSERT INTO v1 (uuid) VALUES (@uuid);
+INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09');
+CALL delete_multi(@uuid);
+DROP procedure delete_multi;
+DROP table t1,t2;
+DROP view v1,v2;
+#
+# Bug#41996 - multi-table delete crashes server (InnoDB table)
+#
+CREATE TABLE t1 (
+b BIGINT,
+i INT, 
+KEY (b)
+);
+INSERT INTO t1 VALUES (2, 2);
+DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b;
+DROP TABLE t1;
+#
+# Bug#43448 - Server crashes on multi table delete with Innodb
+#
+CREATE TABLE t1 (
+id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+t CHAR(12)
+);
+CREATE TABLE t2 (
+id2 INT NOT NULL, 
+t CHAR(12)
+);
+CREATE TABLE t3(
+id3 INT NOT NULL, 
+t CHAR(12), 
+INDEX(id3)
+);
+CREATE PROCEDURE insert_data ()
+BEGIN
+DECLARE i1 INT DEFAULT 20;
+DECLARE i2 INT;
+DECLARE i3 INT;
+WHILE (i1 > 0) DO
+INSERT INTO t1(t) VALUES (i1);
+SET i2 = 2;
+WHILE (i2 > 0) DO
+INSERT INTO t2(id2, t) VALUES (i1, i2);
+SET i3 = 2;
+WHILE (i3 > 0) DO
+INSERT INTO t3(id3, t) VALUES (i1, i2);
+SET i3 = i3 -1;
+END WHILE;
+SET i2 = i2 -1;
+END WHILE;
+SET i1 = i1 - 1;
+END WHILE;
+END |
+CALL insert_data();
+SELECT COUNT(*) FROM t1 WHERE id1 > 10;
+COUNT(*)
+10
+SELECT COUNT(*) FROM t2 WHERE id2 > 10;
+COUNT(*)
+20
+SELECT COUNT(*) FROM t3 WHERE id3 > 10;
+COUNT(*)
+40
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+6
+SELECT COUNT(*) FROM t3;
+COUNT(*)
+12
+DROP PROCEDURE insert_data;
+DROP TABLE t1, t2, t3;
+set storage_engine= @save_storage_engine;

=== modified file 'mysql-test/r/innodb_mrr.result'
--- a/mysql-test/r/innodb_mrr.result	2011-01-14 10:07:50 +0000
+++ b/mysql-test/r/innodb_mrr.result	2011-01-17 21:26:04 +0000
@@ -724,3 +724,15 @@
 MS	United States of Ame
 JA	USA
 DROP TABLE t1,t2;
+#
+# Testcase backport: Bug#43249
+#
+CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, c3 DATE, PRIMARY KEY(c1), UNIQUE INDEX(c2)) engine=innodb;
+INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01');
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
+c1	c2	c3
+08:29:45	NULL	2009-02-01
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
+c1	c2	c3
+08:29:45	NULL	2009-02-01
+drop table `t1`;

=== added file 'mysql-test/r/maria_icp.result'
--- a/mysql-test/r/maria_icp.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/maria_icp.result	2011-01-14 14:30:27 +0000
@@ -0,0 +1,153 @@
+set @save_storage_engine= @@storage_engine;
+set storage_engine=Maria;
+#
+# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for
+#             null-safe operator <=> NULL
+#
+CREATE TABLE t1(
+c1 DATE NOT NULL,
+c2 DATE NULL,
+c3 DATETIME,
+c4 TIMESTAMP,
+PRIMARY KEY(c1),
+UNIQUE(c2)
+);
+
+INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05');
+INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26');
+INSERT INTO t1 VALUES('2008-01-01', NULL        , '2008-01-02', '2008-01-03');
+INSERT INTO t1 VALUES('2008-01-17', NULL        , NULL        , '2009-01-29');
+INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29');
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+DROP TABLE t1;
+#
+# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on
+#
+CREATE TABLE t (
+dummy INT PRIMARY KEY, 
+a INT UNIQUE, 
+b INT
+);
+INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5);
+SELECT * FROM t WHERE a > 2 FOR UPDATE;
+dummy	a	b
+3	3	3
+5	5	5
+DROP TABLE t;
+#
+# Bug#35080 - Innodb crash at mem_block_get_len line 72
+#
+CREATE TABLE t1 (
+t1_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+PRIMARY KEY (t1_autoinc),
+KEY k (uuid)
+);
+CREATE TABLE t2 (
+t2_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+date DATETIME DEFAULT NULL,
+PRIMARY KEY (t2_autoinc),
+KEY k (uuid)
+);
+CREATE VIEW v1 AS 
+SELECT t1_autoinc, uuid
+FROM t1
+WHERE (ISNULL(uuid) OR (uuid like '%-%'));
+CREATE VIEW v2 AS 
+SELECT t2_autoinc, uuid, date 
+FROM t2
+WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36));
+CREATE PROCEDURE delete_multi (IN uuid CHAR(36))
+DELETE v1, v2 FROM v1 INNER JOIN v2
+ON v1.uuid = v2.uuid
+WHERE v1.uuid = @uuid;
+SET @uuid = UUID();
+INSERT INTO v1 (uuid) VALUES (@uuid);
+INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09');
+CALL delete_multi(@uuid);
+DROP procedure delete_multi;
+DROP table t1,t2;
+DROP view v1,v2;
+#
+# Bug#41996 - multi-table delete crashes server (InnoDB table)
+#
+CREATE TABLE t1 (
+b BIGINT,
+i INT, 
+KEY (b)
+);
+INSERT INTO t1 VALUES (2, 2);
+DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b;
+DROP TABLE t1;
+#
+# Bug#43448 - Server crashes on multi table delete with Innodb
+#
+CREATE TABLE t1 (
+id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+t CHAR(12)
+);
+CREATE TABLE t2 (
+id2 INT NOT NULL, 
+t CHAR(12)
+);
+CREATE TABLE t3(
+id3 INT NOT NULL, 
+t CHAR(12), 
+INDEX(id3)
+);
+CREATE PROCEDURE insert_data ()
+BEGIN
+DECLARE i1 INT DEFAULT 20;
+DECLARE i2 INT;
+DECLARE i3 INT;
+WHILE (i1 > 0) DO
+INSERT INTO t1(t) VALUES (i1);
+SET i2 = 2;
+WHILE (i2 > 0) DO
+INSERT INTO t2(id2, t) VALUES (i1, i2);
+SET i3 = 2;
+WHILE (i3 > 0) DO
+INSERT INTO t3(id3, t) VALUES (i1, i2);
+SET i3 = i3 -1;
+END WHILE;
+SET i2 = i2 -1;
+END WHILE;
+SET i1 = i1 - 1;
+END WHILE;
+END |
+CALL insert_data();
+SELECT COUNT(*) FROM t1 WHERE id1 > 10;
+COUNT(*)
+10
+SELECT COUNT(*) FROM t2 WHERE id2 > 10;
+COUNT(*)
+20
+SELECT COUNT(*) FROM t3 WHERE id3 > 10;
+COUNT(*)
+40
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+6
+SELECT COUNT(*) FROM t3;
+COUNT(*)
+12
+DROP PROCEDURE insert_data;
+DROP TABLE t1, t2, t3;
+set storage_engine= @save_storage_engine;

=== added file 'mysql-test/r/myisam_icp.result'
--- a/mysql-test/r/myisam_icp.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/myisam_icp.result	2011-01-14 14:30:27 +0000
@@ -0,0 +1,150 @@
+#
+# Bug#42580 - Innodb's ORDER BY ..LIMIT returns no rows for
+#             null-safe operator <=> NULL
+#
+CREATE TABLE t1(
+c1 DATE NOT NULL,
+c2 DATE NULL,
+c3 DATETIME,
+c4 TIMESTAMP,
+PRIMARY KEY(c1),
+UNIQUE(c2)
+);
+
+INSERT INTO t1 VALUES('0000-00-00', '0000-00-00', '2008-01-04', '2008-01-05');
+INSERT INTO t1 VALUES('2007-05-25', '2007-05-25', '2007-05-26', '2007-05-26');
+INSERT INTO t1 VALUES('2008-01-01', NULL        , '2008-01-02', '2008-01-03');
+INSERT INTO t1 VALUES('2008-01-17', NULL        , NULL        , '2009-01-29');
+INSERT INTO t1 VALUES('2009-01-29', '2009-01-29', '2009-01-29', '2009-01-29');
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c1,c2 LIMIT 2;
+c1	c2	c3	c4
+2008-01-01	NULL	2008-01-02 00:00:00	2008-01-03 00:00:00
+2008-01-17	NULL	NULL	2009-01-29 00:00:00
+
+DROP TABLE t1;
+#
+# Bug#40992 - InnoDB: Crash when engine_condition_pushdown is on
+#
+CREATE TABLE t (
+dummy INT PRIMARY KEY, 
+a INT UNIQUE, 
+b INT
+);
+INSERT INTO t VALUES (1,1,1),(3,3,3),(5,5,5);
+SELECT * FROM t WHERE a > 2 FOR UPDATE;
+dummy	a	b
+3	3	3
+5	5	5
+DROP TABLE t;
+#
+# Bug#35080 - Innodb crash at mem_block_get_len line 72
+#
+CREATE TABLE t1 (
+t1_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+PRIMARY KEY (t1_autoinc),
+KEY k (uuid)
+);
+CREATE TABLE t2 (
+t2_autoinc INT(11) NOT NULL AUTO_INCREMENT,
+uuid VARCHAR(36) DEFAULT NULL,
+date DATETIME DEFAULT NULL,
+PRIMARY KEY (t2_autoinc),
+KEY k (uuid)
+);
+CREATE VIEW v1 AS 
+SELECT t1_autoinc, uuid
+FROM t1
+WHERE (ISNULL(uuid) OR (uuid like '%-%'));
+CREATE VIEW v2 AS 
+SELECT t2_autoinc, uuid, date 
+FROM t2
+WHERE (ISNULL(uuid) OR (LENGTH(uuid) = 36));
+CREATE PROCEDURE delete_multi (IN uuid CHAR(36))
+DELETE v1, v2 FROM v1 INNER JOIN v2
+ON v1.uuid = v2.uuid
+WHERE v1.uuid = @uuid;
+SET @uuid = UUID();
+INSERT INTO v1 (uuid) VALUES (@uuid);
+INSERT INTO v2 (uuid, date) VALUES (@uuid, '2009-09-09');
+CALL delete_multi(@uuid);
+DROP procedure delete_multi;
+DROP table t1,t2;
+DROP view v1,v2;
+#
+# Bug#41996 - multi-table delete crashes server (InnoDB table)
+#
+CREATE TABLE t1 (
+b BIGINT,
+i INT, 
+KEY (b)
+);
+INSERT INTO t1 VALUES (2, 2);
+DELETE t1 FROM t1 a, t1 WHERE a.i=t1.b;
+DROP TABLE t1;
+#
+# Bug#43448 - Server crashes on multi table delete with Innodb
+#
+CREATE TABLE t1 (
+id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
+t CHAR(12)
+);
+CREATE TABLE t2 (
+id2 INT NOT NULL, 
+t CHAR(12)
+);
+CREATE TABLE t3(
+id3 INT NOT NULL, 
+t CHAR(12), 
+INDEX(id3)
+);
+CREATE PROCEDURE insert_data ()
+BEGIN
+DECLARE i1 INT DEFAULT 20;
+DECLARE i2 INT;
+DECLARE i3 INT;
+WHILE (i1 > 0) DO
+INSERT INTO t1(t) VALUES (i1);
+SET i2 = 2;
+WHILE (i2 > 0) DO
+INSERT INTO t2(id2, t) VALUES (i1, i2);
+SET i3 = 2;
+WHILE (i3 > 0) DO
+INSERT INTO t3(id3, t) VALUES (i1, i2);
+SET i3 = i3 -1;
+END WHILE;
+SET i2 = i2 -1;
+END WHILE;
+SET i1 = i1 - 1;
+END WHILE;
+END |
+CALL insert_data();
+SELECT COUNT(*) FROM t1 WHERE id1 > 10;
+COUNT(*)
+10
+SELECT COUNT(*) FROM t2 WHERE id2 > 10;
+COUNT(*)
+20
+SELECT COUNT(*) FROM t3 WHERE id3 > 10;
+COUNT(*)
+40
+DELETE t1, t2, t3 
+FROM t1, t2, t3 
+WHERE t1.id1 = t2.id2 AND t2.id2 = t3.id3 AND t1.id1 > 3;
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+3
+SELECT COUNT(*) FROM t2;
+COUNT(*)
+6
+SELECT COUNT(*) FROM t3;
+COUNT(*)
+12
+DROP PROCEDURE insert_data;
+DROP TABLE t1, t2, t3;

=== modified file 'mysql-test/r/subselect4.result'
--- a/mysql-test/r/subselect4.result	2010-12-11 07:23:34 +0000
+++ b/mysql-test/r/subselect4.result	2011-01-14 17:40:16 +0000
@@ -483,3 +483,191 @@
 # Restore old value for Index condition pushdown
 SET SESSION engine_condition_pushdown=@old_icp;
 DROP TABLE t1,t2;
+#
+# BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(),
+#            file item.cc, line 4448"
+#
+DROP TABLE IF EXISTS C, BB;
+CREATE TABLE C (
+varchar_nokey varchar(1) NOT NULL
+);
+INSERT INTO C VALUES
+('k'),('a'),(''),('u'),('e'),('v'),('i'),
+('t'),('u'),('f'),('u'),('m'),('j'),('f'),
+('v'),('j'),('g'),('e'),('h'),('z');
+CREATE TABLE BB (
+varchar_nokey varchar(1) NOT NULL
+);
+INSERT INTO BB VALUES ('i'),('t');
+SELECT varchar_nokey FROM C
+WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey
+FROM BB);
+ERROR 21000: Operand should contain 2 column(s)
+SELECT varchar_nokey FROM C
+WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey
+FROM BB);
+ERROR 42S22: Unknown column 'OUTR' in 'IN/ALL/ANY subquery'
+DROP TABLE C,BB;
+#
+# During work with BUG#45863 I had problems with a query that was
+# optimized differently in regular and prepared mode.
+# Because there was a bug in one of the selected strategies, I became
+# aware of the problem. Adding an EXPLAIN query to catch this.
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1
+(EMPNUM   CHAR(3) NOT NULL,
+EMPNAME  CHAR(20),
+GRADE    DECIMAL(4),
+CITY     CHAR(15));
+CREATE TABLE t2
+(PNUM     CHAR(3) NOT NULL,
+PNAME    CHAR(20),
+PTYPE    CHAR(6),
+BUDGET   DECIMAL(9),
+CITY     CHAR(15));
+CREATE TABLE t3
+(EMPNUM   CHAR(3) NOT NULL,
+PNUM     CHAR(3) NOT NULL,
+HOURS    DECIMAL(5));
+INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
+INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
+INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
+INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
+INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
+INSERT INTO t3 VALUES  ('E1','P1',40);
+INSERT INTO t3 VALUES  ('E1','P2',20);
+INSERT INTO t3 VALUES  ('E1','P3',80);
+INSERT INTO t3 VALUES  ('E1','P4',20);
+INSERT INTO t3 VALUES  ('E1','P5',12);
+INSERT INTO t3 VALUES  ('E1','P6',12);
+INSERT INTO t3 VALUES  ('E2','P1',40);
+INSERT INTO t3 VALUES  ('E2','P2',80);
+INSERT INTO t3 VALUES  ('E3','P2',20);
+INSERT INTO t3 VALUES  ('E4','P2',20);
+INSERT INTO t3 VALUES  ('E4','P4',40);
+INSERT INTO t3 VALUES  ('E4','P5',80);
+SET @old_optimizer_switch = @@session.optimizer_switch;
+SET @old_join_cache_level = @@session.join_cache_level;
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION join_cache_level = 1;
+CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	SIMPLE	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+DEALLOCATE PREPARE stmt;
+DROP INDEX t1_IDX ON t1;
+CREATE INDEX t1_IDX ON t1(EMPNUM);
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	t1_IDX	NULL	NULL	NULL	5	
+1	SIMPLE	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+DEALLOCATE PREPARE stmt;
+DROP INDEX t1_IDX ON t1;
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+(SELECT EMPNUM
+FROM t3
+WHERE PNUM IN
+(SELECT PNUM
+FROM t2
+WHERE PTYPE = 'Design'));
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	5	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+EXECUTE stmt;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	5	
+1	SIMPLE	subselect2	eq_ref	unique_key	unique_key	3	func	1	
+2	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	6	Using where
+2	SUBQUERY	t3	ALL	NULL	NULL	NULL	NULL	12	Using where; Using join buffer (flat, BNL join)
+DEALLOCATE PREPARE stmt;
+SET SESSION optimizer_switch = @old_optimizer_switch;
+SET SESSION join_cache_level = @old_join_cache_level;
+DROP TABLE t1, t2, t3;

=== modified file 'mysql-test/r/subselect_mat.result'
--- a/mysql-test/r/subselect_mat.result	2010-12-11 07:23:34 +0000
+++ b/mysql-test/r/subselect_mat.result	2011-01-14 10:51:30 +0000
@@ -1344,3 +1344,30 @@
 c2	c2
 10	10
 DROP TABLE t1, t2;
+# 
+# Testcase backport: BUG#46548 IN-subqueries return 0 rows with materialization=on
+# 
+CREATE TABLE t1 (
+pk int,
+a varchar(1),
+b varchar(4),
+c varchar(4),
+d varchar(4),
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	
+1	PRIMARY	subselect2	eq_ref	unique_key	unique_key	5	func	1	
+2	SUBQUERY	t2	range	PRIMARY	PRIMARY	4	NULL	2	Using index condition; Using MRR
+SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+pk
+2
+SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
+pk
+2
+DROP TABLE t1, t2;

=== modified file 'mysql-test/r/subselect_sj.result'
--- a/mysql-test/r/subselect_sj.result	2011-01-15 19:14:36 +0000
+++ b/mysql-test/r/subselect_sj.result	2011-01-17 21:26:04 +0000
@@ -1119,4 +1119,125 @@
 varchar_key
 set optimizer_switch=@save_optimizer_switch;
 DROP TABLE t1, t2, t3;
+#
+# Bug#46692 "Crash occurring on queries with nested FROM subqueries 
+# using materialization."
+#
+CREATE TABLE t1 (
+pk INTEGER PRIMARY KEY,
+int_key INTEGER,
+KEY int_key(int_key)
+);
+INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1);
+CREATE TABLE t2 (
+pk INTEGER PRIMARY KEY,
+int_key INTEGER,
+KEY int_key(int_key)
+);
+INSERT INTO t2 VALUES (1,7),(2,2);
+SELECT * FROM t1 WHERE (140, 4) IN 
+(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key);
+pk	int_key
+DROP TABLE t1, t2;
+#
+# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query
+# causes crash."
+#
+CREATE TABLE t1 (
+pk INTEGER PRIMARY KEY,
+int_nokey INTEGER,
+int_key INTEGER,
+date_key DATE,
+datetime_nokey DATETIME,
+varchar_nokey VARCHAR(1)
+);
+CREATE TABLE t2 (
+date_nokey DATE
+);
+CREATE TABLE t3 (
+pk INTEGER PRIMARY KEY,
+int_nokey INTEGER,
+date_key date,
+varchar_key VARCHAR(1),
+varchar_nokey VARCHAR(1),
+KEY date_key (date_key)
+);
+SELECT date_key FROM t1
+WHERE (int_key, int_nokey)
+IN (SELECT  t3.int_nokey, t3.pk
+FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 
+WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk
+)
+AND (varchar_nokey <> 'f' OR NOT int_key < 7);
+date_key
+#
+# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 
+# + AND in outer query".
+#
+INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'),
+(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 
+(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 
+(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 
+(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 
+(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 
+(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 
+(29,9,1,'0000-00-00','2003-08-11 00:00:00','m');
+INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'),
+(2,2,'2002-09-17','h','h');
+SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey
+WHERE t1.varchar_nokey 
+IN (SELECT varchar_nokey FROM t1 
+WHERE (pk) 
+IN (SELECT t3.int_nokey
+FROM t3 LEFT JOIN t1 ON t1.varchar_nokey
+WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26'
+           )  
+);
+varchar_nokey
+DROP TABLE t1, t2, t3;
+#
+# Bug#45219 "Crash on SELECT DISTINCT query containing a  
+# LEFT JOIN in subquery"
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+int_nokey INTEGER NOT NULL,
+datetime_key DATETIME NOT NULL,
+varchar_key VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY datetime_key (datetime_key),
+KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'),
+(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'),
+(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'),
+(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'),
+(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'),
+(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'),
+(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'),
+(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'),
+(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''),
+(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES 
+(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'),
+(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'),
+(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''),
+(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'),
+(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'),
+(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'),
+(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''),
+(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'),
+(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'),
+(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x');
+CREATE TABLE t3 LIKE t1;
+INSERT INTO t3 VALUES
+(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51','');
+SELECT DISTINCT datetime_key FROM t1
+WHERE (int_nokey, pk)  
+IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)  
+AND pk = 9;
+datetime_key
+DROP TABLE t1, t2, t3;
 set @@optimizer_switch=@save_optimizer_switch;

=== modified file 'mysql-test/r/subselect_sj_jcl6.result'
--- a/mysql-test/r/subselect_sj_jcl6.result	2011-01-15 19:14:36 +0000
+++ b/mysql-test/r/subselect_sj_jcl6.result	2011-01-17 21:26:04 +0000
@@ -1126,6 +1126,127 @@
 varchar_key
 set optimizer_switch=@save_optimizer_switch;
 DROP TABLE t1, t2, t3;
+#
+# Bug#46692 "Crash occurring on queries with nested FROM subqueries 
+# using materialization."
+#
+CREATE TABLE t1 (
+pk INTEGER PRIMARY KEY,
+int_key INTEGER,
+KEY int_key(int_key)
+);
+INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1);
+CREATE TABLE t2 (
+pk INTEGER PRIMARY KEY,
+int_key INTEGER,
+KEY int_key(int_key)
+);
+INSERT INTO t2 VALUES (1,7),(2,2);
+SELECT * FROM t1 WHERE (140, 4) IN 
+(SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key);
+pk	int_key
+DROP TABLE t1, t2;
+#
+# Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query
+# causes crash."
+#
+CREATE TABLE t1 (
+pk INTEGER PRIMARY KEY,
+int_nokey INTEGER,
+int_key INTEGER,
+date_key DATE,
+datetime_nokey DATETIME,
+varchar_nokey VARCHAR(1)
+);
+CREATE TABLE t2 (
+date_nokey DATE
+);
+CREATE TABLE t3 (
+pk INTEGER PRIMARY KEY,
+int_nokey INTEGER,
+date_key date,
+varchar_key VARCHAR(1),
+varchar_nokey VARCHAR(1),
+KEY date_key (date_key)
+);
+SELECT date_key FROM t1
+WHERE (int_key, int_nokey)
+IN (SELECT  t3.int_nokey, t3.pk
+FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 
+WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk
+)
+AND (varchar_nokey <> 'f' OR NOT int_key < 7);
+date_key
+#
+# Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 
+# + AND in outer query".
+#
+INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'),
+(11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 
+(12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 
+(13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 
+(14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 
+(15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 
+(16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 
+(29,9,1,'0000-00-00','2003-08-11 00:00:00','m');
+INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'),
+(2,2,'2002-09-17','h','h');
+SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey
+WHERE t1.varchar_nokey 
+IN (SELECT varchar_nokey FROM t1 
+WHERE (pk) 
+IN (SELECT t3.int_nokey
+FROM t3 LEFT JOIN t1 ON t1.varchar_nokey
+WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26'
+           )  
+);
+varchar_nokey
+DROP TABLE t1, t2, t3;
+#
+# Bug#45219 "Crash on SELECT DISTINCT query containing a  
+# LEFT JOIN in subquery"
+#
+CREATE TABLE t1 (
+pk INTEGER NOT NULL,
+int_nokey INTEGER NOT NULL,
+datetime_key DATETIME NOT NULL,
+varchar_key VARCHAR(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY datetime_key (datetime_key),
+KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'),
+(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'),
+(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'),
+(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'),
+(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'),
+(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'),
+(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'),
+(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'),
+(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''),
+(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u');
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES 
+(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'),
+(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'),
+(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''),
+(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'),
+(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'),
+(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'),
+(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''),
+(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'),
+(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'),
+(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x');
+CREATE TABLE t3 LIKE t1;
+INSERT INTO t3 VALUES
+(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51','');
+SELECT DISTINCT datetime_key FROM t1
+WHERE (int_nokey, pk)  
+IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)  
+AND pk = 9;
+datetime_key
+DROP TABLE t1, t2, t3;
 set @@optimizer_switch=@save_optimizer_switch;
 #
 # BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off

=== modified file 'mysql-test/suite/optimizer_unfixed_bugs/r/bug49129.result'
--- a/mysql-test/suite/optimizer_unfixed_bugs/r/bug49129.result	2009-12-15 07:16:46 +0000
+++ b/mysql-test/suite/optimizer_unfixed_bugs/r/bug49129.result	2011-01-17 12:09:30 +0000
@@ -26,9 +26,9 @@
 1
 2
 3
+SET SESSION optimizer_switch = 'semijoin=off';
 
 # This result is correct
-SET SESSION optimizer_switch = 'semijoin=off';
 SELECT * FROM t0 WHERE t0.a IN 
 (SELECT t1.a FROM t1, t2 WHERE t2.a=t0.a AND t1.b=t2.b);
 a

=== modified file 'mysql-test/suite/optimizer_unfixed_bugs/t/disabled.def'
--- a/mysql-test/suite/optimizer_unfixed_bugs/t/disabled.def	2009-12-15 07:16:46 +0000
+++ b/mysql-test/suite/optimizer_unfixed_bugs/t/disabled.def	2011-01-17 12:09:30 +0000
@@ -1,6 +1,5 @@
 # Disabling all subquery problems
 
-bug49129             : Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
 bug45221             : Query "SELECT pk FROM C WHERE pk IN (SELECT # int_key)" failing
 bug45219             : Azalea crash on query containing a JOIN in subquery
 

=== added file 'mysql-test/t/innodb_icp.test'
--- a/mysql-test/t/innodb_icp.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/innodb_icp.test	2011-01-14 13:38:41 +0000
@@ -0,0 +1,13 @@
+#
+# ICP/InnoDB tests (Index Condition Pushdown)
+#
+
+--source include/have_innodb.inc
+
+set @save_storage_engine= @@storage_engine;
+set storage_engine=InnoDB;
+
+--source include/icp_tests.inc
+
+set storage_engine= @save_storage_engine;
+

=== modified file 'mysql-test/t/innodb_mrr.test'
--- a/mysql-test/t/innodb_mrr.test	2011-01-14 10:07:50 +0000
+++ b/mysql-test/t/innodb_mrr.test	2011-01-17 21:26:04 +0000
@@ -415,3 +415,14 @@
 
 DROP TABLE t1,t2;
 
+--echo #
+--echo # Testcase backport: Bug#43249
+--echo #
+CREATE TABLE t1(c1 TIME NOT NULL, c2 TIME NULL, c3 DATE, PRIMARY KEY(c1), UNIQUE INDEX(c2)) engine=innodb;
+INSERT INTO t1 VALUES('8:29:45',NULL,'2009-02-01');
+# first time, good results:
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
+# second time, bad results:
+SELECT * FROM t1 WHERE c2 <=> NULL ORDER BY c2 LIMIT 2;
+drop table `t1`;
+

=== added file 'mysql-test/t/maria_icp.test'
--- a/mysql-test/t/maria_icp.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/maria_icp.test	2011-01-14 13:38:41 +0000
@@ -0,0 +1,13 @@
+#
+# ICP/Maria tests (Index Condition Pushdown)
+#
+
+--source include/have_maria.inc
+
+set @save_storage_engine= @@storage_engine;
+set storage_engine=Maria;
+
+--source include/icp_tests.inc
+
+set storage_engine= @save_storage_engine;
+

=== added file 'mysql-test/t/myisam_icp.test'
--- a/mysql-test/t/myisam_icp.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/myisam_icp.test	2011-01-14 13:38:41 +0000
@@ -0,0 +1,6 @@
+#
+# ICP/MyISAM tests (Index Condition Pushdown)
+#
+
+--source include/icp_tests.inc
+

=== modified file 'mysql-test/t/subselect4.test'
--- a/mysql-test/t/subselect4.test	2010-12-06 08:25:44 +0000
+++ b/mysql-test/t/subselect4.test	2011-01-14 17:40:16 +0000
@@ -432,3 +432,173 @@
 SET SESSION engine_condition_pushdown=@old_icp;
 
 DROP TABLE t1,t2;
+
+--echo #
+--echo # BUG#45863 "Assertion failed: (fixed == 0), function fix_fields(),
+--echo #            file item.cc, line 4448"
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS C, BB;
+--enable_warnings
+
+CREATE TABLE C (
+  varchar_nokey varchar(1) NOT NULL
+);
+INSERT INTO C VALUES
+  ('k'),('a'),(''),('u'),('e'),('v'),('i'),
+  ('t'),('u'),('f'),('u'),('m'),('j'),('f'),
+  ('v'),('j'),('g'),('e'),('h'),('z');
+CREATE TABLE BB (
+  varchar_nokey varchar(1) NOT NULL
+);
+INSERT INTO BB VALUES ('i'),('t');
+-- error ER_OPERAND_COLUMNS
+SELECT varchar_nokey FROM C
+WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey
+                                FROM BB);
+-- error ER_BAD_FIELD_ERROR
+SELECT varchar_nokey FROM C
+WHERE (varchar_nokey, OUTR) IN (SELECT varchar_nokey, varchar_nokey
+                                FROM BB);
+DROP TABLE C,BB;
+
+--echo #
+--echo # During work with BUG#45863 I had problems with a query that was
+--echo # optimized differently in regular and prepared mode.
+--echo # Because there was a bug in one of the selected strategies, I became
+--echo # aware of the problem. Adding an EXPLAIN query to catch this.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1
+ (EMPNUM   CHAR(3) NOT NULL,
+  EMPNAME  CHAR(20),
+  GRADE    DECIMAL(4),
+  CITY     CHAR(15));
+
+CREATE TABLE t2
+ (PNUM     CHAR(3) NOT NULL,
+  PNAME    CHAR(20),
+  PTYPE    CHAR(6),
+  BUDGET   DECIMAL(9),
+  CITY     CHAR(15));
+
+CREATE TABLE t3
+ (EMPNUM   CHAR(3) NOT NULL,
+  PNUM     CHAR(3) NOT NULL,
+  HOURS    DECIMAL(5));
+
+INSERT INTO t1 VALUES ('E1','Alice',12,'Deale');
+INSERT INTO t1 VALUES ('E2','Betty',10,'Vienna');
+INSERT INTO t1 VALUES ('E3','Carmen',13,'Vienna');
+INSERT INTO t1 VALUES ('E4','Don',12,'Deale');
+INSERT INTO t1 VALUES ('E5','Ed',13,'Akron');
+
+INSERT INTO t2 VALUES ('P1','MXSS','Design',10000,'Deale');
+INSERT INTO t2 VALUES ('P2','CALM','Code',30000,'Vienna');
+INSERT INTO t2 VALUES ('P3','SDP','Test',30000,'Tampa');
+INSERT INTO t2 VALUES ('P4','SDP','Design',20000,'Deale');
+INSERT INTO t2 VALUES ('P5','IRM','Test',10000,'Vienna');
+INSERT INTO t2 VALUES ('P6','PAYR','Design',50000,'Deale');
+
+INSERT INTO t3 VALUES  ('E1','P1',40);
+INSERT INTO t3 VALUES  ('E1','P2',20);
+INSERT INTO t3 VALUES  ('E1','P3',80);
+INSERT INTO t3 VALUES  ('E1','P4',20);
+INSERT INTO t3 VALUES  ('E1','P5',12);
+INSERT INTO t3 VALUES  ('E1','P6',12);
+INSERT INTO t3 VALUES  ('E2','P1',40);
+INSERT INTO t3 VALUES  ('E2','P2',80);
+INSERT INTO t3 VALUES  ('E3','P2',20);
+INSERT INTO t3 VALUES  ('E4','P2',20);
+INSERT INTO t3 VALUES  ('E4','P4',40);
+INSERT INTO t3 VALUES  ('E4','P5',80);
+
+SET @old_optimizer_switch = @@session.optimizer_switch;
+SET @old_join_cache_level = @@session.join_cache_level;
+SET SESSION optimizer_switch = 'firstmatch=on,loosescan=on,materialization=on,semijoin=on';
+SET SESSION join_cache_level = 1;
+
+CREATE UNIQUE INDEX t1_IDX ON t1(EMPNUM);
+
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'));
+
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+DROP INDEX t1_IDX ON t1;
+CREATE INDEX t1_IDX ON t1(EMPNUM);
+
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'));
+
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+DROP INDEX t1_IDX ON t1;
+
+EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'));
+
+PREPARE stmt FROM "EXPLAIN SELECT EMPNAME
+FROM t1
+WHERE EMPNUM IN
+   (SELECT EMPNUM
+    FROM t3
+    WHERE PNUM IN
+       (SELECT PNUM
+        FROM t2
+        WHERE PTYPE = 'Design'))";
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SET SESSION optimizer_switch = @old_optimizer_switch;
+SET SESSION join_cache_level = @old_join_cache_level;
+
+DROP TABLE t1, t2, t3;
+

=== modified file 'mysql-test/t/subselect_mat.test'
--- a/mysql-test/t/subselect_mat.test	2010-11-25 09:43:23 +0000
+++ b/mysql-test/t/subselect_mat.test	2011-01-14 10:51:30 +0000
@@ -988,3 +988,26 @@
 EXECUTE st1;
 
 DROP TABLE t1, t2;
+
+--echo # 
+--echo # Testcase backport: BUG#46548 IN-subqueries return 0 rows with materialization=on
+--echo # 
+CREATE TABLE t1 (
+  pk int,
+  a varchar(1),
+  b varchar(4),
+  c varchar(4),
+  d varchar(4),
+  PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff');
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff');
+
+SET @@optimizer_switch='default,semijoin=on,materialization=on';
+EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0);
+SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0);
+DROP TABLE t1, t2;
+

=== modified file 'mysql-test/t/subselect_sj.test'
--- a/mysql-test/t/subselect_sj.test	2010-12-11 07:23:34 +0000
+++ b/mysql-test/t/subselect_sj.test	2011-01-14 23:07:04 +0000
@@ -982,5 +982,141 @@
 set optimizer_switch=@save_optimizer_switch;
 DROP TABLE t1, t2, t3;
 
+--echo #
+--echo # Bug#46692 "Crash occurring on queries with nested FROM subqueries 
+--echo # using materialization."
+--echo #
+CREATE TABLE t1 (
+  pk INTEGER PRIMARY KEY,
+  int_key INTEGER,
+  KEY int_key(int_key)
+);
+INSERT INTO t1 VALUES (10,186),(11,NULL),(12,2),(13,3),(14,0),(15,133),(16,1);
+
+CREATE TABLE t2 (
+  pk INTEGER PRIMARY KEY,
+  int_key INTEGER,
+  KEY int_key(int_key)
+);
+INSERT INTO t2 VALUES (1,7),(2,2);
+
+SELECT * FROM t1 WHERE (140, 4) IN 
+  (SELECT t2.int_key, t2 .pk FROM t2 STRAIGHT_JOIN t1 ON t2.int_key);
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#42353 "SELECT ... WHERE oe IN (SELECT w/ LEFT JOIN) query
+--echo # causes crash."
+--echo #
+CREATE TABLE t1 (
+  pk INTEGER PRIMARY KEY,
+  int_nokey INTEGER,
+  int_key INTEGER,
+  date_key DATE,
+  datetime_nokey DATETIME,
+  varchar_nokey VARCHAR(1)
+);
+
+CREATE TABLE t2 (
+  date_nokey DATE
+);
+
+CREATE TABLE t3 (
+  pk INTEGER PRIMARY KEY,
+  int_nokey INTEGER,
+  date_key date,
+  varchar_key VARCHAR(1),
+  varchar_nokey VARCHAR(1),
+  KEY date_key (date_key)
+);
+
+SELECT date_key FROM t1
+WHERE (int_key, int_nokey)
+  IN (SELECT  t3.int_nokey, t3.pk
+      FROM t2 LEFT JOIN t3 ON (t2.date_nokey < t3.date_key) 
+      WHERE t3.varchar_key <= t3.varchar_nokey OR t3.int_nokey <= t3.pk
+     )
+  AND (varchar_nokey <> 'f' OR NOT int_key < 7); 
+
+
+--echo #
+--echo # Bug#45933 "Crash in optimize_semijoin_nests on JOIN in subquery 
+--echo # + AND in outer query".
+--echo #
+INSERT INTO t1 VALUES (10,7,5,'2009-06-16','2002-04-10 14:25:30','w'),
+                      (11,7,0,'0000-00-00','0000-00-00 00:00:00','s'), 
+		      (12,4,0,'2003-07-14','2006-09-14 04:01:02','y'), 
+		      (13,0,4,'2002-07-25','0000-00-00 00:00:00','c'), 
+		      (14,1,8,'2007-07-03','0000-00-00 00:00:00','q'), 
+		      (15,6,5,'2001-11-12','0000-00-00 00:00:00',''), 
+		      (16,2,9,'0000-00-00','0000-00-00 00:00:00','j'), 
+		      (29,9,1,'0000-00-00','2003-08-11 00:00:00','m');
+INSERT INTO t3 VALUES (1,9,'0000-00-00','b','b'),
+                      (2,2,'2002-09-17','h','h');
+
+SELECT t1.varchar_nokey FROM t1 JOIN t3 ON t1.datetime_nokey
+WHERE t1.varchar_nokey 
+  IN (SELECT varchar_nokey FROM t1 
+      WHERE (pk) 
+        IN (SELECT t3.int_nokey
+            FROM t3 LEFT JOIN t1 ON t1.varchar_nokey
+            WHERE t3.date_key BETWEEN '2008-06-07' AND '2006-06-26'
+           )  
+     );
+
+DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # Bug#45219 "Crash on SELECT DISTINCT query containing a  
+--echo # LEFT JOIN in subquery"
+--echo #
+
+CREATE TABLE t1 (
+  pk INTEGER NOT NULL,
+  int_nokey INTEGER NOT NULL,
+  datetime_key DATETIME NOT NULL,
+  varchar_key VARCHAR(1) NOT NULL,
+  PRIMARY KEY (pk),
+  KEY datetime_key (datetime_key),
+  KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,9,'0000-00-00 00:00:00','p'),(2,0,'2002-02-09 07:38:13','v'),
+(3,8,'2001-05-03 12:08:14','t'),(4,3,'0000-00-00 00:00:00','u'),
+(5,7,'2009-07-28 03:43:30','n'),(6,0,'2009-08-04 00:00:00','l'),
+(7,1,'0000-00-00 00:00:00','h'),(8,9,'0000-00-00 00:00:00','u'),
+(9,0,'2005-08-02 17:16:54','n'),(10,9,'2002-12-21 00:00:00','j'),
+(11,0,'2005-08-15 12:37:35','k'),(12,5,'0000-00-00 00:00:00','e'),
+(13,0,'2006-03-10 00:00:00','i'),(14,8,'2005-05-16 11:02:36','u'),
+(15,8,'2008-11-02 00:00:00','n'),(16,5,'2006-03-15 00:00:00','b'),
+(17,1,'0000-00-00 00:00:00','x'),(18,7,'0000-00-00 00:00:00',''),
+(19,0,'2008-12-17 20:15:40','q'),(20,9,'0000-00-00 00:00:00','u');
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 VALUES 
+(10,0,'2006-07-07 07:26:28','q'),(11,5,'2002-09-23 00:00:00','m'),
+(12,7,'0000-00-00 00:00:00','j'),(13,1,'2006-06-07 00:00:00','z'),
+(14,8,'2000-09-16 12:15:34','a'),(15,2,'2007-08-05 15:47:52',''),
+(16,1,'0000-00-00 00:00:00','e'),(17,8,'2005-12-02 19:34:26','t'),
+(18,5,'0000-00-00 00:00:00','q'),(19,4,'0000-00-00 00:00:00','b'),
+(20,5,'2007-12-28 00:00:00','w'),(21,3,'2004-08-02 11:48:43','m'),
+(22,0,'0000-00-00 00:00:00','x'),(23,8,'2004-04-19 12:18:43',''),
+(24,0,'2009-04-27 00:00:00','w'),(25,4,'2006-10-20 14:52:15','x'),
+(26,0,'0000-00-00 00:00:00','e'),(27,0,'2002-03-22 11:48:37','e'),
+(28,2,'0000-00-00 00:00:00','p'),(29,0,'2001-01-04 03:55:07','x');
+
+CREATE TABLE t3 LIKE t1;
+INSERT INTO t3 VALUES
+(10,8,'2007-08-19 08:08:38','i'),(11,0,'2000-05-21 03:51:51','');
+ 
+SELECT DISTINCT datetime_key FROM t1
+WHERE (int_nokey, pk)  
+  IN (SELECT t3.pk, t3.pk FROM t2 LEFT JOIN t3 ON t3.varchar_key)  
+  AND pk = 9;
+
+DROP TABLE t1, t2, t3;
+
+
 # The following command must be the last one the file 
 set @@optimizer_switch=@save_optimizer_switch;

=== modified file 'sql/opt_subselect.cc'
--- a/sql/opt_subselect.cc	2010-11-23 22:08:48 +0000
+++ b/sql/opt_subselect.cc	2011-01-14 23:07:04 +0000
@@ -1152,7 +1152,7 @@
            sj_nest->sj_subq_pred->types_allow_materialization)
       {
         join->emb_sjm_nest= sj_nest;
-        if (choose_plan(join, all_table_map))
+        if (choose_plan(join, all_table_map &~join->const_table_map))
           DBUG_RETURN(TRUE); /* purecov: inspected */
         /*
           The best plan to run the subquery is now in join->best_positions,
@@ -1856,7 +1856,7 @@
       {
         pos->sj_strategy= SJ_OPT_DUPS_WEEDOUT;
         *current_read_time= dups_cost;
-        *current_record_count= *current_record_count / sj_inner_fanout;
+        *current_record_count= prefix_rec_count * sj_outer_fanout;
         join->cur_dups_producing_tables &= ~dups_removed_fanout;
       }
     }

=== modified file 'sql/structs.h'
--- a/sql/structs.h	2010-06-26 10:05:41 +0000
+++ b/sql/structs.h	2011-01-14 09:55:03 +0000
@@ -75,7 +75,6 @@
   uint	key_length;			/* Tot length of key */
   ulong flags;                          /* dupp key and pack flags */
   uint	key_parts;			/* How many key_parts */
-  uint  extra_length;
   uint	usable_key_parts;		/* Should normally be = key_parts */
   uint  block_size;
   uint  name_length;

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2010-12-06 08:25:44 +0000
+++ b/sql/table.cc	2011-01-14 09:55:03 +0000
@@ -1493,7 +1493,6 @@
           key_part->null_bit= field->null_bit;
           key_part->store_length+=HA_KEY_NULL_LENGTH;
           keyinfo->flags|=HA_NULL_PART_KEY;
-          keyinfo->extra_length+= HA_KEY_NULL_LENGTH;
           keyinfo->key_length+= HA_KEY_NULL_LENGTH;
         }
         if (field->type() == MYSQL_TYPE_BLOB ||
@@ -1505,7 +1504,6 @@
             key_part->key_part_flag|= HA_BLOB_PART;
           else
             key_part->key_part_flag|= HA_VAR_LENGTH_PART;
-          keyinfo->extra_length+=HA_KEY_BLOB_LENGTH;
           key_part->store_length+=HA_KEY_BLOB_LENGTH;
           keyinfo->key_length+= HA_KEY_BLOB_LENGTH;
         }



More information about the commits mailing list