List:Commits« Previous MessageNext Message »
From:Roy Lyseng Date:April 30 2012 6:56am
Subject:bzr push into mysql-trunk branch (roy.lyseng:3899 to 3900) Bug#13974177
View as plain text  
 3900 Roy Lyseng	2012-04-30
      Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
      
      The problem query in this bug report can be written as:
      
      SELECT ot1.* FROM ot1 LEFT JOIN ot2 ON ot1.c=ot2.c
      WHERE ot2.c IN
         (SELECT it2.c FROM it1 LEFT JOIN it2 ON it1.c=it2.c
         ) AND ot2.c IS NULL
      ;
      
      (The columns are all not nullable.)
      
      We see that there is a left outer join in both the inner and the outer
      query. What happens is that the optimizer after semi-join transformation
      detects a multiple equality between it2.c and ot2.c. When it sees
      "ot2.c IS NULL" it tries to apply outer join NOT EXISTS optimization, and
      due to the multiple equality, it is applied to both outer join operations.
      However, the NOT EXISTS optimization requires an accompanying table
      condition (with the IS NULL predicate), and only one of the outer joins
      will have that predicate. Hence, when executing the second outer join,
      there is a NOT EXISTS optimization flag, but no associated table
      condition, and the assertion hits.
      
      The root cause for this problem is lack of nullability propagation in
      semi-join transformation. Even though we can safely assume that conditions
      generated as part of semi-join transformation treat UNKNOWN results as
      FALSE (because we are transforming an =ANY operator and not an ALL
      operator), the generated conditions do not have the abort_on_null flag set.
      This means that not_null_tables() is zero (an empty table map) for 
      the resulting condition, and simplify_joins() is unable to convert the
      outer joins to inner joins (We see that NULL values for it2.c and ot2.c
      can safely be ignored).
      
      mysql-test/include/subquery_sj.inc
        Added test case for bug#13974177.
      
      mysql-test/r/derived.result
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
        Some changed explain results, because outer join is converted to inner.
      
      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
        Added test case results for bug#13974177.
        There are also some changed explain results, because sometimes
        outer join is converted to inner join.
      
      sql/sql_optimizer.cc
        In convert_subquery_to_semijoin(), apply the top_level_item() function
        to all generated conditions.

    modified:
      mysql-test/include/subquery_sj.inc
      mysql-test/r/derived.result
      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/sql_optimizer.cc
 3899 Roy Lyseng	2012-04-23
      Bug#13956813: Segfault in memcpy from Join_cache::write_record_data()
      
      This bug requires outer join processing, duplicate weedout semi-join
      strategy, derived tables and join buffering for multiple tables in
      order to hit.
      
      It is related to bug#13383857, which added materialization for derived
      tables when join buffering was used. But this was not enough: In some
      cases, we may call evaluate_null_complemented_join_record() without
      all inner tables of the outer join having been materialized. This may
      e.g happen if there are no qualifying rows in the first inner table
      of the outer join. Then, the first and all subsequent inner tables
      will be null-complemented. This by itself does not mandate
      materialization, but materialization is also a prerequisite for setting
      up the rowid buffer for duplicate weedout. A rowid copy operation has
      been set up for this table, but it crashes if the rowid buffer has not
      also been set up.
      
      The fix is to add initializer code (ie table materialization) for
      all tables that have not yet been initialized, even for null-extended
      inner tables of an outer join.
      
      mysql-test/include/subquery_sj.inc
        Added test case for bug#13956813.
      
      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
        Added test case results for bug#13956813.
      
      sql/sql_executor.cc
        In evaluate_null_complemented_join_record(), add materialization
        and rowid buffer setup for tables that have not already been
        materialized.
        Materialization is encapsulated into a static inline function.

    modified:
      mysql-test/include/subquery_sj.inc
      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/sql_executor.cc
=== modified file 'mysql-test/include/subquery_sj.inc'
--- a/mysql-test/include/subquery_sj.inc	2012-04-23 11:29:25 +0000
+++ b/mysql-test/include/subquery_sj.inc	2012-04-30 06:56:15 +0000
@@ -5951,4 +5951,70 @@ DROP VIEW view_inline_0, view_inline_1, 
 DROP TABLE t1, t2, t3;
 
 --echo # End of test for bug#13956813.
