List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:October 13 2011 7:55am
Subject:bzr push into mysql-trunk branch (tor.didriksen:3489 to 3490)
View as plain text  
 3490 Tor Didriksen	2011-10-13 [merge]
      merge opt-team => trunk

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
      sql/item.cc
      sql/item.h
      sql/sql_select.cc
      sql/table.cc
      sql/table.h
 3489 Andrei Elkin	2011-10-12
      Bug#13033076 - OCCASIONAL CRASH OF RPL.RPL_PARALLEL_DDL
      
      This is an exploratory patch containing pure test's changes
      to get some info out of pb runs.
      The failure is not necessary crash and ends on non-wins with 
      errno 17 out of mkdir. That makes to think of a garbage left
      in a database dir.
     @ mysql-test/suite/rpl/r/rpl_parallel_ddl.result
        results updated.
     @ mysql-test/suite/rpl/t/rpl_parallel_ddl.test
        Added print-out after rename on the slave to search for
        possible garbage files.

    modified:
      mysql-test/suite/rpl/r/rpl_parallel_ddl.result
      mysql-test/suite/rpl/t/rpl_parallel_ddl.test
=== modified file 'mysql-test/include/subquery_sj.inc'
--- a/mysql-test/include/subquery_sj.inc	2011-10-01 19:26:04 +0000
+++ b/mysql-test/include/subquery_sj.inc	2011-10-07 12:44:17 +0000
@@ -4115,4 +4115,130 @@ DROP TABLE it, ot;
 
 --echo # End of test for bug#12714094
 
