summaryrefslogtreecommitdiff
path: root/mysql-test/main
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-07-28 13:43:26 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2019-07-28 13:43:26 +0200
commit2792c6e7b057b18c19b506f37c35716529f80979 (patch)
treecead6068286ee469dbfe33a28d4585742eb26cbb /mysql-test/main
parentc0743e4b0056eba0b19a19458c85e52a83cef676 (diff)
parent4b5a14d0fe3d6945a0a9516261f563dcfd1f2c9c (diff)
downloadmariadb-git-2792c6e7b057b18c19b506f37c35716529f80979.tar.gz
Merge branch '10.3' into 10.4
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/connect_debug.result5
-rw-r--r--mysql-test/main/connect_debug.test11
-rw-r--r--mysql-test/main/derived.result11
-rw-r--r--mysql-test/main/derived.test4
-rw-r--r--mysql-test/main/derived_view.result59
-rw-r--r--mysql-test/main/derived_view.test34
-rw-r--r--mysql-test/main/func_group.result2
-rw-r--r--mysql-test/main/group_min_max.result2
-rw-r--r--mysql-test/main/information_schema_parameters.result4
-rw-r--r--mysql-test/main/information_schema_parameters.test2
-rw-r--r--mysql-test/main/join.result1384
-rw-r--r--mysql-test/main/join.test404
-rw-r--r--mysql-test/main/join_outer_innodb.result2
-rw-r--r--mysql-test/main/join_outer_innodb.test2
-rw-r--r--mysql-test/main/plugin.result10
-rw-r--r--mysql-test/main/plugin.test11
-rw-r--r--mysql-test/main/plugin_not_embedded.result4
-rw-r--r--mysql-test/main/plugin_not_embedded.test9
-rw-r--r--mysql-test/main/ps.result63
-rw-r--r--mysql-test/main/ps.test77
-rw-r--r--mysql-test/main/ps_innodb.result64
-rw-r--r--mysql-test/main/ps_innodb.test80
-rw-r--r--mysql-test/main/selectivity.result6
-rw-r--r--mysql-test/main/selectivity_innodb.result6
-rw-r--r--mysql-test/main/subselect.result35
-rw-r--r--mysql-test/main/subselect.test24
-rw-r--r--mysql-test/main/subselect4.result5
-rw-r--r--mysql-test/main/subselect_cache.result2
-rw-r--r--mysql-test/main/subselect_exists2in.result8
-rw-r--r--mysql-test/main/subselect_innodb.result2
-rw-r--r--mysql-test/main/subselect_mat.result2
-rw-r--r--mysql-test/main/subselect_no_exists_to_in.result41
-rw-r--r--mysql-test/main/subselect_no_mat.result35
-rw-r--r--mysql-test/main/subselect_no_opts.result35
-rw-r--r--mysql-test/main/subselect_no_scache.result35
-rw-r--r--mysql-test/main/subselect_no_semijoin.result35
-rw-r--r--mysql-test/main/subselect_sj_mat.result2
-rw-r--r--mysql-test/main/view.result15
-rw-r--r--mysql-test/main/view.test20
-rw-r--r--mysql-test/main/view_alias.result10
40 files changed, 2519 insertions, 43 deletions
diff --git a/mysql-test/main/connect_debug.result b/mysql-test/main/connect_debug.result
index 0452b238db9..6c066c16731 100644
--- a/mysql-test/main/connect_debug.result
+++ b/mysql-test/main/connect_debug.result
@@ -3,3 +3,8 @@ set global debug_dbug='+d,auth_disconnect';
create user 'bad' identified by 'worse';
set global debug_dbug=@old_dbug;
drop user bad;
+set global debug_dbug='+d,auth_invalid_plugin';
+create user 'bad' identified by 'worse';
+ERROR 1045 (28000): Plugin foo/bar could not be loaded: invalid plugin name
+set global debug_dbug=@old_dbug;
+drop user bad;
diff --git a/mysql-test/main/connect_debug.test b/mysql-test/main/connect_debug.test
index 299b605b2cd..7a2f2872b79 100644
--- a/mysql-test/main/connect_debug.test
+++ b/mysql-test/main/connect_debug.test
@@ -1,3 +1,4 @@
+source include/not_embedded.inc;
source include/have_debug.inc;
set @old_dbug=@@global.debug_dbug;
@@ -10,3 +11,13 @@ create user 'bad' identified by 'worse';
--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse
set global debug_dbug=@old_dbug;
drop user bad;
+
+#
+# malicious server, invalid plugin name
+#
+set global debug_dbug='+d,auth_invalid_plugin';
+create user 'bad' identified by 'worse';
+--error 1
+--exec $MYSQL --default-auth=mysql_old_password --user=bad --password=worse 2>&1
+set global debug_dbug=@old_dbug;
+drop user bad;
diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result
index 792a859d849..a875f8ddf9f 100644
--- a/mysql-test/main/derived.result
+++ b/mysql-test/main/derived.result
@@ -606,6 +606,17 @@ select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where coalesce(message,0) <> 0;
id message
+explain extended
+select x.id, message from (select id from t1) x left join
+(select id, 1 as message from t2) y on x.id=y.id
+where message <> 0;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00
+1 PRIMARY <derived3> ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00
+2 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00
+Warnings:
+Note 1003 /* select#1 */ select `x`.`id` AS `id`,`y`.`message` AS `message` from (/* select#2 */ select `test`.`t1`.`id` AS `id` from `test`.`t1`) `x` join (/* select#3 */ select `test`.`t2`.`id` AS `id`,1 AS `message` from `test`.`t2`) `y` where `y`.`id` = `x`.`id` and `y`.`message` <> 0
drop table t1,t2;
#
# MDEV-7827: Assertion `!table || (!table->read_set ||
diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test
index 8f3f265178c..beb361fd5b7 100644
--- a/mysql-test/main/derived.test
+++ b/mysql-test/main/derived.test
@@ -533,6 +533,10 @@ insert into t2 values(4),(5),(6);
select x.id, message from (select id from t1) x left join
(select id, 1 as message from t2) y on x.id=y.id
where coalesce(message,0) <> 0;
+explain extended
+select x.id, message from (select id from t1) x left join
+(select id, 1 as message from t2) y on x.id=y.id
+where message <> 0;
drop table t1,t2;
--echo #
diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result
index 67b9cb025b1..c4ba604d5c4 100644
--- a/mysql-test/main/derived_view.result
+++ b/mysql-test/main/derived_view.result
@@ -1624,7 +1624,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 't.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(1,<expr_cache><`test`.`t1`.`a`>(exists(/* select#3 */ select 28 from `test`.`t3` where 'j' < `test`.`t1`.`a`)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <in_optimizer>(1,<expr_cache><`test`.`t1`.`a`>(exists(/* select#3 */ select 28 from `test`.`t3` where 'j' < `test`.`t1`.`a` limit 1)))
SELECT * FROM (SELECT * FROM t1) AS t
WHERE EXISTS (SELECT t2.a FROM t3 RIGHT JOIN t2 ON (t3.a = t2.a)
WHERE t2.b < t.a);
@@ -3422,3 +3422,60 @@ id select_type table type possible_keys key key_len ref rows Extra
7 DERIVED p9 ALL NULL NULL NULL NULL 550 Using where; Using join buffer (incremental, BNL join)
7 DERIVED p10 ALL NULL NULL NULL NULL 550 Using where; Using join buffer (incremental, BNL join)
DROP TABLE t1, t2;
+#
+# MDEV-19778: equality condition for mergeable view returning constants
+# in its columns and used as inner table of outer join
+#
+create table t1 (pk int, a int);
+insert into t1 values (1,7), (2,3), (3,2), (4,3);
+create table t2 (b int);
+insert into t2 values (5), (1), (NULL), (3);
+create table t3 (c int);
+insert into t3 values (1), (8);
+create view v1 as
+select 3 as d, t2.b from t2;
+select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
+pk a d b
+2 3 3 5
+2 3 3 1
+2 3 3 NULL
+2 3 3 3
+explain extended select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2
+select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
+where t1.a=dt.d;
+pk a d b
+2 3 3 5
+2 3 3 1
+2 3 3 NULL
+2 3 3 3
+explain extended select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
+where t1.a=dt.d;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2
+select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
+pk a d b c
+2 3 3 5 1
+2 3 3 5 8
+2 3 3 1 1
+2 3 3 1 8
+2 3 3 NULL 1
+2 3 3 NULL 8
+2 3 3 3 1
+2 3 3 3 8
+explain extended select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`a` AS `a`,3 AS `d`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t1`.`a` = 3 and `test`.`t1`.`pk` <= 2
+drop view v1;
+drop table t1,t2,t3;
diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test
index d303391204f..8adbcc8dfd4 100644
--- a/mysql-test/main/derived_view.test
+++ b/mysql-test/main/derived_view.test
@@ -2236,3 +2236,37 @@ JOIN
) gp_20 ON gp_20.id=t2.id ;
DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-19778: equality condition for mergeable view returning constants
+--echo # in its columns and used as inner table of outer join
+--echo #
+
+create table t1 (pk int, a int);
+insert into t1 values (1,7), (2,3), (3,2), (4,3);
+create table t2 (b int);
+insert into t2 values (5), (1), (NULL), (3);
+create table t3 (c int);
+insert into t3 values (1), (8);
+
+create view v1 as
+select 3 as d, t2.b from t2;
+
+let $q=
+select * from t1 left join v1 on t1.pk <= 2 where t1.a=v1.d;
+eval $q;
+eval explain extended $q;
+
+let $q=
+select * from t1 left join (select 3 as d, t2.b from t2) dt on t1.pk <= 2
+ where t1.a=dt.d;
+eval $q;
+eval explain extended $q;
+
+let $q=
+select * from t1 left join (v1,t3) on t1.pk <= 2 where t1.a=v1.d;
+eval $q;
+eval explain extended $q;
+
+drop view v1;
+drop table t1,t2,t3;
diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result
index c6daf2335a9..938acbae0e2 100644
--- a/mysql-test/main/func_group.result
+++ b/mysql-test/main/func_group.result
@@ -1982,6 +1982,7 @@ NULL
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
+Warning 1292 Truncated incorrect DOUBLE value: 'j'
EXPLAIN
SELECT MIN(t2.pk)
@@ -1996,6 +1997,7 @@ id select_type table type possible_keys key key_len ref rows Extra
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'j'
Warning 1292 Truncated incorrect DOUBLE value: 'j'
+Warning 1292 Truncated incorrect DOUBLE value: 'j'
#
# 2) Test that subquery materialization is setup for query with
diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result
index 59e3fc65501..a28cc418207 100644
--- a/mysql-test/main/group_min_max.result
+++ b/mysql-test/main/group_min_max.result
@@ -2449,7 +2449,7 @@ EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE EXISTS
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1_outer index NULL a 10 NULL 15 Using index
-2 SUBQUERY t1 range a a 5 NULL 2 Using where; Using index for group-by
+2 SUBQUERY t1 index NULL a 10 NULL 15 Using index
EXPLAIN SELECT 1 FROM t1 AS t1_outer WHERE
(SELECT max(b) FROM t1 GROUP BY a HAVING a < 2) > 12;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/mysql-test/main/information_schema_parameters.result b/mysql-test/main/information_schema_parameters.result
index a215c86c388..02f97159f28 100644
--- a/mysql-test/main/information_schema_parameters.result
+++ b/mysql-test/main/information_schema_parameters.result
@@ -424,7 +424,7 @@ SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE P
DROP DATABASE IF EXISTS i_s_parameters_test;
CREATE DATABASE i_s_parameters_test;
USE i_s_parameters_test;
-CREATE PROCEDURE testproc (OUT param1 INT)
+CREATE PROCEDURE testproc (IN param1 INT)
BEGIN
SELECT 2+2 as param1;
END;
@@ -432,7 +432,7 @@ END;
SELECT * FROM INFORMATION_SCHEMA.PARAMETERS
WHERE SPECIFIC_SCHEMA = 'i_s_parameters_test' AND SPECIFIC_NAME = 'testproc';
SPECIFIC_CATALOG SPECIFIC_SCHEMA SPECIFIC_NAME ORDINAL_POSITION PARAMETER_MODE PARAMETER_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME DTD_IDENTIFIER ROUTINE_TYPE
-def i_s_parameters_test testproc 1 OUT param1 int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE
+def i_s_parameters_test testproc 1 IN param1 int NULL NULL 10 0 NULL NULL NULL int(11) PROCEDURE
# ========== parameters.5 ==========
DROP DATABASE IF EXISTS i_s_parameters_test;
CREATE DATABASE i_s_parameters_test;
diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test
index bf25a6757f0..8ce6af478b6 100644
--- a/mysql-test/main/information_schema_parameters.test
+++ b/mysql-test/main/information_schema_parameters.test
@@ -92,7 +92,7 @@ CREATE DATABASE i_s_parameters_test;
USE i_s_parameters_test;
delimiter //;
-CREATE PROCEDURE testproc (OUT param1 INT)
+CREATE PROCEDURE testproc (IN param1 INT)
BEGIN
SELECT 2+2 as param1;
END;
diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result
index 1e880e1e442..edca2905380 100644
--- a/mysql-test/main/join.result
+++ b/mysql-test/main/join.result
@@ -1551,6 +1551,1390 @@ ERROR 23000: Column 'c' in field list is ambiguous
DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
#
+# MDEV-19421: Embedding inner joins
+#
+create table t1 (a int);
+insert into t1 values (7), (5), (3);
+create table s1 (b int);
+insert into s1 values (7), (5), (3);
+create table t2 (a int);
+insert into t2 values (5), (1), (7);
+create table s2 (b int);
+insert into s2 values (5), (1), (7);
+create table t3 (a int);
+insert into t3 values (2), (7), (3);
+create table t4 (a int);
+insert into t4 values (4), (7), (9), (5);
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
+t1_a t2_a t3_a
+7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t1`.`a`) where `test`.`t2`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a;
+t1_a t2_a t3_a
+7 7 7
+5 5 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a on t1.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t3` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a on t1.a=t3.a;
+t1_a t2_a t3_a
+7 7 7
+3 NULL 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 using(a) using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 using(a) using(a);
+t1_a t2_a t3_a
+7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 using(a) using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t1`.`a`) where `test`.`t2`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 using(a) using(a);
+t1_a t2_a t3_a
+7 7 7
+5 5 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 using(a) using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t3` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 using(a) using(a);
+t1_a t2_a t3_a
+7 7 7
+3 NULL 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a;
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a;
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+7 5 NULL
+5 5 NULL
+3 5 NULL
+7 1 NULL
+5 1 NULL
+3 1 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a;
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+NULL NULL 2
+NULL NULL 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t1.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t1.a=t3.a;
+t1_a t2_a t3_a
+7 5 7
+7 1 7
+7 7 7
+3 5 3
+3 1 3
+3 7 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t1.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t1`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t1.a=t3.a;
+t1_a t2_a t3_a
+7 5 7
+7 1 7
+7 7 7
+3 5 3
+3 1 3
+3 7 3
+5 5 NULL
+5 1 NULL
+5 7 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t1.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t1`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t1.a=t3.a;
+t1_a t2_a t3_a
+7 5 7
+3 5 3
+7 1 7
+3 1 3
+7 7 7
+3 7 3
+NULL NULL 2
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 join t3 on t2.a=t3.a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 join t3 on t2.a=t3.a);
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 left join t3 on t2.a=t3.a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 left join t3 on t2.a=t3.a);
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+7 5 NULL
+5 5 NULL
+3 5 NULL
+7 1 NULL
+5 1 NULL
+3 1 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 right join t3 on t2.a=t3.a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t3` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 right join t3 on t2.a=t3.a);
+t1_a t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+7 NULL 2
+5 NULL 2
+3 NULL 2
+7 NULL 3
+5 NULL 3
+3 NULL 3
+explain extended select *
+from s1 join t2 join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`s1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select *
+from s1 join t2 join t3 using(a);
+a b
+7 7
+7 5
+7 3
+explain extended select *
+from s1 join t2 left join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`s1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select *
+from s1 join t2 left join t3 using(a);
+a b
+7 7
+7 5
+7 3
+5 7
+5 5
+5 3
+1 7
+1 5
+1 3
+explain extended select *
+from s1 join t2 right join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`t3` left join (`test`.`s1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select *
+from s1 join t2 right join t3 using(a);
+a b
+7 7
+7 5
+7 3
+2 NULL
+3 NULL
+explain extended select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`s1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 join t3 using(a);
+b t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+explain extended select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 left join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`s1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 left join t3 using(a);
+b t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+7 5 NULL
+5 5 NULL
+3 5 NULL
+7 1 NULL
+5 1 NULL
+3 1 NULL
+explain extended select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 right join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t3` left join (`test`.`s1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 right join t3 using(a);
+b t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+NULL NULL 2
+NULL NULL 3
+explain extended select s1.b, t2.a as t2_a, t3.a as t3_a
+from (s1 join t2) right join t3 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t3` left join (`test`.`s1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from (s1 join t2) right join t3 using(a);
+b t2_a t3_a
+7 7 7
+5 7 7
+3 7 7
+NULL NULL 2
+NULL NULL 3
+explain extended select *
+from s1 join t2 natural join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`s1` join `test`.`t2` join `test`.`t3` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select *
+from s1 join t2 natural join t3;
+a b
+7 7
+7 5
+7 3
+explain extended select *
+from s1 join t2 natural left join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`s1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select *
+from s1 join t2 natural left join t3;
+a b
+7 7
+7 5
+7 3
+5 7
+5 5
+5 3
+1 7
+1 5
+1 3
+explain extended select *
+from s1 join t2 natural right join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`s1`.`b` AS `b` from `test`.`t3` left join (`test`.`s1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select *
+from s1 join t2 natural right join t3;
+a b
+7 7
+7 5
+7 3
+2 NULL
+3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3;
+t1_a t2_a t3_a
+7 5 2
+5 5 2
+3 5 2
+7 1 2
+5 1 2
+3 1 2
+7 7 2
+5 7 2
+3 7 2
+7 5 7
+5 5 7
+3 5 7
+7 1 7
+5 1 7
+3 1 7
+7 7 7
+5 7 7
+3 7 7
+7 5 3
+5 5 3
+3 5 3
+7 1 3
+5 1 3
+3 1 3
+7 7 3
+5 7 3
+3 7 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3
+where t1.a=t2.a and t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3
+where t1.a=t2.a and t2.a=t3.a;
+t1_a t2_a t3_a
+7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t4`.`a` = `test`.`t2`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t4`.`a` = `test`.`t2`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 NULL NULL
+5 5 NULL NULL
+3 5 NULL NULL
+7 1 NULL NULL
+5 1 NULL NULL
+3 1 NULL NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t2`.`a`)) on(`test`.`t3`.`a` = `test`.`t2`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 NULL NULL
+5 5 NULL NULL
+3 5 NULL NULL
+7 1 NULL NULL
+5 1 NULL NULL
+3 1 NULL NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` left join (`test`.`t4` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t4`.`a` = `test`.`t2`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 NULL NULL
+5 5 NULL NULL
+3 5 NULL NULL
+7 1 NULL NULL
+5 1 NULL NULL
+3 1 NULL NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t3` join `test`.`t4` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where `test`.`t4`.`a` = `test`.`t3`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL 2 NULL
+NULL NULL 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t4`.`a`) left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 left join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 left join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 2 NULL
+5 5 2 NULL
+3 5 2 NULL
+7 1 2 NULL
+5 1 2 NULL
+3 1 2 NULL
+7 7 2 NULL
+5 7 2 NULL
+3 7 2 NULL
+7 5 3 NULL
+5 5 3 NULL
+3 5 3 NULL
+7 1 3 NULL
+5 1 3 NULL
+3 1 3 NULL
+7 7 3 NULL
+5 7 3 NULL
+3 7 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 right join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`t1` join `test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 right join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 join t4 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`s2` join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a`
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 join t4 using(a);
+s1_b s2_b t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+explain extended select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 left join t4 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`s2` join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 left join t4 using(a);
+s1_b s2_b t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 2 NULL
+5 5 2 NULL
+3 5 2 NULL
+7 1 2 NULL
+5 1 2 NULL
+3 1 2 NULL
+7 7 2 NULL
+5 7 2 NULL
+3 7 2 NULL
+7 5 3 NULL
+5 5 3 NULL
+3 5 3 NULL
+7 1 3 NULL
+5 1 3 NULL
+3 1 3 NULL
+7 7 3 NULL
+5 7 3 NULL
+3 7 3 NULL
+explain extended select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 right join t4 using(a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`s1` join `test`.`s2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 right join t4 using(a);
+s1_b s2_b t3_a t4_a
+7 5 7 7
+5 5 7 7
+3 5 7 7
+7 1 7 7
+5 1 7 7
+3 1 7 7
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 on t2.a=t3.a join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 on t2.a=t3.a join t4;
+t1_a t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 on t2.a=t3.a join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) join `test`.`t4` where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 on t2.a=t3.a join t4;
+t1_a t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 5 NULL 4
+5 5 NULL 4
+3 5 NULL 4
+7 1 NULL 4
+5 1 NULL 4
+3 1 NULL 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 NULL 7
+5 5 NULL 7
+3 5 NULL 7
+7 1 NULL 7
+5 1 NULL 7
+3 1 NULL 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 5 NULL 9
+5 5 NULL 9
+3 5 NULL 9
+7 1 NULL 9
+5 1 NULL 9
+3 1 NULL 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+7 5 NULL 5
+5 5 NULL 5
+3 5 NULL 5
+7 1 NULL 5
+5 1 NULL 5
+3 1 NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 on t2.a=t3.a join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t3` left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) join `test`.`t4` where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 on t2.a=t3.a join t4;
+t1_a t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+NULL NULL 2 4
+NULL NULL 3 4
+NULL NULL 2 7
+NULL NULL 3 7
+NULL NULL 2 9
+NULL NULL 3 9
+NULL NULL 2 5
+NULL NULL 3 5
+explain extended select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 join t3 using(a) join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where `test`.`t3`.`a` = `test`.`t2`.`a`
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 join t3 using(a) join t4;
+s1_b t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+explain extended select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 left join t3 using(a) join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t2`.`a`) join `test`.`t4` where 1
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 left join t3 using(a) join t4;
+s1_b t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 5 NULL 4
+5 5 NULL 4
+3 5 NULL 4
+7 1 NULL 4
+5 1 NULL 4
+3 1 NULL 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 5 NULL 7
+5 5 NULL 7
+3 5 NULL 7
+7 1 NULL 7
+5 1 NULL 7
+3 1 NULL 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 5 NULL 9
+5 5 NULL 9
+3 5 NULL 9
+7 1 NULL 9
+5 1 NULL 9
+3 1 NULL 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+7 5 NULL 5
+5 5 NULL 5
+3 5 NULL 5
+7 1 NULL 5
+5 1 NULL 5
+3 1 NULL 5
+explain extended select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 right join t3 using(a) join t4;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t3` left join (`test`.`s1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) join `test`.`t4` where 1
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 right join t3 using(a) join t4;
+s1_b t2_a t3_a t4_a
+7 7 7 4
+5 7 7 4
+3 7 7 4
+7 7 7 7
+5 7 7 7
+3 7 7 7
+7 7 7 9
+5 7 7 9
+3 7 7 9
+7 7 7 5
+5 7 7 5
+3 7 7 5
+NULL NULL 2 4
+NULL NULL 3 4
+NULL NULL 2 7
+NULL NULL 3 7
+NULL NULL 2 9
+NULL NULL 3 9
+NULL NULL 2 5
+NULL NULL 3 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a` and `test`.`t2`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` join `test`.`t2` join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where `test`.`t2`.`a` = `test`.`t1`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+5 5 2 NULL
+7 7 2 NULL
+5 5 3 NULL
+7 7 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`t1` join `test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a` and `test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+3 NULL 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+3 NULL 7 7
+5 5 2 NULL
+7 7 2 NULL
+3 NULL 2 NULL
+5 5 3 NULL
+7 7 3 NULL
+3 NULL 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+5 5 7 7
+7 7 7 7
+3 NULL 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a`) join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`t3`.`a`
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 5 7 7
+NULL 1 7 7
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a`) join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 5 7 7
+NULL 1 7 7
+7 7 2 NULL
+5 5 2 NULL
+NULL 1 2 NULL
+7 7 3 NULL
+5 5 3 NULL
+NULL 1 3 NULL
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a`) join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t4`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 5 7 7
+NULL 1 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 join t4 on t4.a=s1.b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`s1`.`b`) join `test`.`t3` join `test`.`t4` where `test`.`t4`.`a` = `test`.`s1`.`b`
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 join t4 on t4.a=s1.b;
+s1_b t1_a t2_a t3_a t4_a
+7 7 7 2 7
+7 5 7 2 7
+7 3 7 2 7
+7 7 7 7 7
+7 5 7 7 7
+7 3 7 7 7
+7 7 7 3 7
+7 5 7 3 7
+7 3 7 3 7
+5 7 5 2 5
+5 5 5 2 5
+5 3 5 2 5
+5 7 5 7 5
+5 5 5 7 5
+5 3 5 7 5
+5 7 5 3 5
+5 5 5 3 5
+5 3 5 3 5
+explain extended select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 left join t4 on t4.a=s1.b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`s1` join `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`s1`.`b`) join `test`.`t3` left join `test`.`t4` on(`test`.`t4`.`a` = `test`.`s1`.`b`) where 1
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 left join t4 on t4.a=s1.b;
+s1_b t1_a t2_a t3_a t4_a
+7 7 7 2 7
+7 5 7 2 7
+7 3 7 2 7
+7 7 7 7 7
+7 5 7 7 7
+7 3 7 7 7
+7 7 7 3 7
+7 5 7 3 7
+7 3 7 3 7
+5 7 5 2 5
+5 5 5 2 5
+5 3 5 2 5
+5 7 5 7 5
+5 5 5 7 5
+5 3 5 7 5
+5 7 5 3 5
+5 5 5 3 5
+5 3 5 3 5
+3 7 NULL 2 NULL
+3 5 NULL 2 NULL
+3 3 NULL 2 NULL
+3 7 NULL 7 NULL
+3 5 NULL 7 NULL
+3 3 NULL 7 NULL
+3 7 NULL 3 NULL
+3 5 NULL 3 NULL
+3 3 NULL 3 NULL
+explain extended select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 right join t4 on t4.a=s1.b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join (`test`.`s1` join `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t4`.`a`) join `test`.`t3`) on(`test`.`s1`.`b` = `test`.`t4`.`a`) where 1
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 right join t4 on t4.a=s1.b;
+s1_b t1_a t2_a t3_a t4_a
+5 7 5 2 5
+5 5 5 2 5
+5 3 5 2 5
+7 7 7 2 7
+7 5 7 2 7
+7 3 7 2 7
+5 7 5 7 5
+5 5 5 7 5
+5 3 5 7 5
+7 7 7 7 7
+7 5 7 7 7
+7 3 7 7 7
+5 7 5 3 5
+5 5 5 3 5
+5 3 5 3 5
+7 7 7 3 7
+7 5 7 3 7
+7 3 7 3 7
+NULL NULL NULL NULL 4
+NULL NULL NULL NULL 9
+explain extended select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t2` left join (`test`.`s1` join `test`.`s2` join `test`.`t1`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`s2`.`b` = `test`.`s1`.`b`) join `test`.`t3` where 1
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+s1_b s2_b t1_a t2_a t3_a
+5 5 7 7 2
+7 7 7 7 2
+5 5 5 5 2
+7 7 5 5 2
+5 5 7 7 7
+7 7 7 7 7
+5 5 5 5 7
+7 7 5 5 7
+5 5 7 7 3
+7 7 7 7 3
+5 5 5 5 3
+7 7 5 5 3
+NULL NULL NULL 1 2
+NULL NULL NULL 1 7
+NULL NULL NULL 1 3
+explain extended select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 left join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t2` left join (`test`.`s1` left join `test`.`s2` on(`test`.`s2`.`b` = `test`.`s1`.`b`) join `test`.`t1`) on(`test`.`t1`.`a` = `test`.`t2`.`a`) join `test`.`t3` where 1
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 left join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+s1_b s2_b t1_a t2_a t3_a
+5 5 7 7 2
+7 7 7 7 2
+3 NULL 7 7 2
+5 5 5 5 2
+7 7 5 5 2
+3 NULL 5 5 2
+5 5 7 7 7
+7 7 7 7 7
+3 NULL 7 7 7
+5 5 5 5 7
+7 7 5 5 7
+3 NULL 5 5 7
+5 5 7 7 3
+7 7 7 7 3
+3 NULL 7 7 3
+5 5 5 5 3
+7 7 5 5 3
+3 NULL 5 5 3
+NULL NULL NULL 1 2
+NULL NULL NULL 1 7
+NULL NULL NULL 1 3
+explain extended select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 right join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00
+1 SIMPLE s2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join)
+1 SIMPLE s1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`s1`.`b` AS `s1_b`,`test`.`s2`.`b` AS `s2_b`,`test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a` from `test`.`t2` left join (`test`.`s2` left join `test`.`s1` on(`test`.`s1`.`b` = `test`.`s2`.`b`) join `test`.`t1`) on(`test`.`t1`.`a` = `test`.`t2`.`a`) join `test`.`t3` where 1
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 right join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+s1_b s2_b t1_a t2_a t3_a
+7 7 7 7 2
+5 5 7 7 2
+NULL 1 7 7 2
+7 7 5 5 2
+5 5 5 5 2
+NULL 1 5 5 2
+7 7 7 7 7
+5 5 7 7 7
+NULL 1 7 7 7
+7 7 5 5 7
+5 5 5 5 7
+NULL 1 5 5 7
+7 7 7 7 3
+5 5 7 7 3
+NULL 1 7 7 3
+7 7 5 5 3
+5 5 5 5 3
+NULL 1 5 5 3
+NULL NULL NULL 1 2
+NULL NULL NULL 1 7
+NULL NULL NULL 1 3
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t4`.`a`) left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1 join t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t4`.`a`) left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1 join t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+explain extended select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1, t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 4 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `t1_a`,`test`.`t2`.`a` AS `t2_a`,`test`.`t3`.`a` AS `t3_a`,`test`.`t4`.`a` AS `t4_a` from `test`.`t4` left join `test`.`t3` on(`test`.`t3`.`a` = `test`.`t4`.`a`) left join (`test`.`t1` join `test`.`t2`) on(`test`.`t2`.`a` = `test`.`t3`.`a`) where 1
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1, t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+t1_a t2_a t3_a t4_a
+7 7 7 7
+5 7 7 7
+3 7 7 7
+NULL NULL NULL 4
+NULL NULL NULL 9
+NULL NULL NULL 5
+drop table t1,t2,t3,t4,s1,s2;
+#
# End of MariaDB 5.5 tests
#
#
diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test
index 223886b579c..b36b0ac8f35 100644
--- a/mysql-test/main/join.test
+++ b/mysql-test/main/join.test
@@ -1211,6 +1211,410 @@ DROP PROCEDURE p1;
DROP TABLE t1,t2,t3,t4,t5;
--echo #
+--echo # MDEV-19421: Embedding inner joins
+--echo #
+
+create table t1 (a int);
+insert into t1 values (7), (5), (3);
+create table s1 (b int);
+insert into s1 values (7), (5), (3);
+create table t2 (a int);
+insert into t2 values (5), (1), (7);
+create table s2 (b int);
+insert into s2 values (5), (1), (7);
+create table t3 (a int);
+insert into t3 values (2), (7), (3);
+create table t4 (a int);
+insert into t4 values (4), (7), (9), (5);
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a on t1.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 using(a) using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 using(a) using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 using(a) using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3 on t1.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 left join t3 on t1.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 right join t3 on t1.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 join t3 on t2.a=t3.a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 left join t3 on t2.a=t3.a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join (t2 right join t3 on t2.a=t3.a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 left join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 right join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 left join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from s1 join t2 right join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b, t2.a as t2_a, t3.a as t3_a
+from (s1 join t2) right join t3 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 natural join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 natural left join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select *
+from s1 join t2 natural right join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from t1 join t2 join t3
+where t1.a=t2.a and t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 left join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 left join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 right join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 join t4 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 left join t4 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t3.a as t3_a, t4.a as t4_a
+from s1 join s2 join t3 right join t4 using(a);
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 join t3 on t2.a=t3.a join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 left join t3 on t2.a=t3.a join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 on t2.a=t3.a join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 join t3 using(a) join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 left join t3 using(a) join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t2 right join t3 using(a) join t4;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 left join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 left join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 right join t2 on t1.a=t2.a join t3 right join t4 on t3.a=t4.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 join t4 on t4.a=s1.b;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 left join t4 on t4.a=s1.b;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from s1 join t1 left join t2 on s1.b=t2.a join t3 right join t4 on t4.a=s1.b;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 left join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select s1.b as s1_b, s2.b as s2_b, t1.a as t1_a, t2.a as t2_a, t3.a as t3_a
+from s1 right join s2 on s1.b=s2.b join t1 right join t2 on t1.a=t2.a join t3;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from t1 join t2 right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1 join t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+let $q=
+select t1.a as t1_a, t2.a as t2_a, t3.a as t3_a, t4.a as t4_a
+from (t1, t2) right join t3 right join t4 on t3.a=t4.a on t2.a=t3.a;
+eval explain extended $q;
+eval $q;
+
+drop table t1,t2,t3,t4,s1,s2;
+
+--echo #
--echo # End of MariaDB 5.5 tests
--echo #
diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result
index 9026a32e356..ccd73ec955f 100644
--- a/mysql-test/main/join_outer_innodb.result
+++ b/mysql-test/main/join_outer_innodb.result
@@ -486,7 +486,7 @@ Note 1051 Unknown table 'test.t2'
Note 1051 Unknown table 'test.t3'
create table t2(a int,unique key (a)) engine=innodb;
create table t3(b int) engine=innodb;
-create table t1(a int,b int)engine=innodb;
+create table t1(c int,b int)engine=innodb;
set @mdev4270_opl= @@optimizer_prune_level;
set @mdev4270_osd= @@optimizer_search_depth;
set optimizer_prune_level=0;
diff --git a/mysql-test/main/join_outer_innodb.test b/mysql-test/main/join_outer_innodb.test
index fe08689c80b..67e9965a475 100644
--- a/mysql-test/main/join_outer_innodb.test
+++ b/mysql-test/main/join_outer_innodb.test
@@ -358,7 +358,7 @@ drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16;
drop table if exists t1,t2,t3;
create table t2(a int,unique key (a)) engine=innodb;
create table t3(b int) engine=innodb;
-create table t1(a int,b int)engine=innodb;
+create table t1(c int,b int)engine=innodb;
set @mdev4270_opl= @@optimizer_prune_level;
set @mdev4270_osd= @@optimizer_search_depth;
diff --git a/mysql-test/main/plugin.result b/mysql-test/main/plugin.result
index 49342705289..6fbbc0a880a 100644
--- a/mysql-test/main/plugin.result
+++ b/mysql-test/main/plugin.result
@@ -318,6 +318,15 @@ UNUSABLE
uninstall soname 'ha_example';
select plugin_name from information_schema.plugins where plugin_library like 'ha_example%';
plugin_name
+set names utf8;
+select convert('admin𝌆' using utf8);
+convert('admin𝌆' using utf8)
+admin????
+Warnings:
+Warning 1300 Invalid utf8 character string: '\xF0\x9D\x8C\x86'
+install plugin foo soname 'admin𝌆';
+ERROR HY000: No paths allowed for shared library
+# End of 5.5 test
#
# MDEV-5309 - RENAME TABLE does not check for existence of the table's
# engine
@@ -331,6 +340,7 @@ UNINSTALL PLUGIN example;
RENAME TABLE t1 TO t2;
ERROR 42S02: Table 'test.t1' doesn't exist
DROP TABLE t1;
+# End of 10.1 test
#
# MDEV-16294: INSTALL PLUGIN IF NOT EXISTS / UNINSTALL PLUGIN IF EXISTS
#
diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test
index 0990cb206d8..5a855a1276e 100644
--- a/mysql-test/main/plugin.test
+++ b/mysql-test/main/plugin.test
@@ -252,6 +252,15 @@ select plugin_name from information_schema.plugins where plugin_library like 'ha
uninstall soname 'ha_example';
select plugin_name from information_schema.plugins where plugin_library like 'ha_example%';
+#
+#
+#
+set names utf8;
+select convert('admin𝌆' using utf8);
+--error ER_UDF_NO_PATHS
+install plugin foo soname 'admin𝌆';
+
+--echo # End of 5.5 test
--echo #
--echo # MDEV-5309 - RENAME TABLE does not check for existence of the table's
@@ -266,6 +275,8 @@ UNINSTALL PLUGIN example;
RENAME TABLE t1 TO t2;
DROP TABLE t1;
+--echo # End of 10.1 test
+
--source include/install_plugin_if_exists.inc
diff --git a/mysql-test/main/plugin_not_embedded.result b/mysql-test/main/plugin_not_embedded.result
index 2edf6c496d3..a9ac5735137 100644
--- a/mysql-test/main/plugin_not_embedded.result
+++ b/mysql-test/main/plugin_not_embedded.result
@@ -16,3 +16,7 @@ connection default;
DROP USER bug51770@localhost;
INSTALL PLUGIN example SONAME '../ha_example.so';
ERROR HY000: No paths allowed for shared library
+insert mysql.plugin values ();
+# restart
+delete from mysql.plugin where name = '';
+# End of 5.5 tests
diff --git a/mysql-test/main/plugin_not_embedded.test b/mysql-test/main/plugin_not_embedded.test
index 3b4129b6b6b..a9126053f18 100644
--- a/mysql-test/main/plugin_not_embedded.test
+++ b/mysql-test/main/plugin_not_embedded.test
@@ -30,3 +30,12 @@ let $path = `select CONCAT_WS('/', '..', '$HA_EXAMPLE_SO')`;
--replace_regex /\.dll/.so/
--error ER_UDF_NO_PATHS
eval INSTALL PLUGIN example SONAME '$path';
+
+#
+# Bug#27302459: EMPTY VALUE IN MYSQL.PLUGIN TABLE CAUSES SERVER TO EXIT ON STARTUP
+#
+insert mysql.plugin values ();
+source include/restart_mysqld.inc;
+delete from mysql.plugin where name = '';
+
+--echo # End of 5.5 tests
diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result
index 1e846180429..b3b295842cd 100644
--- a/mysql-test/main/ps.result
+++ b/mysql-test/main/ps.result
@@ -4393,6 +4393,69 @@ LINE1 1
LINE2 2
LINE3 3
drop table t1;
+#
+# MDEV-17042: prepared statement does not return error with
+# SQL_MODE STRICT_TRANS_TABLES. (Part 1)
+#
+set @save_sql_mode=@@sql_mode;
+set sql_mode='STRICT_ALL_TABLES';
+CREATE TABLE t1 (id int, count int);
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id decimal(10,5), count int);
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id double, count int);
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id date, count int);
+insert into t1 values ("2019-06-11",1),("2019-06-12",2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+set sql_mode=@save_sql_mode;
# End of 5.5 tests
#
# End of 10.0 tests
diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test
index f701716e4f4..a9d588a02c0 100644
--- a/mysql-test/main/ps.test
+++ b/mysql-test/main/ps.test
@@ -3864,6 +3864,83 @@ FROM
FROM t1 A, (SELECT @cnt := 0) C) T
) X;
drop table t1;
+
+--echo #
+--echo # MDEV-17042: prepared statement does not return error with
+--echo # SQL_MODE STRICT_TRANS_TABLES. (Part 1)
+--echo #
+
+set @save_sql_mode=@@sql_mode;
+set sql_mode='STRICT_ALL_TABLES';
+
+CREATE TABLE t1 (id int, count int);
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id decimal(10,5), count int);
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id double, count int);
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id date, count int);
+insert into t1 values ("2019-06-11",1),("2019-06-12",2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+set sql_mode=@save_sql_mode;
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/main/ps_innodb.result b/mysql-test/main/ps_innodb.result
new file mode 100644
index 00000000000..4a5819e4072
--- /dev/null
+++ b/mysql-test/main/ps_innodb.result
@@ -0,0 +1,64 @@
+#
+# MDEV-17042: prepared statement does not return error with
+# SQL_MODE STRICT_TRANS_TABLES. (Part 2)
+#
+set @save_sql_mode=@@sql_mode;
+set sql_mode='STRICT_TRANS_TABLES';
+CREATE TABLE t1 (id int, count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id decimal(10,5), count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DECIMAL value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id double, count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect DOUBLE value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+CREATE TABLE t1 (id date, count int) engine=innodb;
+insert into t1 values ("2019-06-11",1),("2019-06-12",2);
+update t1 set count = count + 1 where id = '1bad';
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+execute stmt;
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+deallocate prepare stmt;
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+execute stmt using @a;
+ERROR 22007: Truncated incorrect datetime value: '1bad'
+deallocate prepare stmt;
+drop table t1;
+set sql_mode=@save_sql_mode;
+# End of 5.5 tests
diff --git a/mysql-test/main/ps_innodb.test b/mysql-test/main/ps_innodb.test
new file mode 100644
index 00000000000..6f56af35271
--- /dev/null
+++ b/mysql-test/main/ps_innodb.test
@@ -0,0 +1,80 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-17042: prepared statement does not return error with
+--echo # SQL_MODE STRICT_TRANS_TABLES. (Part 2)
+--echo #
+
+set @save_sql_mode=@@sql_mode;
+set sql_mode='STRICT_TRANS_TABLES';
+
+CREATE TABLE t1 (id int, count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id decimal(10,5), count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id double, count int) engine=innodb;
+insert into t1 values (1,1),(0,2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+
+CREATE TABLE t1 (id date, count int) engine=innodb;
+insert into t1 values ("2019-06-11",1),("2019-06-12",2);
+--error ER_TRUNCATED_WRONG_VALUE
+update t1 set count = count + 1 where id = '1bad';
+
+prepare stmt from "update t1 set count = count + 1 where id = '1bad'";
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt;
+deallocate prepare stmt;
+
+prepare stmt from 'update t1 set count = count + 1 where id = ?';
+set @a = '1bad';
+--error ER_TRUNCATED_WRONG_VALUE
+execute stmt using @a;
+deallocate prepare stmt;
+drop table t1;
+set sql_mode=@save_sql_mode;
+
+--echo # End of 5.5 tests
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 087faef284d..33c7c9be47a 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -402,7 +402,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
-Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
+Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey` limit 1))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@@ -443,7 +443,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
-Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
+Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey` limit 1))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@@ -987,7 +987,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 14 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where <cache>(<in_optimizer>(1,exists(/* select#2 */ select 1 from `test`.`t1` join `test`.`t2`))) and `test`.`t1`.`a` <> `test`.`t2`.`b` or `test`.`t1`.`a` <= 4
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where <cache>(<in_optimizer>(1,exists(/* select#2 */ select 1 from `test`.`t1` join `test`.`t2` limit 1))) and `test`.`t1`.`a` <> `test`.`t2`.`b` or `test`.`t1`.`a` <= 4
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index b6fed1bb41d..92091f0d6db 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -405,7 +405,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 100.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
-Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
+Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey` limit 1))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@@ -446,7 +446,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY customer ALL NULL NULL NULL NULL 150 91.00 Using where
Warnings:
Note 1276 Field or reference 'dbt3_s001.customer.c_custkey' of SELECT #4 was resolved in SELECT #2
-Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey`))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
+Note 1003 /* select#1 */ select substr(`dbt3_s001`.`customer`.`c_phone`,1,2) AS `cntrycode`,count(0) AS `numcust`,sum(`dbt3_s001`.`customer`.`c_acctbal`) AS `totacctbal` from `dbt3_s001`.`customer` where substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25') and `dbt3_s001`.`customer`.`c_acctbal` > (/* select#3 */ select avg(`dbt3_s001`.`customer`.`c_acctbal`) from `dbt3_s001`.`customer` where `dbt3_s001`.`customer`.`c_acctbal` > 0.00 and substr(`dbt3_s001`.`customer`.`c_phone`,1,2) in ('10','20','14','19','11','28','25')) and !<in_optimizer>(1,<expr_cache><`dbt3_s001`.`customer`.`c_custkey`>(exists(/* select#4 */ select 1 from `dbt3_s001`.`orders` where `dbt3_s001`.`orders`.`o_custkey` = `dbt3_s001`.`customer`.`c_custkey` limit 1))) group by substr(`dbt3_s001`.`customer`.`c_phone`,1,2) order by substr(`dbt3_s001`.`customer`.`c_phone`,1,2)
select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal
from (
select substr(c_phone, 1, 2) as cntrycode, c_acctbal
@@ -997,7 +997,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 SUBQUERY t2 ALL NULL NULL NULL NULL 7 100.00
2 SUBQUERY t1 ALL NULL NULL NULL NULL 14 100.00 Using join buffer (flat, BNL join)
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where <cache>(<in_optimizer>(1,exists(/* select#2 */ select 1 from `test`.`t1` join `test`.`t2`))) and `test`.`t1`.`a` <> `test`.`t2`.`b` or `test`.`t1`.`a` <= 4
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` join `test`.`t2` where <cache>(<in_optimizer>(1,exists(/* select#2 */ select 1 from `test`.`t1` join `test`.`t2` limit 1))) and `test`.`t1`.`a` <> `test`.`t2`.`b` or `test`.`t1`.`a` <= 4
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index 1fdf8d19ba6..fc0049db997 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result
@@ -1894,7 +1894,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null)))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1)))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -4462,7 +4462,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7264,6 +7264,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test
index 82823b418ef..7ed423edf96 100644
--- a/mysql-test/main/subselect.test
+++ b/mysql-test/main/subselect.test
@@ -6104,6 +6104,30 @@ explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
drop table t1,t2;
+
+--echo #
+--echo # MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+--echo #
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+
+set @l=1;
+execute stmt1 using @l;
+set @l=2;
+execute stmt1 using @l;
+set @l=0;
+execute stmt1 using @l;
+
+deallocate prepare stmt1;
+
+drop table t10, t12;
+
--echo End of 5.5 tests
--echo # End of 10.0 tests
diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result
index 783542c7dbf..3dc019cc6c1 100644
--- a/mysql-test/main/subselect4.result
+++ b/mysql-test/main/subselect4.result
@@ -2565,9 +2565,8 @@ explain
select * from t1
where exists (select * from t2 where t2.a=t1.a order by t2.b limit 0);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 100
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1
-2 MATERIALIZED t2 ALL NULL NULL NULL NULL 100
+1 PRIMARY t1 ALL NULL NULL NULL NULL 100 Using where
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
# LIMIT+OFFSET prevents the conversion:
explain
select * from t1
diff --git a/mysql-test/main/subselect_cache.result b/mysql-test/main/subselect_cache.result
index 813d668c88c..abd978de9a5 100644
--- a/mysql-test/main/subselect_cache.result
+++ b/mysql-test/main/subselect_cache.result
@@ -3387,6 +3387,7 @@ WHERE table1 .`col_varchar_key` ) field10
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
+Warning 1292 Truncated incorrect DOUBLE value: 'f'
SET @@optimizer_switch = 'subquery_cache=on';
/* cache is on */ SELECT COUNT( DISTINCT table2 .`col_int_key` ) , (
SELECT SUBQUERY2_t1 .`col_int_key`
@@ -3403,6 +3404,7 @@ WHERE table1 .`col_varchar_key` ) field10
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'f'
Warning 1292 Truncated incorrect DOUBLE value: 'f'
+Warning 1292 Truncated incorrect DOUBLE value: 'f'
drop table t1,t2,t3,t4;
set @@optimizer_switch= default;
#launchpad BUG#611625
diff --git a/mysql-test/main/subselect_exists2in.result b/mysql-test/main/subselect_exists2in.result
index 029ac22a486..950538ad114 100644
--- a/mysql-test/main/subselect_exists2in.result
+++ b/mysql-test/main/subselect_exists2in.result
@@ -94,7 +94,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t3 ALL bb NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(/* select#2 */ select `test`.`t3`.`a` from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a`)
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(/* select#2 */ select `test`.`t3`.`a` from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a` limit 1)
set optimizer_switch=default;
set optimizer_switch='exists_to_in=on';
drop table t1,t2,t3;
@@ -361,7 +361,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t2.b' of SELECT #3 was resolved in SELECT #2
-Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !exists(/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
+Note 1003 /* select#1 */ select (/* select#2 */ select 1 from dual where !exists(/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1 limit 1)) AS `( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )` from `test`.`t1`
SELECT ( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1;
( SELECT b FROM t2 WHERE NOT EXISTS ( SELECT c FROM t3 WHERE c = b ) )
1
@@ -432,7 +432,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a1' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` where exists(/* select#2 */ select 1 from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`b1` = `test`.`t1`.`a1`)
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`a1` AS `a1` from `test`.`t1` where exists(/* select#2 */ select 1 from `test`.`t3` where `test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`b1` = `test`.`t1`.`a1` limit 1)
set optimizer_switch=default;
set optimizer_switch='exists_to_in=on';
drop table t1,t3;
@@ -908,7 +908,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1276 Field or reference 'sq1.pk' of SELECT #3 was resolved in SELECT #1
Note 1276 Field or reference 'sq1.f1' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select straight_join `test`.`t1`.`f2` AS `f2` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`,`test`.`t1`.`pk`>(exists(/* select#3 */ select 1 from `test`.`t1` `sq2` semi join (`test`.`t1`) where `test`.`sq2`.`f1` = `test`.`t1`.`f1` and `test`.`t1`.`pk` = `test`.`t1`.`f1`))
+Note 1003 /* select#1 */ select straight_join `test`.`t1`.`f2` AS `f2` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`,`test`.`t1`.`pk`>(exists(/* select#3 */ select 1 from `test`.`t1` `sq2` semi join (`test`.`t1`) where `test`.`sq2`.`f1` = `test`.`t1`.`f1` and `test`.`t1`.`pk` = `test`.`t1`.`f1` limit 1))
SELECT STRAIGHT_JOIN sq1.f2
FROM ( SELECT * FROM t1 ) AS sq1
WHERE EXISTS ( SELECT * FROM t1 AS sq2
diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result
index 781b94b689b..4cf28638484 100644
--- a/mysql-test/main/subselect_innodb.result
+++ b/mysql-test/main/subselect_innodb.result
@@ -458,7 +458,7 @@ EXPLAIN
SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 );
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-2 SUBQUERY t2 index PRIMARY PRIMARY 4 NULL 1 Using where; Using index; Using temporary
+2 SUBQUERY t2 index NULL PRIMARY 4 NULL 1 Using index; Using temporary
2 SUBQUERY t3 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
SELECT * FROM t1 WHERE EXISTS ( SELECT b FROM t2, t3 GROUP BY b HAVING b != 3 );
a
diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result
index 64bdfb499b4..4e03d9663ef 100644
--- a/mysql-test/main/subselect_mat.result
+++ b/mysql-test/main/subselect_mat.result
@@ -2284,7 +2284,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3`))
+Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3` limit 1))
# this checks the result set above
set optimizer_switch= 'materialization=off,semijoin=off';
SELECT * FROM t1
diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result
index 613a0d8dd6c..cffe195d3de 100644
--- a/mysql-test/main/subselect_no_exists_to_in.result
+++ b/mysql-test/main/subselect_no_exists_to_in.result
@@ -351,7 +351,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 100.00 Using index
Warnings:
Note 1276 Field or reference 'test.t6.clinic_uq' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(/* select#2 */ select 1 from `test`.`t7` where `test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))
+Note 1003 /* select#1 */ select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where <expr_cache><`test`.`t6`.`clinic_uq`>(exists(/* select#2 */ select 1 from `test`.`t7` where `test`.`t7`.`uq` = `test`.`t6`.`clinic_uq` limit 1))
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
ERROR 23000: Column 'a' in field list is ambiguous
drop table t1,t2,t3;
@@ -1898,7 +1898,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -2434,7 +2434,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.up.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(/* select#2 */ select 1 from `test`.`t1` where `test`.`t1`.`a` = `test`.`up`.`a`))
+Note 1003 /* select#1 */ select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where <expr_cache><`test`.`up`.`a`>(exists(/* select#2 */ select 1 from `test`.`t1` where `test`.`t1`.`a` = `test`.`up`.`a` limit 1))
drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
@@ -4452,7 +4452,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists(/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` limit 1))
EXPLAIN EXTENDED
SELECT 2 FROM t1 WHERE EXISTS ((SELECT 1 FROM t2 WHERE t1.a=t2.a) UNION
(SELECT 1 FROM t2 WHERE t1.a = t2.a));
@@ -4464,7 +4464,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7264,6 +7264,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result
index 982e701231d..4ebf04b1f55 100644
--- a/mysql-test/main/subselect_no_mat.result
+++ b/mysql-test/main/subselect_no_mat.result
@@ -1901,7 +1901,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null)))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1)))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -4464,7 +4464,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7257,6 +7257,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result
index 1937f2af8f6..b4ee1ba6287 100644
--- a/mysql-test/main/subselect_no_opts.result
+++ b/mysql-test/main/subselect_no_opts.result
@@ -1897,7 +1897,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -4460,7 +4460,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1)
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7255,6 +7255,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result
index 929af9b4b1f..71d61e797f3 100644
--- a/mysql-test/main/subselect_no_scache.result
+++ b/mysql-test/main/subselect_no_scache.result
@@ -1900,7 +1900,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -4468,7 +4468,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1)
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7270,6 +7270,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result
index 52c81e58a49..f4eadbf46ce 100644
--- a/mysql-test/main/subselect_no_semijoin.result
+++ b/mysql-test/main/subselect_no_semijoin.result
@@ -1897,7 +1897,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 100.00 Using where; Using index
Warnings:
Note 1276 Field or reference 'test.tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null)))
+Note 1003 /* select#1 */ select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where !<in_optimizer>(1,<expr_cache><`test`.`tt`.`id`>(exists(/* select#2 */ select `test`.`t1`.`id` from `test`.`t1` where `test`.`t1`.`id` < 8 and `test`.`t1`.`id` = `test`.`tt`.`id` having `test`.`t1`.`id` is not null limit 1)))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -4460,7 +4460,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #1
-Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`)))
+Note 1003 /* select#1 */ select 2 AS `2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a`>(exists((/* select#2 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) union (/* select#3 */ select 1 from `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a`) limit 1))
DROP TABLE t1,t2;
create table t0(a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
@@ -7255,6 +7255,37 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1,t2;
+#
+# MDEV-19429: Wrong query result with EXISTS and LIMIT 0
+#
+create table t10 (a int);
+insert into t10 values (1),(2),(3);
+create table t12 (a int);
+insert into t12 values (1),(2),(3);
+select * from t10 where exists (select * from t12 order by a limit 0);
+a
+explain select * from t10 where exists (select * from t12 order by a limit 0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Zero limit
+prepare stmt1 from "select * from t10 where exists (select * from t12 order by a limit ?)";
+set @l=1;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=2;
+execute stmt1 using @l;
+a
+1
+2
+3
+set @l=0;
+execute stmt1 using @l;
+a
+deallocate prepare stmt1;
+drop table t10, t12;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result
index 61caa0f1fbe..203dbee6374 100644
--- a/mysql-test/main/subselect_sj_mat.result
+++ b/mysql-test/main/subselect_sj_mat.result
@@ -2320,7 +2320,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED t3 ALL NULL NULL NULL NULL 8 100.00
Warnings:
Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1
-Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3`))
+Note 1003 /* select#1 */ select `test`.`t1`.`f1` AS `f1` from `test`.`t1` where <expr_cache><`test`.`t1`.`f1`>(exists(/* select#2 */ select 1 from `test`.`t2` semi join (`test`.`t3`) join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`f1` = `test`.`t3`.`f3` limit 1))
# this checks the result set above
set optimizer_switch= 'materialization=off,semijoin=off';
SELECT * FROM t1
diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result
index fdaf0baa02a..fe90989f3b0 100644
--- a/mysql-test/main/view.result
+++ b/mysql-test/main/view.result
@@ -5736,6 +5736,21 @@ t37, t38, t39, t40, t41, t42, t43, t44, t45,
t46, t47, t48, t49, t50, t51, t52, t53, t54,
t55, t56, t57, t58, t59,t60;
drop view v60;
+#
+# MDEV-15572: view.test, server crash with --big-tables=1
+#
+set @save_big_tables=@@big_tables;
+set big_tables=ON;
+CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
+CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
+CREATE VIEW v1 AS
+SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
+REPLACE INTO v1 (f1, f2, f3, f4)
+SELECT f1, f2, f3, f4 FROM t1;
+ERROR HY000: Can not modify more than one base table through a join view 'test.v1'
+drop view v1;
+drop table t1, t2;
+set big_tables=@save_big_tables;
# -----------------------------------------------------------------
# -- End of 5.5 tests.
# -----------------------------------------------------------------
diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test
index ce8ac8dec48..ccf9bcc8c9a 100644
--- a/mysql-test/main/view.test
+++ b/mysql-test/main/view.test
@@ -5624,6 +5624,26 @@ t46, t47, t48, t49, t50, t51, t52, t53, t54,
t55, t56, t57, t58, t59,t60;
drop view v60;
+--echo #
+--echo # MDEV-15572: view.test, server crash with --big-tables=1
+--echo #
+
+set @save_big_tables=@@big_tables;
+set big_tables=ON;
+CREATE TABLE t1 ( f1 int , f2 int , f3 int , f4 int);
+CREATE TABLE t2 ( f1 int , f2 int , f3 int , f4 int);
+
+CREATE VIEW v1 AS
+ SELECT t2.f1, t1.f2, t2.f3, t2.f4 FROM (t1 JOIN t2);
+
+--error ER_VIEW_MULTIUPDATE
+REPLACE INTO v1 (f1, f2, f3, f4)
+ SELECT f1, f2, f3, f4 FROM t1;
+
+drop view v1;
+drop table t1, t2;
+set big_tables=@save_big_tables;
+
--echo # -----------------------------------------------------------------
--echo # -- End of 5.5 tests.
--echo # -----------------------------------------------------------------
diff --git a/mysql-test/main/view_alias.result b/mysql-test/main/view_alias.result
index f3ae7aef3a6..384deeb2b99 100644
--- a/mysql-test/main/view_alias.result
+++ b/mysql-test/main/view_alias.result
@@ -90,23 +90,23 @@ CREATE TABLE t2 LIKE t1;
# Test alias in subquery
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 AS b WHERE b.a = 0);
DROP VIEW v1;
-CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 1 from `test`.`t2` `b` where `b`.`a` = 0);
+CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 1 from `test`.`t2` `b` where `b`.`a` = 0 limit 1);
DROP VIEW v1;
# Test column alias in subquery
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT a AS alias FROM t1 GROUP BY alias);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select `t1`.`a` AS `alias` from `t1` group by `t1`.`a`) latin1 latin1_swedish_ci
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select `t1`.`a` AS `alias` from `t1` group by `t1`.`a` limit 1) latin1 latin1_swedish_ci
DROP VIEW v1;
-CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t1`.`a` AS `alias` from `test`.`t1` group by `test`.`t1`.`a`);
+CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t1`.`a` AS `alias` from `test`.`t1` group by `test`.`t1`.`a` limit 1);
DROP VIEW v1;
# Alias as the expression column name.
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT ' a ' AS alias FROM t1 GROUP BY alias);
SHOW CREATE VIEW v1;
View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select ' a ' AS `alias` from `t1` group by ' a ') latin1 latin1_swedish_ci
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select ' a ' AS `alias` from `t1` group by ' a ' limit 1) latin1 latin1_swedish_ci
DROP VIEW v1;
-CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select ' a ' AS `alias` from `test`.`t1` group by ' a ');
+CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select ' a ' AS `alias` from `test`.`t1` group by ' a ' limit 1);
DROP VIEW v1;
DROP TABLE t1, t2;
create view v1 as select interval(55,10) as my_col;