+
+--echo #
+--echo # Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+--echo #
+
+CREATE TABLE t1 (
+  pk INTEGER AUTO_INCREMENT,
+  col_int_nokey INTEGER,
+  col_int_key INTEGER,
+  col_varchar_key VARCHAR(1),
+  col_varchar_nokey VARCHAR(1),
+  PRIMARY KEY (pk),
+  KEY (col_int_key),
+  KEY (col_varchar_key, col_int_key)
+);
+
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+ (0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+ (9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+ (6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+ (4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+ (1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+
+CREATE TABLE t2 (
+  pk INTEGER AUTO_INCREMENT,
+  col_int_nokey INTEGER NOT NULL,
+  col_time_key TIME NOT NULL,
+  col_time_nokey TIME NOT NULL,
+  PRIMARY KEY (pk),
+  KEY (col_time_key)
+) ENGINE=InnoDB;
+
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+ (7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+ (9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+ (4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+ (5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+ (1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+ (6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+ (5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+ (204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+ (9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+ (0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+
+let $query=
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+      LEFT JOIN t1 AS ot1
+      ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+   (SELECT it1.pk AS x,
+           it1.col_int_nokey AS y
+    FROM t2 AS it2
+         LEFT JOIN t2 AS it1
+         ON it2.col_time_nokey = it1.col_time_key
+   ) AND ot1.pk IS NULL
+;
+
+eval explain $query;
+eval $query;
+
+DROP TABLE t1, t2;
+
+--echo # End of test for bug#13974177.
+
 --echo # End of 5.6 tests

=== modified file 'mysql-test/r/derived.result'
--- a/mysql-test/r/derived.result	2012-02-29 11:17:52 +0000
+++ b/mysql-test/r/derived.result	2012-04-30 06:56:15 +0000
@@ -1815,9 +1815,9 @@ WHERE outr.col_varchar_nokey = 'e'
 AND outr.col_varchar_key <> 'r'
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	<derived4>	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
-1	PRIMARY	<derived5>	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	PRIMARY	<derived4>	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	PRIMARY	<derived5>	ref	auto_key0	auto_key0	4	const	2	Using where
+1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
 5	DERIVED	t1	ALL	NULL	NULL	NULL	NULL	20	NULL
 4	DERIVED	t3	system	NULL	NULL	NULL	NULL	1	NULL
 2	DERIVED	t2	ALL	NULL	NULL	NULL	NULL	20	NULL

=== modified file 'mysql-test/r/subquery_all.result'
--- a/mysql-test/r/subquery_all.result	2012-04-11 12:12:00 +0000
+++ b/mysql-test/r/subquery_all.result	2012-04-30 06:56:15 +0000
@@ -6867,11 +6867,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM v1 AS alias1
 RIGHT JOIN t1 AS alias2 ON 1
@@ -6911,11 +6911,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT * FROM v2;
 col_varchar_nokey
 d
@@ -6942,11 +6942,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM t1 AS alias2
 LEFT JOIN v1 AS alias1 ON 1

=== modified file 'mysql-test/r/subquery_all_bka.result'
--- a/mysql-test/r/subquery_all_bka.result	2012-04-11 12:12:00 +0000
+++ b/mysql-test/r/subquery_all_bka.result	2012-04-30 06:56:15 +0000
@@ -6868,11 +6868,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM v1 AS alias1
 RIGHT JOIN t1 AS alias2 ON 1
@@ -6912,11 +6912,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT * FROM v2;
 col_varchar_nokey
 d
@@ -6943,11 +6943,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ALL	col_varchar_key	NULL	NULL	NULL	5	80.00	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	sq2_alias2	index	col_int_key	col_int_key	4	NULL	5	80.00	Using where; Using index; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM t1 AS alias2
 LEFT JOIN v1 AS alias1 ON 1

=== modified file 'mysql-test/r/subquery_all_bka_nixbnl.result'
--- a/mysql-test/r/subquery_all_bka_nixbnl.result	2012-04-11 12:12:00 +0000
+++ b/mysql-test/r/subquery_all_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -6868,11 +6868,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ref	col_varchar_key	col_varchar_key	3	test.t1.col_varchar_nokey	1	100.00	Using join buffer (Batched Key Access)
 1	SIMPLE	sq2_alias2	ref	col_int_key	col_int_key	4	func	2	100.00	Using where; Using index
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`test`.`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `test`.`t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `test`.`t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM v1 AS alias1
 RIGHT JOIN t1 AS alias2 ON 1
@@ -6912,11 +6912,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ref	col_varchar_key	col_varchar_key	3	test.t1.col_varchar_nokey	1	100.00	Using join buffer (Batched Key Access)
 1	SIMPLE	sq2_alias2	ref	col_int_key	col_int_key	4	func	2	100.00	Using where; Using index
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #3 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #3 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT * FROM v2;
 col_varchar_nokey
 d
@@ -6943,11 +6943,11 @@ id	select_type	table	type	possible_keys	
 1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Start temporary
 1	SIMPLE	alias2	ref	col_varchar_key	col_varchar_key	3	test.t1.col_varchar_nokey	1	100.00	Using join buffer (Batched Key Access)
 1	SIMPLE	sq2_alias2	ref	col_int_key	col_int_key	4	func	2	100.00	Using where; Using index
-1	SIMPLE	t1	index	NULL	col_varchar_key	7	NULL	5	100.00	Using where; Using index; End temporary
+1	SIMPLE	t1	ALL	col_varchar_key	NULL	NULL	NULL	5	100.00	Range checked for each record (index map: 0x4); End temporary
 Warnings:
 Note	1276	Field or reference 'alias1.col_int_key' of SELECT #2 was resolved in SELECT #1
 Note	1276	Field or reference 'alias1.col_varchar_key' of SELECT #2 was resolved in SELECT #1
-Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) left join (`test`.`t1`) on(1) where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
+Note	1003	/* select#1 */ select `test`.`alias2`.`col_varchar_nokey` AS `col_varchar_nokey` from `test`.`t1` `alias2` semi join (`test`.`t1` left join `test`.`t1` `sq2_alias2` on((`sq2_alias2`.`col_int_key` = `test`.`t1`.`pk`))) join `test`.`t1` where ((`test`.`alias2`.`col_varchar_key` = `test`.`t1`.`col_varchar_nokey`) and (`test`.`t1`.`pk` <> `t1`.`col_int_key`) and (`test`.`t1`.`col_varchar_key` > `t1`.`col_varchar_key`))
 SELECT alias2.col_varchar_nokey
 FROM t1 AS alias2
 LEFT JOIN v1 AS alias1 ON 1

=== modified file 'mysql-test/r/subquery_sj_all.result'
--- a/mysql-test/r/subquery_sj_all.result	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_all.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,17 +2207,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,8 +2603,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2612,9 +2612,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3531,7 +3531,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4083,8 +4083,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5451,7 +5451,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8854,10 +8854,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9464,11 +9464,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9488,5 +9488,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_all_bka.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,8 +2604,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2613,9 +2613,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3534,7 +3534,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4086,8 +4086,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5454,7 +5454,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary; Using join buffer (Batched Key Access)
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8859,10 +8859,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9469,11 +9469,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize; Using join buffer (Batched Key Access)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9493,6 +9493,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_all_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,8 +2604,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2613,9 +2613,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3534,7 +3534,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4086,8 +4086,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5454,7 +5454,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	NULL
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary; Using join buffer (Batched Key Access)
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8860,10 +8860,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9471,10 +9471,10 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize; Using join buffer (Batched Key Access)
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	Using where
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9494,6 +9494,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_all_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -1025,7 +1025,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1059,7 +1059,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1068,7 +1068,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1117,7 +1117,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1152,7 +1152,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1161,7 +1161,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1210,7 +1210,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1245,7 +1245,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1254,7 +1254,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1305,8 +1305,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1339,8 +1339,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1348,8 +1348,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1400,7 +1400,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1439,7 +1439,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1448,7 +1448,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1500,7 +1500,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1539,7 +1539,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1548,7 +1548,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1599,8 +1599,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1633,8 +1633,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1642,8 +1642,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1694,8 +1694,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1733,8 +1733,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1742,8 +1742,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1794,7 +1794,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1833,7 +1833,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1842,7 +1842,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1928,7 +1928,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1937,7 +1937,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2021,7 +2021,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2030,7 +2030,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2080,7 +2080,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2115,7 +2115,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2124,7 +2124,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2175,8 +2175,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2209,17 +2209,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2309,7 +2309,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2318,7 +2318,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2371,7 +2371,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2411,7 +2411,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2420,7 +2420,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2471,9 +2471,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2505,18 +2505,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2566,9 +2566,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2605,8 +2605,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2614,9 +2614,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2714,7 +2714,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2723,7 +2723,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3535,7 +3535,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4087,8 +4087,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5455,7 +5455,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary; Using join buffer (Batched Key Access (unique))
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8860,10 +8860,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9470,11 +9470,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize; Using join buffer (Batched Key Access (unique))
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9494,6 +9494,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed.result	2012-04-30 06:56:15 +0000
@@ -1022,7 +1022,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1056,7 +1056,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1065,7 +1065,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1114,7 +1114,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1149,7 +1149,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1158,7 +1158,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1207,7 +1207,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1242,7 +1242,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1251,7 +1251,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1302,8 +1302,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1336,8 +1336,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1345,8 +1345,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1397,7 +1397,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1436,7 +1436,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1445,7 +1445,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1497,7 +1497,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1536,7 +1536,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1545,7 +1545,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1596,8 +1596,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1630,8 +1630,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1639,8 +1639,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1691,8 +1691,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1730,8 +1730,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1739,8 +1739,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1791,7 +1791,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1830,7 +1830,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1839,7 +1839,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1925,7 +1925,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1934,7 +1934,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2018,7 +2018,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2027,7 +2027,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2077,7 +2077,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2112,7 +2112,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2121,7 +2121,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2172,8 +2172,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2206,8 +2206,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2215,8 +2215,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2306,7 +2306,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2315,7 +2315,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2368,7 +2368,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2408,7 +2408,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2417,7 +2417,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2468,9 +2468,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2502,18 +2502,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2563,9 +2563,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2602,18 +2602,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2667,7 +2667,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2711,7 +2711,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2720,7 +2720,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3521,9 +3521,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4073,8 +4073,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5441,7 +5441,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8838,10 +8838,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9449,9 +9449,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9472,5 +9472,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bka.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,8 +2207,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2216,8 +2216,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,18 +2603,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2668,7 +2668,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3522,9 +3522,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4074,8 +4074,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5442,7 +5442,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8839,10 +8839,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9450,9 +9450,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9473,6 +9473,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,17 +2207,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,18 +2603,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2668,7 +2668,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3529,9 +3529,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4081,8 +4081,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5449,7 +5449,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	NULL
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8847,10 +8847,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9457,11 +9457,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Start temporary
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	6	alias1.col_varchar_key,alias1.col_varchar_nokey	2	Using index; End temporary
+1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	3	test.alias2.col_varchar_key	1	Using index
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	test.alias2.col_varchar_key,view_inline_2.My_exp_p	2	End temporary
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9481,6 +9481,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Start temporary; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_dupsweed_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,8 +2208,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2217,8 +2217,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,18 +2604,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2669,7 +2669,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3523,9 +3523,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4075,8 +4075,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5443,7 +5443,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8840,10 +8840,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9451,9 +9451,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9474,6 +9474,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,17 +2207,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,18 +2603,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2668,7 +2668,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3520,9 +3520,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; FirstMatch(t0)
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; FirstMatch(t0)
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4072,8 +4072,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5440,7 +5440,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8837,10 +8837,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9450,7 +9450,7 @@ id	select_type	table	type	possible_keys	
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(<derived2>); Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9471,6 +9471,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bka.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,18 +2604,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2669,7 +2669,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3521,9 +3521,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; FirstMatch(t0)
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; FirstMatch(t0)
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4073,8 +4073,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5441,7 +5441,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8838,10 +8838,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9451,7 +9451,7 @@ id	select_type	table	type	possible_keys	
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(<derived2>); Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9472,6 +9472,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,18 +2604,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2669,7 +2669,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3530,9 +3530,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; FirstMatch(t0)
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; FirstMatch(t0)
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4082,8 +4082,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5450,7 +5450,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	NULL
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8846,10 +8846,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9456,11 +9456,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Start temporary
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	6	alias1.col_varchar_key,alias1.col_varchar_nokey	2	Using index; FirstMatch(<derived2>)
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
+1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	3	test.alias2.col_varchar_key	1	Using index
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	test.alias2.col_varchar_key,view_inline_2.My_exp_p	2	End temporary
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9480,6 +9480,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_firstmatch_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -1025,7 +1025,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1059,7 +1059,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1068,7 +1068,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1117,7 +1117,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1152,7 +1152,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1161,7 +1161,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1210,7 +1210,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1245,7 +1245,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1254,7 +1254,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1305,8 +1305,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1339,8 +1339,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1348,8 +1348,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1400,7 +1400,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1439,7 +1439,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1448,7 +1448,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1500,7 +1500,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1539,7 +1539,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1548,7 +1548,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1599,8 +1599,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1633,8 +1633,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1642,8 +1642,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1694,8 +1694,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1733,8 +1733,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1742,8 +1742,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1794,7 +1794,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1833,7 +1833,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1842,7 +1842,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1928,7 +1928,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1937,7 +1937,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2021,7 +2021,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2030,7 +2030,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2080,7 +2080,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2115,7 +2115,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	FirstMatch
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2124,7 +2124,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2175,8 +2175,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2209,17 +2209,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2309,7 +2309,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2318,7 +2318,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2371,7 +2371,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2411,7 +2411,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2420,7 +2420,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2471,9 +2471,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2505,18 +2505,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(t1)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2566,9 +2566,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2605,18 +2605,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2670,7 +2670,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2714,7 +2714,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2723,7 +2723,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3522,9 +3522,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; FirstMatch(t0)
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; FirstMatch(t0)
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4074,8 +4074,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5442,7 +5442,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8839,10 +8839,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; FirstMatch(table3)
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; FirstMatch(table3)
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9452,7 +9452,7 @@ id	select_type	table	type	possible_keys	
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where; FirstMatch(alias2)
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; FirstMatch(<derived2>); Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9473,6 +9473,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; FirstMatch(it1); Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_loosescan.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,8 +2207,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2216,8 +2216,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,18 +2603,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2668,7 +2668,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3522,9 +3522,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4074,8 +4074,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5442,7 +5442,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8839,10 +8839,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9450,9 +9450,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9473,5 +9473,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bka.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,8 +2208,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2217,8 +2217,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,18 +2604,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2669,7 +2669,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3523,9 +3523,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4075,8 +4075,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5443,7 +5443,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8840,10 +8840,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9451,9 +9451,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9474,6 +9474,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,18 +2604,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2669,7 +2669,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3530,9 +3530,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4082,8 +4082,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5450,7 +5450,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	NULL
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8848,10 +8848,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9458,11 +9458,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Start temporary
 1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	6	alias1.col_varchar_key,alias1.col_varchar_nokey	2	Using index; End temporary
+1	PRIMARY	<derived7>	ref	auto_key0	auto_key0	3	test.alias2.col_varchar_key	1	Using index
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	test.alias2.col_varchar_key,view_inline_2.My_exp_p	2	End temporary
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9482,6 +9482,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Start temporary; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_loosescan_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -1025,7 +1025,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1059,7 +1059,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1068,7 +1068,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1117,7 +1117,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1152,7 +1152,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1161,7 +1161,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1210,7 +1210,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1245,7 +1245,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1254,7 +1254,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1305,8 +1305,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1339,8 +1339,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1348,8 +1348,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1400,7 +1400,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1439,7 +1439,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1448,7 +1448,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1500,7 +1500,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1539,7 +1539,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1548,7 +1548,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1599,8 +1599,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1633,8 +1633,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1642,8 +1642,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1694,8 +1694,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1733,8 +1733,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1742,8 +1742,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1794,7 +1794,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1833,7 +1833,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1842,7 +1842,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1928,7 +1928,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1937,7 +1937,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2021,7 +2021,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2030,7 +2030,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2080,7 +2080,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2115,7 +2115,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2124,7 +2124,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2175,8 +2175,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2209,8 +2209,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2218,8 +2218,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2309,7 +2309,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2318,7 +2318,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2371,7 +2371,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2411,7 +2411,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2420,7 +2420,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2471,9 +2471,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2505,18 +2505,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2566,9 +2566,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2605,18 +2605,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2670,7 +2670,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2714,7 +2714,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2723,7 +2723,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3524,9 +3524,9 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	Start temporary
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using where; Using index; Using join buffer (Block Nested Loop)
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
-1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using where; Using index; End temporary
+1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End temporary
 drop table t0, t1,t2,t3;
 
 Test that neither MaterializeLookup strategy for semijoin,
@@ -4076,8 +4076,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Start temporary
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
-1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5444,7 +5444,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8841,10 +8841,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9452,9 +9452,9 @@ WHERE (alias1.col_varchar_key, alias1.co
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where; Using join buffer (Block Nested Loop)
 1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	4	test.alias2.col_varchar_key	2	NULL
 1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
@@ -9475,6 +9475,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_mat.result	2012-04-30 06:56:15 +0000
@@ -1023,7 +1023,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1057,7 +1057,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1066,7 +1066,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1115,7 +1115,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1150,7 +1150,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1159,7 +1159,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1208,7 +1208,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1243,7 +1243,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1252,7 +1252,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1303,8 +1303,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1337,8 +1337,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1346,8 +1346,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1398,7 +1398,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1437,7 +1437,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1446,7 +1446,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1498,7 +1498,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1537,7 +1537,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1546,7 +1546,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1597,8 +1597,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1631,8 +1631,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1640,8 +1640,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1692,8 +1692,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1731,8 +1731,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1740,8 +1740,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1792,7 +1792,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1831,7 +1831,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1840,7 +1840,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1926,7 +1926,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1935,7 +1935,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2019,7 +2019,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2028,7 +2028,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2078,7 +2078,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2113,7 +2113,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2122,7 +2122,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2173,8 +2173,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2207,8 +2207,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2216,8 +2216,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2307,7 +2307,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2316,7 +2316,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2369,7 +2369,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2409,7 +2409,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2418,7 +2418,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2469,9 +2469,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2503,18 +2503,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2564,9 +2564,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2603,8 +2603,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2612,9 +2612,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2712,7 +2712,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2721,7 +2721,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3531,7 +3531,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4083,8 +4083,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5451,7 +5451,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8852,10 +8852,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9462,11 +9462,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9486,5 +9486,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_mat_bka.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,8 +2208,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2217,8 +2217,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,8 +2604,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2613,9 +2613,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3532,7 +3532,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4084,8 +4084,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5452,7 +5452,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8853,10 +8853,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9463,11 +9463,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9487,6 +9487,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_mat_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -1024,7 +1024,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1058,7 +1058,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1067,7 +1067,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1116,7 +1116,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1151,7 +1151,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1160,7 +1160,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1209,7 +1209,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1244,7 +1244,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1253,7 +1253,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1304,8 +1304,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1338,8 +1338,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1347,8 +1347,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1399,7 +1399,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1438,7 +1438,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1447,7 +1447,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1499,7 +1499,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1538,7 +1538,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1547,7 +1547,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1598,8 +1598,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1632,8 +1632,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1641,8 +1641,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1693,8 +1693,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1732,8 +1732,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1741,8 +1741,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1793,7 +1793,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1832,7 +1832,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1841,7 +1841,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1927,7 +1927,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -1936,7 +1936,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2020,7 +2020,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2029,7 +2029,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2079,7 +2079,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2114,7 +2114,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2123,7 +2123,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2174,8 +2174,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2208,17 +2208,17 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2308,7 +2308,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2317,7 +2317,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2370,7 +2370,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2410,7 +2410,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
@@ -2419,7 +2419,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
@@ -2470,9 +2470,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2504,18 +2504,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2565,9 +2565,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2604,8 +2604,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2613,9 +2613,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2713,7 +2713,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2722,7 +2722,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3532,7 +3532,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4084,8 +4084,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5452,7 +5452,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	NULL
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8854,10 +8854,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t1.col_varchar_key	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9464,11 +9464,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	NULL
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	Using where
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9488,6 +9488,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Start temporary; End temporary
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_mat_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -1025,7 +1025,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1059,7 +1059,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1068,7 +1068,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1117,7 +1117,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1152,7 +1152,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1161,7 +1161,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1210,7 +1210,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1245,7 +1245,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1254,7 +1254,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1305,8 +1305,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1339,8 +1339,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1348,8 +1348,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1400,7 +1400,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1439,7 +1439,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1448,7 +1448,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1500,7 +1500,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1539,7 +1539,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1548,7 +1548,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1599,8 +1599,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1633,8 +1633,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1642,8 +1642,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1694,8 +1694,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1733,8 +1733,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -1742,8 +1742,8 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -1794,7 +1794,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1833,7 +1833,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -1842,7 +1842,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -1928,7 +1928,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -1937,7 +1937,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2021,7 +2021,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2030,7 +2030,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2080,7 +2080,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2115,7 +2115,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2124,7 +2124,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2175,8 +2175,8 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start materialize; Scan
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2209,8 +2209,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2218,8 +2218,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -2309,7 +2309,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2318,7 +2318,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2371,7 +2371,7 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2411,7 +2411,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2420,7 +2420,7 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
@@ -2471,9 +2471,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2505,18 +2505,18 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	0	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2566,9 +2566,9 @@ DEALLOCATE PREPARE stmt;
 EXPLAIN SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize; Scan
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Start temporary
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (t1.i) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 i
@@ -2605,8 +2605,8 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End materialize; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2614,9 +2614,9 @@ i
 EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
-1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	1	Using where; Start temporary
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 i
@@ -2714,7 +2714,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	NULL
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Start materialize
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Start materialize
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End materialize; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i);
@@ -2723,7 +2723,7 @@ EXPLAIN SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	Using where; Start temporary
-1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using join buffer (Block Nested Loop)
+1	SIMPLE	t2	ALL	NULL	NULL	NULL	NULL	2	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	t3	ALL	NULL	NULL	NULL	NULL	2	Using where; End temporary; Using join buffer (Block Nested Loop)
 SELECT * FROM t1 WHERE (11) IN 
 (SELECT t3.i FROM t2 LEFT JOIN t3 ON t2.i=t3.i WHERE t1.i);
@@ -3533,7 +3533,7 @@ from t0 where a in
 (select t2.a+t3.a from t1 left join (t2 join t3) on t2.a=t1.a and t3.a=t1.a);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	t0	ALL	NULL	NULL	NULL	NULL	10	NULL
-1	SIMPLE	t1	index	NULL	a	5	NULL	10	Using index; Start materialize
+1	SIMPLE	t1	index	a	a	5	NULL	10	Using index; Start materialize
 1	SIMPLE	t2	ref	a	a	5	test.t1.a	1	Using index
 1	SIMPLE	t3	ref	a	a	5	test.t1.a	1	Using index; End materialize
 drop table t0, t1,t2,t3;
@@ -4085,8 +4085,8 @@ FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it3	ALL	NULL	NULL	NULL	NULL	3	Materialize; Scan
-1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	4	Using where; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	8	Using where; Using join buffer (Block Nested Loop)
 SELECT *
 FROM ot1 LEFT JOIN ot2 ON ot1.a=ot2.a
 WHERE (ot1.a,ot2.a) IN (SELECT a, a FROM it3);
@@ -5453,7 +5453,7 @@ FROM it1 LEFT JOIN it2 ON it2.datetime_k
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	it1	index	NULL	int_key	4	NULL	2	Using index; Start temporary
 1	SIMPLE	ot1	ALL	NULL	NULL	NULL	NULL	20	Using join buffer (Block Nested Loop)
-1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	it2	ref	int_key	int_key	4	test.ot1.int_nokey	2	Using where; End temporary
 DROP TABLE ot1, it1, it2;
 # End of BUG#38075
 # 
@@ -8854,10 +8854,10 @@ WHERE subquery3_t2.col_int_nokey <> 9
 ;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
 1	SIMPLE	table1	ALL	NULL	NULL	NULL	NULL	1	Start temporary
-1	SIMPLE	table2	ALL	NULL	NULL	NULL	NULL	1	Using where
-1	SIMPLE	table3	ref	col_int_key	col_int_key	5	test.table2.col_int_key	1	Using where; Using index
-1	SIMPLE	subquery3_t1	ALL	NULL	NULL	NULL	NULL	4	Using where
-1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where; End temporary
+1	SIMPLE	table2	ALL	col_int_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	table3	eq_ref	PRIMARY,col_int_key	PRIMARY	4	test.table2.col_int_nokey	1	Using where
+1	SIMPLE	subquery3_t2	ALL	col_varchar_key	NULL	NULL	NULL	1	Using where
+1	SIMPLE	subquery3_t1	ref	col_varchar_key	col_varchar_key	4	test.subquery3_t2.col_varchar_key	1	Using where; End temporary
 SELECT table1.pk,table2.pk, table3.pk
 FROM t2 AS table1
 LEFT JOIN t1 AS table2
@@ -9464,11 +9464,11 @@ WHERE (alias1.col_varchar_key, alias1.co
 (SELECT * FROM view_inline_2
 );
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
-1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Start temporary
-1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Using where
-1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	Using where
-1	PRIMARY	<derived2>	ALL	NULL	NULL	NULL	NULL	15	Using where; End temporary
-1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize
+1	PRIMARY	<derived7>	ALL	NULL	NULL	NULL	NULL	2	Materialize; Scan
+1	PRIMARY	<derived2>	ref	auto_key0	auto_key0	8	view_inline_2.p,view_inline_2.My_exp_p	2	NULL
+1	PRIMARY	alias2	ALL	NULL	NULL	NULL	NULL	11	Using where; Using join buffer (Block Nested Loop)
+1	PRIMARY	sq2_alias1	ALL	NULL	NULL	NULL	NULL	15	Start materialize
+1	PRIMARY	sq2_alias2	ref	col_int_key	col_int_key	5	test.sq2_alias1.pk	2	End materialize
 7	DERIVED	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 8	UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union7,8>	ALL	NULL	NULL	NULL	NULL	NULL	Using temporary
@@ -9488,6 +9488,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where; Start temporary
+1	SIMPLE	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	test.ot1.col_int_nokey	1	Using where
+1	SIMPLE	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; End temporary; Using join buffer (Block Nested Loop)
+1	SIMPLE	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_mat_nosj.result	2012-04-30 06:56:15 +0000
@@ -9558,5 +9558,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	PRIMARY	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+2	SUBQUERY	it2	ALL	NULL	NULL	NULL	NULL	20	NULL
+2	SUBQUERY	it1	ref	col_time_key	col_time_key	3	test.it2.col_time_nokey	1	NULL
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_none.result	2012-04-30 06:56:15 +0000
@@ -9473,5 +9473,76 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	PRIMARY	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	func	1	Using where
+2	DEPENDENT SUBQUERY	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_none_bka.result	2012-04-30 06:56:15 +0000
@@ -9474,6 +9474,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	PRIMARY	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	func	1	Using where
+2	DEPENDENT SUBQUERY	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_none_bka_nixbnl.result	2012-04-30 06:56:15 +0000
@@ -9474,6 +9474,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	PRIMARY	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where
+2	DEPENDENT SUBQUERY	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	func	1	Using where
+2	DEPENDENT SUBQUERY	it2	ALL	NULL	NULL	NULL	NULL	20	Using where
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # 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	2012-04-23 11:29:25 +0000
+++ b/mysql-test/r/subquery_sj_none_bkaunique.result	2012-04-30 06:56:15 +0000
@@ -9475,6 +9475,77 @@ NULL
 DROP VIEW view_inline_0, view_inline_1, view_inline_2;
 DROP TABLE t1, t2, t3;
 # End of test for bug#13956813.
+#
+# Bug#13974177: Assert !(tab->table->regginfo.not_exists_optimize...
+#
+CREATE TABLE t1 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER,
+col_int_key INTEGER,
+col_varchar_key VARCHAR(1),
+col_varchar_nokey VARCHAR(1),
+PRIMARY KEY (pk),
+KEY (col_int_key),
+KEY (col_varchar_key, col_int_key)
+);
+INSERT INTO t1(col_int_key, col_int_nokey, col_varchar_key, col_varchar_nokey)
+VALUES
+(0, 4, 'j', 'j'), (8, 6, 'v', 'v'), (1, 3, 'c', 'c'), (8, 5, 'm', 'm'),
+(9, 3, 'd', 'd'), (24, 246, 'd', 'd'), (6, 2, 'y', 'y'), (1, 9, 't', 't'),
+(6, 3, 'd', 'd'), (2, 8, 's', 's'), (4, 1, 'r', 'r'), (8, 8, 'm', 'm'),
+(4, 8, 'b', 'b'), (4, 5, 'x', 'x'), (7, 7, 'g', 'g'), (4, 5, 'p', 'p'),
+(1, 1, 'q', 'q'), (9, 6, 'w', 'w'), (4, 2, 'd', 'd'), (8, 9, 'e', 'e');
+CREATE TABLE t2 (
+pk INTEGER AUTO_INCREMENT,
+col_int_nokey INTEGER NOT NULL,
+col_time_key TIME NOT NULL,
+col_time_nokey TIME NOT NULL,
+PRIMARY KEY (pk),
+KEY (col_time_key)
+) ENGINE=InnoDB;
+INSERT INTO t2 (col_int_nokey, col_time_key, col_time_nokey) VALUES
+(7, '00:00:00', '00:00:00'), (0, '00:00:00', '00:00:00'),
+(9, '06:35:17', '06:35:17'), (3, '18:07:14', '18:07:14'),
+(4, '20:36:52', '20:36:52'), (2, '21:29:07', '21:29:07'),
+(5, '23:45:57', '23:45:57'), (3, '22:54:57', '22:54:57'),
+(1, '18:45:09', '18:45:09'), (3, '14:30:46', '14:30:46'),
+(6, '19:23:43', '19:23:43'), (7, '03:39:30', '03:39:30'),
+(5, '23:37:52', '23:37:52'), (1, '16:59:30', '16:59:30'),
+(204, '22:21:15', '22:21:15'), (224, '12:24:37', '12:24:37'),
+(9, '15:02:08', '15:02:08'), (5, '23:59:59', '23:59:59'),
+(0, '08:23:30', '08:23:30'), (3, '08:32:22', '08:32:22');
+explain SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	ot1	const	PRIMARY,col_varchar_key	PRIMARY	4	const	1	Using where
+1	PRIMARY	ot2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+2	DEPENDENT SUBQUERY	it1	eq_ref	PRIMARY,col_time_key	PRIMARY	4	func	1	Using where
+2	DEPENDENT SUBQUERY	it2	ALL	NULL	NULL	NULL	NULL	20	Using where; Using join buffer (Block Nested Loop)
+SELECT ot1.col_int_key AS x
+FROM t1 AS ot2
+LEFT JOIN t1 AS ot1
+ON ot2.col_varchar_nokey > ot1.col_varchar_key
+WHERE (ot1.col_int_nokey, ot1.pk) IN
+(SELECT it1.pk AS x,
+it1.col_int_nokey AS y
+FROM t2 AS it2
+LEFT JOIN t2 AS it1
+ON it2.col_time_nokey = it1.col_time_key
+) AND ot1.pk IS NULL
+;
+x
+DROP TABLE t1, t2;
+# End of test for bug#13974177.
 # End of 5.6 tests
 set optimizer_switch=default;
 set optimizer_switch=default;

=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc	2012-04-19 12:34:50 +0000
+++ b/sql/sql_optimizer.cc	2012-04-30 06:56:15 +0000
@@ -1465,9 +1465,10 @@ static bool check_equality(THD *thd, Ite
                                 (Item_row *) right_item,
                                 cond_equal, eq_list);
     }
-    else 
+    else
       return check_simple_equality(left_item, right_item, item, cond_equal);
-  } 
+  }
+
   return FALSE;
 }
 
@@ -6503,6 +6504,7 @@ static bool convert_subquery_to_semijoin
 
     Opt_trace_array sj_on_trace(&thd->opt_trace,
                                 "evaluating_constant_semijoin_conditions");
+    sj_nest->sj_on_expr->top_level_item();
     if (sj_nest->sj_on_expr->fix_fields(thd, &sj_nest->sj_on_expr))
       DBUG_RETURN(true);
   }
@@ -6535,6 +6537,7 @@ static bool convert_subquery_to_semijoin
                                           sj_nest->sj_on_expr));
     if (emb_tbl_nest->join_cond() == NULL)
       DBUG_RETURN(true);
+    emb_tbl_nest->join_cond()->top_level_item();
     if (!emb_tbl_nest->join_cond()->fixed &&
         emb_tbl_nest->join_cond()->fix_fields(parent_join->thd,
                                               emb_tbl_nest->join_cond_ref()))
@@ -6546,6 +6549,7 @@ static bool convert_subquery_to_semijoin
     parent_join->conds= and_items(parent_join->conds, sj_nest->sj_on_expr);
     if (parent_join->conds == NULL)
       DBUG_RETURN(true);
+    parent_join->conds->top_level_item();
     if (parent_join->conds->fix_fields(parent_join->thd, &parent_join->conds))
       DBUG_RETURN(true);
     parent_join->select_lex->where= parent_join->conds;

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (roy.lyseng:3899 to 3900) Bug#13974177Roy Lyseng30 Apr