+--echo #
+--echo # Bug#12867557: Valgrind: conditional jump/move at key_cmp
+--echo #
+
+CREATE TABLE t1 (
+ pk INTEGER AUTO_INCREMENT,
+ col_int_key INTEGER,
+ PRIMARY KEY (pk),
+ KEY (col_int_key)
+) AUTO_INCREMENT=10;
+
+INSERT INTO t1 (col_int_key) VALUES (8);
+
+CREATE TABLE t2 (
+ pk INTEGER AUTO_INCREMENT,
+ col_int_key INTEGER,
+ col_time_key TIME,
+ PRIMARY KEY (pk),
+ KEY (col_int_key),
+ KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+ (8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+ (7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+ (1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+ (9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+ (0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+ (NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+ (NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+   (SELECT parent1.col_int_key AS p1
+    FROM t1 AS parent1)
+ AND grandparent1.pk > 9;
+
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+   (SELECT grandparent1.col_time_key AS g1
+    FROM t2 AS grandparent1
+    WHERE grandparent1.col_int_key IN
+       (SELECT parent1.col_int_key AS p1
+        FROM t1 AS parent1)
+      AND grandparent1.pk > 9);
+
+DROP TABLE t0, t1, t2;
+
+--echo # End of test for bug#12867557
+
+--echo #
+--echo # Bug#12711441: crash in fix_after_pullout
+--echo #
+
+CREATE TABLE t1 (
+  pk int NOT NULL,
+  col_int_nokey int DEFAULT NULL,
+  col_int_key int DEFAULT NULL,
+  col_time_key time DEFAULT NULL,
+  col_varchar_key varchar(1) DEFAULT NULL,
+  PRIMARY KEY (pk)
+);
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+CREATE TABLE t2 (
+  col_int_key int DEFAULT NULL,
+  col_varchar_key varchar(1) DEFAULT NULL,
+  col_varchar_nokey varchar(1) DEFAULT NULL,
+  KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+
+CREATE TABLE t3 (
+  pk int NOT NULL,
+  col_int_key INT DEFAULT NULL,
+  PRIMARY KEY (pk)
+);
+
+CREATE TABLE t4 (
+  col_int_nokey INT DEFAULT NULL,
+  col_varchar_key varchar(1) DEFAULT NULL,
+  col_varchar_nokey varchar(1) DEFAULT NULL,
+  KEY col_varchar_key(col_varchar_key)
+);
+
+CREATE TABLE ts
+  SELECT alias1.col_time_key AS field1
+  FROM v1 AS alias1
+       RIGHT JOIN t3 AS alias2
+       ON alias2.col_int_key = alias1.col_int_nokey
+  WHERE alias1.pk >= SOME(
+    SELECT SQ1_alias1.pk AS SQ1_field1
+    FROM t3 AS SQ1_alias1
+         INNER JOIN (t2 AS SQ1_alias2
+           INNER JOIN t4 AS SQ1_alias3
+           ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+         ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+    WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+      AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+
+SELECT * FROM ts WHERE field1 IN (
+  SELECT alias1.col_time_key AS field1
+  FROM v1 AS alias1
+       RIGHT JOIN t3 AS alias2
+       ON alias2.col_int_key = alias1.col_int_nokey
+  WHERE alias1.pk >= SOME(
+    SELECT SQ1_alias1.pk AS SQ1_field1
+    FROM t3 AS SQ1_alias1
+         INNER JOIN (t2 AS SQ1_alias2
+           INNER JOIN t4 AS SQ1_alias3
+           ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+          ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+    WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+      AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+
+--echo # End of test for bug#12711441.
+
 --echo # End of 5.6 tests

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2011-10-04 05:55:38 +0000
+++ b/mysql-test/r/subquery_all.result	2011-10-12 13:32:10 +0000
@@ -6733,4 +6733,95 @@ COUNT(*)
 6
 DROP TABLE t1, t2, t3;
 #
+# Bug#12838171: 51VS56: TRANSFORMED IN()+SUBQ QUERY 
+#               PRODUCES EMPTY RESULT ON 5.6, 1 ROW ON 5.1
+#
+CREATE TABLE ot (
+col_int_nokey int(11), 
+col_varchar_nokey varchar(1)
+) ;
+INSERT INTO ot VALUES (1,'x');
+CREATE TABLE it (
+col_int_key int(11), 
+col_varchar_key varchar(1), 
+KEY idx_cvk_cik (col_varchar_key,col_int_key)
+) ;
+INSERT INTO it VALUES (NULL,'x'), (NULL,'f');
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	9	const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	4	const	1	100.00	Using index; FirstMatch(ot)
+Warnings:
+Note	1276	Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and <cache>(coalesce('1',1)))
+DROP TABLE it;
+CREATE TABLE it (
+col_int_key int(11),
+col_varchar_key varchar(1),
+col_varchar_key2 varchar(1),
+KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
+KEY idx_cvk_cik (col_varchar_key, col_int_key)
+);
+INSERT INTO it VALUES (NULL,'x','x'), (NULL,'f','f');
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cvk2_cik,idx_cvk_cik	idx_cvk_cvk2_cik	13	const,const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+DROP TABLE it, ot;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_all_bka.result'
--- a/mysql-test/r/subquery_all_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_all_bka.result	2011-10-13 07:54:52 +0000
@@ -6734,5 +6734,96 @@ COUNT(*)
 6
 DROP TABLE t1, t2, t3;
 #
+# Bug#12838171: 51VS56: TRANSFORMED IN()+SUBQ QUERY 
+#               PRODUCES EMPTY RESULT ON 5.6, 1 ROW ON 5.1
+#
+CREATE TABLE ot (
+col_int_nokey int(11), 
+col_varchar_nokey varchar(1)
+) ;
+INSERT INTO ot VALUES (1,'x');
+CREATE TABLE it (
+col_int_key int(11), 
+col_varchar_key varchar(1), 
+KEY idx_cvk_cik (col_varchar_key,col_int_key)
+) ;
+INSERT INTO it VALUES (NULL,'x'), (NULL,'f');
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	9	const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	4	const	1	100.00	Using index; FirstMatch(ot)
+Warnings:
+Note	1276	Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and <cache>(coalesce('1',1)))
+DROP TABLE it;
+CREATE TABLE it (
+col_int_key int(11),
+col_varchar_key varchar(1),
+col_varchar_key2 varchar(1),
+KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
+KEY idx_cvk_cik (col_varchar_key, col_int_key)
+);
+INSERT INTO it VALUES (NULL,'x','x'), (NULL,'f','f');
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cvk2_cik,idx_cvk_cik	idx_cvk_cvk2_cik	13	const,const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+DROP TABLE it, ot;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_all_bka_nixbnl.result'
--- a/mysql-test/r/subquery_all_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_all_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6734,5 +6734,96 @@ COUNT(*)
 6
 DROP TABLE t1, t2, t3;
 #
+# Bug#12838171: 51VS56: TRANSFORMED IN()+SUBQ QUERY 
+#               PRODUCES EMPTY RESULT ON 5.6, 1 ROW ON 5.1
+#
+CREATE TABLE ot (
+col_int_nokey int(11), 
+col_varchar_nokey varchar(1)
+) ;
+INSERT INTO ot VALUES (1,'x');
+CREATE TABLE it (
+col_int_key int(11), 
+col_varchar_key varchar(1), 
+KEY idx_cvk_cik (col_varchar_key,col_int_key)
+) ;
+INSERT INTO it VALUES (NULL,'x'), (NULL,'f');
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	9	const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey 
+FROM ot 
+WHERE col_varchar_nokey IN
+(SELECT col_varchar_key
+FROM it 
+WHERE coalesce(col_int_nokey, 1) );
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cik	idx_cvk_cik	4	const	1	100.00	Using index; FirstMatch(ot)
+Warnings:
+Note	1276	Field or reference 'test.ot.col_int_nokey' of SELECT #2 was resolved in SELECT #1
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key` = 'x') and <cache>(coalesce('1',1)))
+DROP TABLE it;
+CREATE TABLE it (
+col_int_key int(11),
+col_varchar_key varchar(1),
+col_varchar_key2 varchar(1),
+KEY idx_cvk_cvk2_cik (col_varchar_key, col_varchar_key2, col_int_key),
+KEY idx_cvk_cik (col_varchar_key, col_int_key)
+);
+INSERT INTO it VALUES (NULL,'x','x'), (NULL,'f','f');
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+col_int_nokey
+1
+
+EXPLAIN EXTENDED
+SELECT col_int_nokey
+FROM ot
+WHERE (col_varchar_nokey, 'x') IN
+(SELECT col_varchar_key, col_varchar_key2
+FROM it
+WHERE col_int_key IS NULL);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
+1	PRIMARY	ot	system	NULL	NULL	NULL	NULL	1	100.00	
+1	PRIMARY	it	ref	idx_cvk_cvk2_cik,idx_cvk_cik	idx_cvk_cvk2_cik	13	const,const,const	1	100.00	Using where; Using index; FirstMatch(ot)
+Warnings:
+Note	1003	/* select#1 */ select '1' AS `col_int_nokey` from (`test`.`it`) where ((`test`.`it`.`col_varchar_key2` = 'x') and (`test`.`it`.`col_varchar_key` = 'x') and isnull(`test`.`it`.`col_int_key`))
+
+DROP TABLE it, ot;
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all.result'
--- a/mysql-test/r/subquery_sj_all.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_all.result	2011-10-07 12:44:17 +0000
@@ -6794,5 +6794,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bka.result'
--- a/mysql-test/r/subquery_sj_all_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_all_bka.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_all_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_all_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_all_bkaunique.result'
--- a/mysql-test/r/subquery_sj_all_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_all_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed.result'
--- a/mysql-test/r/subquery_sj_dupsweed.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed.result	2011-10-07 12:44:17 +0000
@@ -6794,5 +6794,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bka.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bka.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_dupsweed_bkaunique.result'
--- a/mysql-test/r/subquery_sj_dupsweed_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_firstmatch.result'
--- a/mysql-test/r/subquery_sj_firstmatch.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bka.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bka.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_firstmatch_bkaunique.result'
--- a/mysql-test/r/subquery_sj_firstmatch_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6797,6 +6797,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 #
 # Bug#51457 Firstmatch semijoin strategy gives wrong results for

=== modified file 'mysql-test/r/subquery_sj_loosescan.result'
--- a/mysql-test/r/subquery_sj_loosescan.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_loosescan.result	2011-10-07 12:44:17 +0000
@@ -6795,5 +6795,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bka.result'
--- a/mysql-test/r/subquery_sj_loosescan_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bka.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_loosescan_bkaunique.result'
--- a/mysql-test/r/subquery_sj_loosescan_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6797,6 +6797,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat.result'
--- a/mysql-test/r/subquery_sj_mat.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_mat.result	2011-10-07 12:44:17 +0000
@@ -6794,5 +6794,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bka.result'
--- a/mysql-test/r/subquery_sj_mat_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_mat_bka.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_mat_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_mat_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6795,6 +6795,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_bkaunique.result'
--- a/mysql-test/r/subquery_sj_mat_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_mat_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6796,6 +6796,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_mat_nosj.result'
--- a/mysql-test/r/subquery_sj_mat_nosj.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_mat_nosj.result	2011-10-07 12:44:17 +0000
@@ -6871,5 +6871,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none.result'
--- a/mysql-test/r/subquery_sj_none.result	2011-10-01 19:26:04 +0000
+++ b/mysql-test/r/subquery_sj_none.result	2011-10-07 12:44:17 +0000
@@ -6806,5 +6806,113 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bka.result'
--- a/mysql-test/r/subquery_sj_none_bka.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_none_bka.result	2011-10-13 07:54:52 +0000
@@ -6807,6 +6807,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bka_nixbnl.result'
--- a/mysql-test/r/subquery_sj_none_bka_nixbnl.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_none_bka_nixbnl.result	2011-10-13 07:54:52 +0000
@@ -6807,6 +6807,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'mysql-test/r/subquery_sj_none_bkaunique.result'
--- a/mysql-test/r/subquery_sj_none_bkaunique.result	2011-10-05 13:16:38 +0000
+++ b/mysql-test/r/subquery_sj_none_bkaunique.result	2011-10-13 07:54:52 +0000
@@ -6808,6 +6808,114 @@ field1
 1
 DROP TABLE it, ot;
 # End of test for bug#12714094
+#
+# Bug#12867557: Valgrind: conditional jump/move at key_cmp
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+PRIMARY KEY (pk),
+KEY (col_int_key)
+) AUTO_INCREMENT=10;
+INSERT INTO t1 (col_int_key) VALUES (8);
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_key INTEGER,
+col_time_key TIME,
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_time_key)
+)  AUTO_INCREMENT=10;
+INSERT INTO t2 (col_int_key, col_time_key)
+VALUES
+(8, '22:55:23.019225'), (7, '10:19:31.050677'), (1, '14:40:36.038608'),
+(7, '04:37:47.062416'), (9, '19:34:06.054514'), (NULL,'20:35:33.022996'),
+(1, NULL), (9, '14:43:37.057393'), (2, '02:23:09.043438'),
+(9, '01:22:45.041064'), (2, '00:00:00'), (4, '00:13:25.038482'),
+(0, '03:47:16.042671'), (4, '01:41:48.007423'), (8, '00:00:00'),
+(NULL, '22:32:04.047407'), (NULL, '16:44:14.028443'), (0, '17:38:37.059754'),
+(NULL, '08:46:48.042388'), (8, '14:11:27.044095');
+CREATE TABLE t0
+SELECT DISTINCT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9;
+UPDATE t0
+SET g1 = g1
+WHERE g1 IN
+(SELECT grandparent1.col_time_key AS g1
+FROM t2 AS grandparent1
+WHERE grandparent1.col_int_key IN
+(SELECT parent1.col_int_key AS p1
+FROM t1 AS parent1)
+AND grandparent1.pk > 9);
+DROP TABLE t0, t1, t2;
+# End of test for bug#12867557
+#
+# Bug#12711441: crash in fix_after_pullout
+#
+CREATE TABLE t1 (
+pk int NOT NULL,
+col_int_nokey int DEFAULT NULL,
+col_int_key int DEFAULT NULL,
+col_time_key time DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (
+col_int_key int DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key, col_int_key)
+);
+CREATE TABLE t3 (
+pk int NOT NULL,
+col_int_key INT DEFAULT NULL,
+PRIMARY KEY (pk)
+);
+CREATE TABLE t4 (
+col_int_nokey INT DEFAULT NULL,
+col_varchar_key varchar(1) DEFAULT NULL,
+col_varchar_nokey varchar(1) DEFAULT NULL,
+KEY col_varchar_key(col_varchar_key)
+);
+CREATE TABLE ts
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+;
+SELECT * FROM ts WHERE field1 IN (
+SELECT alias1.col_time_key AS field1
+FROM v1 AS alias1
+RIGHT JOIN t3 AS alias2
+ON alias2.col_int_key = alias1.col_int_nokey
+WHERE alias1.pk >= SOME(
+SELECT SQ1_alias1.pk AS SQ1_field1
+FROM t3 AS SQ1_alias1
+INNER JOIN (t2 AS SQ1_alias2
+INNER JOIN t4 AS SQ1_alias3
+ON SQ1_alias3.col_varchar_key = SQ1_alias2.col_varchar_nokey)
+ON SQ1_alias3.col_int_nokey = SQ1_alias2.col_int_key
+WHERE SQ1_alias2.col_varchar_key <= alias1.col_varchar_key
+AND SQ1_alias3.col_varchar_nokey <> alias1.col_varchar_key)
+);
+field1
+DROP TABLE t1, t2, t3, t4, ts;
+DROP VIEW v1;
+# End of test for bug#12711441.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-09-07 12:41:53 +0000
+++ b/sql/item.cc	2011-10-07 12:44:17 +0000
@@ -600,18 +600,6 @@ Item_ident::Item_ident(Name_resolution_c
 }
 
 
-Item_ident::Item_ident(TABLE_LIST *view_arg, const char *field_name_arg)
-  :orig_db_name(NullS), orig_table_name(view_arg->table_name),
-   orig_field_name(field_name_arg), context(&view_arg->view->select_lex.context),
-   db_name(NullS), table_name(view_arg->alias),
-   field_name(field_name_arg),
-   alias_name_used(FALSE), cached_field_index(NO_CACHED_FIELD_INDEX),
-   cached_table(NULL), depended_from(NULL)
-{
-  name = (char*) field_name_arg;
-}
-
-
 /**
   Constructor used by Item_field & Item_*_ref (see Item comment)
 */
@@ -2379,6 +2367,9 @@ void Item_ident::fix_after_pullout(st_se
                                    st_select_lex *removed_select,
                                    Item **ref)
 {
+  DBUG_ASSERT(context->select_lex == NULL ||
+              context->select_lex != depended_from);
+
   if (context->select_lex == removed_select ||
       context->select_lex == parent_select)
   {
@@ -6294,20 +6285,6 @@ Item_ref::Item_ref(Name_resolution_conte
 }
 
 
-Item_ref::Item_ref(TABLE_LIST *view_arg, Item **item,
-                   const char *field_name_arg, bool alias_name_used_arg)
-  :Item_ident(view_arg, field_name_arg),
-   result_field(NULL), ref(item)
-{
-  alias_name_used= alias_name_used_arg;
-  /*
-    This constructor is used to create some internal references over fixed items
-  */
-  if (ref && *ref && (*ref)->fixed)
-    set_properties();
-}
-
-
 /**
   Resolve the name of a reference to a column reference.
 

=== modified file 'sql/item.h'
--- a/sql/item.h	2011-10-12 13:58:31 +0000
+++ b/sql/item.h	2011-10-13 07:54:52 +0000
@@ -1704,7 +1704,6 @@ public:
              const char *db_name_arg, const char *table_name_arg,
              const char *field_name_arg);
   Item_ident(THD *thd, Item_ident *item);
-  Item_ident(TABLE_LIST *view_arg, const char *field_name_arg);
   /*
     Return used table information for the level on which this table is resolved.
   */
@@ -2594,8 +2593,6 @@ public:
   Item_ref(Name_resolution_context *context_arg, Item **item,
            const char *table_name_arg, const char *field_name_arg,
            bool alias_name_used_arg= FALSE);
-  Item_ref(TABLE_LIST *view_arg, Item **item,
-           const char *field_name_arg, bool alias_name_used_arg= FALSE);
 
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_ref(THD *thd, Item_ref *item)
@@ -2737,12 +2734,6 @@ public:
   {}
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
-  Item_direct_ref(TABLE_LIST *view_arg, Item **item,
-                  const char *field_name_arg,
-                  bool alias_name_used_arg= FALSE)
-    :Item_ref(view_arg, item, field_name_arg,
-              alias_name_used_arg)
-  {}
 
   double val_real();
   longlong val_int();
@@ -2761,17 +2752,19 @@ public:
 class Item_direct_view_ref :public Item_direct_ref
 {
 public:
-  Item_direct_view_ref(Name_resolution_context *context_arg, Item **item,
-                  const char *table_name_arg,
-                  const char *field_name_arg)
-    :Item_direct_ref(context_arg, item, table_name_arg, field_name_arg) {}
+  Item_direct_view_ref(Name_resolution_context *context_arg,
+                       Item **item,
+                       const char *alias_name_arg,
+                       const char *table_name_arg,
+                       const char *field_name_arg)
+    : Item_direct_ref(context_arg, item, alias_name_arg, field_name_arg)
+  {
+    orig_table_name= table_name_arg;
+  }
+
   /* Constructor need to process subselect with temporary tables (see Item) */
   Item_direct_view_ref(THD *thd, Item_direct_ref *item)
     :Item_direct_ref(thd, item) {}
-  Item_direct_view_ref(TABLE_LIST *view_arg, Item **item,
-                       const char *field_name_arg)
-    :Item_direct_ref(view_arg, item, field_name_arg)
-  {}
 
   bool fix_fields(THD *, Item **);
   bool eq(const Item *item, bool binary_cmp) const;

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-10-05 14:27:14 +0000
+++ b/sql/sql_select.cc	2011-10-13 07:54:52 +0000
@@ -18992,7 +18992,8 @@ sub_select(JOIN *join,JOIN_TAB *join_tab
   }
 
   join->return_tab= join_tab;
-  join_tab->not_null_compl= TRUE;
+  join_tab->not_null_compl= true;
+  join_tab->found_match= false;
 
   if (join_tab->last_inner)
   {

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2011-10-07 06:03:14 +0000
+++ b/sql/table.cc	2011-10-13 07:54:52 +0000
@@ -73,6 +73,10 @@ static void fix_type_pointers(const char
 			      uint types, char **names);
 static uint find_field(Field **fields, uchar *record, uint start, uint length);
 
+static Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
+                               const char *name,
+                               Name_resolution_context *context);
+
 inline bool is_system_table_name(const char *name, uint length);
 
 static ulong get_form_pos(File file, uchar *head);
@@ -4431,8 +4435,9 @@ Item *Natural_join_column::create_item(T
   if (view_field)
   {
     DBUG_ASSERT(table_field == NULL);
+    SELECT_LEX *select= thd->lex->current_select;
     return create_view_field(thd, table_ref, &view_field->item,
-                             view_field->name);
+                             view_field->name, &select->context);
   }
   return table_field;
 }
@@ -4522,11 +4527,14 @@ const char *Field_iterator_view::name()
 
 Item *Field_iterator_view::create_item(THD *thd)
 {
-  return create_view_field(thd, view, &ptr->item, ptr->name);
+  SELECT_LEX *select= thd->lex->current_select;
+  return create_view_field(thd, view, &ptr->item, ptr->name,
+                           &select->context);
 }
 
-Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
-                        const char *name)
+static Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
+                               const char *name,
+                               Name_resolution_context *context)
 {
   bool save_wrapper= thd->lex->select_lex.no_wrap_view_item;
   Item *field= *field_ref;
@@ -4559,7 +4567,8 @@ Item *create_view_field(THD *thd, TABLE_
   {
     DBUG_RETURN(field);
   }
-  Item *item= new Item_direct_view_ref(view, field_ref, name);
+  Item *item= new Item_direct_view_ref(context, field_ref,
+                                       view->alias, view->table_name, name);
   DBUG_RETURN(item);
 }
 

=== modified file 'sql/table.h'
--- a/sql/table.h	2011-10-05 13:16:38 +0000
+++ b/sql/table.h	2011-10-13 07:54:52 +0000
@@ -1337,9 +1337,6 @@ enum enum_derived_type {
 class select_union;
 class TMP_TABLE_PARAM;
 
-Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
-                        const char *name);
-
 struct Field_translator
 {
   Item *item;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (tor.didriksen:3489 to 3490) Tor Didriksen13 Oct