1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

MDEV-40620: Run the FULL JOIN tests over more engines and switches

full_join.test runs once for every point of three crossed axes, the
optimizer switch axis in full_join.combinations, the storage engine axis
in full_join_engine.combinations and the index axis in
full_join_index.combinations, thirty runs in all.  The result file in the
tree is the run with the default engine, no added indexes and the
switches at their defaults.  Every other run's expected output is a diff
against it, so a run whose output matches it has no file of its own, and
a query added to the test shows up in all thirty runs.

The index axis gives every column of every base table a non-unique index
on itself.  The work is decided by what the database holds at the point
full_join_add_indexes.inc is sourced, so a section sources it after the
tables it creates.  A non-unique index is the only kind that can be added
without knowing the data, since a primary key or a unique index would
fail on the duplicates and the NULLs that many sections put in a join
column on purpose.

The switch axis holds the four switches at their defaults and each of
them off in turn, which is what makes a wrong result attributable to one
transformation.
This commit is contained in:
Dave Gosselin
2026-08-17 11:51:35 -04:00
parent 4561ccad91
commit 446817322a
36 changed files with 39465 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
# InnoDB keeps its index statistics in a table and recalculates them from a
# background thread once enough rows have changed. An EXPLAIN that runs
# while that recalculation is still pending reports a row estimate taken
# from whatever the table held at the time, so the same query gives a
# different estimate from one run to the next. Transient statistics are
# computed when the table is opened, from a sample large enough to cover
# every one of these small tables, which makes the estimates reproducible.
[innodb]
innodb
default-storage-engine=innodb
innodb-stats-persistent=0
[myisam]
default-storage-engine=myisam
[aria]
default-storage-engine=aria

View File

@@ -0,0 +1,12 @@
# Storage engine axis for the FULL JOIN tests.
#
# The engine is chosen entirely by the default-storage-engine option in
# full_join_engine.combinations, so nothing has to happen here. The file
# exists because a combinations file becomes an independent axis only when
# it is attached to a sourced include. MTR crosses the combinations of
# each sourced include with those of the test's own combinations file, so
# sourcing this gives every optimizer switch combination one run per
# engine. See mtr_cases.pm, get_tags_from_file and collect_one_test_case.
#
# A create table that names its own engine is unaffected, which is what
# keeps the mixed engine section meaningful under every combination here.

View File

@@ -0,0 +1,3 @@
[noidx]
[allidx]

View File

@@ -0,0 +1,21 @@
# Index axis for the FULL JOIN tests.
#
# Under the allidx combination every column of every base table that is
# not already the first column of some index gains a non-unique index on
# itself. Under noidx nothing happens and the tables keep the indexes
# their CREATE TABLE gave them. The work itself is in
# full_join_add_indexes.inc, which a test sources after each group of
# CREATE TABLE and INSERT statements.
#
# A combinations file becomes an independent axis only when it is
# attached to a sourced include, and MTR crosses the combinations of each
# sourced include with those of the test's own combinations file. So
# sourcing this gives every optimizer switch combination one run with the
# extra indexes and one without. See mtr_cases.pm, get_tags_from_file
# and collect_one_test_case.
#
# Source this file once and once only. The list of combination files a
# test collects is not deduplicated, so a second source of this file adds
# a second axis of the same two values and doubles the number of runs.
# That is why the work lives in a separate include with no combinations
# file of its own, which is then free to be sourced as often as needed.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,468 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,aria,no_flatten_join_nests,noidx.result 2026-09-04 14:59:03
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -966,7 +966,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` join `test`.`t1`) where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -988,7 +988,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1009,7 +1009,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` left join `test`.`t1` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1041,7 +1041,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where `test`.`t1`.`a` is not null
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1053,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1073,7 +1073,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -4511,7 +4511,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL u 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range u u 5 NULL 3 Using where; Using index
+1 MATERIALIZED t2 range u u 5 NULL 4 Using where; Using index
1 MATERIALIZED t3 eq_ref u u 5 test.t2.u 1 Using where; Using index
select t1.u as u1, t2.u as u2, t3.u as u3
from t1 full join (t2 join t3 on t2.u = t3.u) on t1.u = t2.u;
@@ -6204,7 +6204,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6224,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6244,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6265,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6309,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6332,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6355,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6379,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6404,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6431,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6474,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6494,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6517,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6539,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6560,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6583,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6717,7 +6717,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6739,7 +6739,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6761,7 +6761,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6789,7 +6789,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6805,7 +6805,7 @@
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6817,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` join `test`.`t4`) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6876,7 +6876,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (`test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6928,12 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t3` left join (`test`.`t1` left join `test`.`t2` on(1)) on(1)) left join `test`.`t4` on(1)) where `test`.`t3`.`a` <= 1000
drop table t1;
drop table t2;
drop table t3;
@@ -7749,7 +7749,7 @@
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -8131,9 +8131,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8182,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8268,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8404,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8438,11 +8438,11 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 1 60.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8479,7 +8479,7 @@
1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8559,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 1 75.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -9153,7 +9153,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
@@ -9872,10 +9872,10 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,493 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,aria,no_full_join_rewrite,noidx.result 2026-09-04 14:59:21
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t2`.`b`) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -4511,7 +4514,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL u 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range u u 5 NULL 3 Using where; Using index
+1 MATERIALIZED t2 range u u 5 NULL 4 Using where; Using index
1 MATERIALIZED t3 eq_ref u u 5 test.t2.u 1 Using where; Using index
select t1.u as u1, t2.u as u2, t3.u as u3
from t1 full join (t2 join t3 on t2.u = t3.u) on t1.u = t2.u;
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 0.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8438,7 +8448,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 1 60.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8559,8 +8569,8 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t2 range a a 4 NULL 3 20.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 1 75.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
drop table t1;
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,83 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,aria,no_outer_join_to_inner,noidx.result 2026-09-04 14:59:38
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -4511,7 +4511,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL u 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range u u 5 NULL 3 Using where; Using index
+1 MATERIALIZED t2 range u u 5 NULL 4 Using where; Using index
1 MATERIALIZED t3 eq_ref u u 5 test.t2.u 1 Using where; Using index
select t1.u as u1, t2.u as u2, t3.u as u3
from t1 full join (t2 join t3 on t2.u = t3.u) on t1.u = t2.u;
@@ -8438,7 +8438,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 1 60.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8559,8 +8559,8 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t2 range a a 4 NULL 3 20.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 1 75.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
drop table t1;
@@ -8981,8 +8981,8 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,7 +9072,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
@@ -9627,7 +9627,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3

View File

@@ -0,0 +1,791 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,aria,no_simplify_joins,noidx.result 2026-09-04 14:59:55
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1054,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -4511,7 +4514,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL u 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range u u 5 NULL 3 Using where; Using index
+1 MATERIALIZED t2 range u u 5 NULL 4 Using where; Using index
1 MATERIALIZED t3 eq_ref u u 5 test.t2.u 1 Using where; Using index
select t1.u as u1, t2.u as u2, t3.u as u3
from t1 full join (t2 join t3 on t2.u = t3.u) on t1.u = t2.u;
@@ -6204,7 +6207,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6227,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6247,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6268,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6312,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6335,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6358,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6382,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6407,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6434,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6477,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6497,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6520,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6542,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6563,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6586,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 0.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6824,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` left join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7749,7 +7759,7 @@
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8131,9 +8141,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8192,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8278,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8414,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8438,11 +8448,11 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 1 60.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8479,7 +8489,7 @@
1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8569,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 1 75.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,31 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,aria,noidx,simplify_joins.result 2026-09-04 15:00:12
@@ -4511,7 +4511,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL u 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range u u 5 NULL 3 Using where; Using index
+1 MATERIALIZED t2 range u u 5 NULL 4 Using where; Using index
1 MATERIALIZED t3 eq_ref u u 5 test.t2.u 1 Using where; Using index
select t1.u as u1, t2.u as u2, t3.u as u3
from t1 full join (t2 join t3 on t2.u = t3.u) on t1.u = t2.u;
@@ -8438,7 +8438,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 1 60.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8559,8 +8559,8 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t2 range a a 4 NULL 3 20.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 1 75.00 Using where; Using index
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
drop table t1;

View File

@@ -0,0 +1,667 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,innodb,no_flatten_join_nests,noidx.result 2026-09-04 15:00:30
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -966,7 +966,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` join `test`.`t1`) where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -988,7 +988,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1009,7 +1009,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` left join `test`.`t1` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1041,7 +1041,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where `test`.`t1`.`a` is not null
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1053,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1073,7 +1073,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -4113,8 +4113,8 @@
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select t1.id as id1, t2.id as id2
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
@@ -4134,8 +4134,8 @@
# PK join with aggregate.
explain select count(*) from t1 full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select count(*) from t1 full join t2 on t1.id = t2.id;
count(*)
4
@@ -4182,7 +4182,7 @@
explain select count(*) from t1 full join t2 on t1.grp = t2.grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL grp 5 NULL 4 Using index
-1 SIMPLE t2 ref grp grp 5 test.t1.grp 1 Using where; Using index
+1 SIMPLE t2 ref grp grp 5 test.t1.grp 4 Using where; Using index
select count(*) from t1 full join t2 on t1.grp = t2.grp;
count(*)
6
@@ -4231,8 +4231,8 @@
explain select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
a1 b1 a2 b2
@@ -4301,10 +4301,10 @@
explain select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
i1 i2 i4
@@ -4328,9 +4328,9 @@
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
select t1.id as i1, t3.id as i3, t2.id as i2
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
i1 i3 i2
@@ -4355,10 +4355,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t3.id as i3, t2.id as i2, t4.id as i4
from (t1 join t3 on t1.id = t3.id)
full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
@@ -4395,10 +4395,10 @@
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2, t3.b as b3
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
@@ -4431,9 +4431,9 @@
full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join t2 on t1.a = t2.a;
@@ -4464,10 +4464,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join (t2 join t3 as t4 on t2.a = t4.a and t2.b = t4.b)
@@ -6204,7 +6204,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6224,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6244,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6265,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6309,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6332,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6355,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6379,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6404,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6431,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6474,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6494,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6517,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6539,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6560,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6583,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6717,7 +6717,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6739,7 +6739,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6761,7 +6761,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6785,11 +6785,11 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
-1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6805,7 +6805,7 @@
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6817,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` join `test`.`t4`) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6876,7 +6876,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (`test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6928,12 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t3` left join (`test`.`t1` left join `test`.`t2` on(1)) on(1)) left join `test`.`t4` on(1)) where `test`.`t3`.`a` <= 1000
drop table t1;
drop table t2;
drop table t3;
@@ -7543,7 +7543,7 @@
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 index NULL a 5 NULL 3 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
@@ -7744,12 +7744,12 @@
1 PRIMARY b ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.b.col_int_nokey 1 100.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (flat, BNL join)
-3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 100.00
-4 DEPENDENT UNION t3 system NULL NULL NULL NULL 1 100.00
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 100.00
+4 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 1 100.00
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
-2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
+2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 1 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -8131,9 +8131,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8182,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8268,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8404,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8438,11 +8438,11 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 5 40.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8476,10 +8476,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 100.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 4 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8559,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t3 range a a 5 NULL 2 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -9153,7 +9153,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
@@ -9872,10 +9872,10 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a
@@ -10557,8 +10557,8 @@
explain select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
a1 a2
@@ -10581,9 +10581,9 @@
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
select t1.a as a1, t5.a as a5, t2.a as a2
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
a1 a5 a2
@@ -10605,10 +10605,10 @@
explain select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using where; Using index
select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
a1 a2 a4
@@ -10633,10 +10633,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 2 Using where; Using index
select t1.a as a1, t5.a as a5, t2.a as a2, t4.a as a4
from (t1 join t5 on t1.b = t5.b)
full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;

View File

@@ -0,0 +1,722 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,innodb,no_full_join_rewrite,noidx.result 2026-09-04 15:00:49
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t2`.`b`) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -4113,8 +4116,8 @@
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select t1.id as id1, t2.id as id2
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
@@ -4134,8 +4137,8 @@
# PK join with aggregate.
explain select count(*) from t1 full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select count(*) from t1 full join t2 on t1.id = t2.id;
count(*)
4
@@ -4182,7 +4185,7 @@
explain select count(*) from t1 full join t2 on t1.grp = t2.grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL grp 5 NULL 4 Using index
-1 SIMPLE t2 ref grp grp 5 test.t1.grp 1 Using where; Using index
+1 SIMPLE t2 ref grp grp 5 test.t1.grp 4 Using where; Using index
select count(*) from t1 full join t2 on t1.grp = t2.grp;
count(*)
6
@@ -4231,8 +4234,8 @@
explain select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
a1 b1 a2 b2
@@ -4301,10 +4304,10 @@
explain select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
i1 i2 i4
@@ -4328,9 +4331,9 @@
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
select t1.id as i1, t3.id as i3, t2.id as i2
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
i1 i3 i2
@@ -4355,10 +4358,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t3.id as i3, t2.id as i2, t4.id as i4
from (t1 join t3 on t1.id = t3.id)
full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
@@ -4395,10 +4398,10 @@
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2, t3.b as b3
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
@@ -4431,9 +4434,9 @@
full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join t2 on t1.a = t2.a;
@@ -4464,10 +4467,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join (t2 join t3 as t4 on t2.a = t4.a and t2.b = t4.b)
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
-1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6824,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7543,7 +7553,7 @@
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 index NULL a 5 NULL 3 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
@@ -7744,10 +7754,10 @@
1 PRIMARY b ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.b.col_int_nokey 1 100.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (flat, BNL join)
-3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 100.00
-4 DEPENDENT UNION t3 system NULL NULL NULL NULL 1 100.00
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 100.00
+4 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 1 100.00
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
-2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
+2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 1 100.00 Using where; Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8438,7 +8448,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 5 40.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8476,10 +8486,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
+1 MATERIALIZED t3 index a a 5 NULL 4 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8569,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t3 range a a 5 NULL 2 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 40.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a
@@ -10557,8 +10574,8 @@
explain select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
a1 a2
@@ -10581,9 +10598,9 @@
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
select t1.a as a1, t5.a as a5, t2.a as a2
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
a1 a5 a2
@@ -10605,10 +10622,10 @@
explain select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using where; Using index
select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
a1 a2 a4
@@ -10633,10 +10650,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 2 Using where; Using index
select t1.a as a1, t5.a as a5, t2.a as a2, t4.a as a4
from (t1 join t5 on t1.b = t5.b)
full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;

View File

@@ -0,0 +1,341 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,innodb,no_outer_join_to_inner,noidx.result 2026-09-04 15:01:10
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -4113,8 +4113,8 @@
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select t1.id as id1, t2.id as id2
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
@@ -4134,8 +4134,8 @@
# PK join with aggregate.
explain select count(*) from t1 full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select count(*) from t1 full join t2 on t1.id = t2.id;
count(*)
4
@@ -4182,7 +4182,7 @@
explain select count(*) from t1 full join t2 on t1.grp = t2.grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL grp 5 NULL 4 Using index
-1 SIMPLE t2 ref grp grp 5 test.t1.grp 1 Using where; Using index
+1 SIMPLE t2 ref grp grp 5 test.t1.grp 4 Using where; Using index
select count(*) from t1 full join t2 on t1.grp = t2.grp;
count(*)
6
@@ -4231,8 +4231,8 @@
explain select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
a1 b1 a2 b2
@@ -4301,10 +4301,10 @@
explain select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
i1 i2 i4
@@ -4328,9 +4328,9 @@
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
select t1.id as i1, t3.id as i3, t2.id as i2
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
i1 i3 i2
@@ -4355,10 +4355,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t3.id as i3, t2.id as i2, t4.id as i4
from (t1 join t3 on t1.id = t3.id)
full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
@@ -4395,10 +4395,10 @@
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2, t3.b as b3
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
@@ -4431,9 +4431,9 @@
full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join t2 on t1.a = t2.a;
@@ -4464,10 +4464,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join (t2 join t3 as t4 on t2.a = t4.a and t2.b = t4.b)
@@ -6785,9 +6785,9 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
-1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
@@ -6817,13 +6817,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` left join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6928,12 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on(1)) on(1) left join `test`.`t4` on(1) where `test`.`t3`.`a` <= 1000
drop table t1;
drop table t2;
drop table t3;
@@ -7543,7 +7543,7 @@
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 index NULL a 5 NULL 3 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
@@ -7744,10 +7744,10 @@
1 PRIMARY b ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.b.col_int_nokey 1 100.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (flat, BNL join)
-3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 100.00
-4 DEPENDENT UNION t3 system NULL NULL NULL NULL 1 100.00
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 100.00
+4 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 1 100.00
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
-2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
+2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 1 100.00 Using where; Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
@@ -8438,7 +8438,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 5 40.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8476,10 +8476,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
+1 MATERIALIZED t3 index a a 5 NULL 4 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8559,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t3 range a a 5 NULL 2 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 40.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -8981,8 +8981,8 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,7 +9072,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
@@ -9627,7 +9627,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
@@ -10557,8 +10557,8 @@
explain select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
a1 a2
@@ -10581,9 +10581,9 @@
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
select t1.a as a1, t5.a as a5, t2.a as a2
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
a1 a5 a2
@@ -10605,10 +10605,10 @@
explain select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using where; Using index
select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
a1 a2 a4
@@ -10633,10 +10633,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 2 Using where; Using index
select t1.a as a1, t5.a as a5, t2.a as a2, t4.a as a4
from (t1 join t5 on t1.b = t5.b)
full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;

View File

@@ -0,0 +1,986 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,innodb,no_simplify_joins,noidx.result 2026-09-04 15:01:31
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1054,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -4113,8 +4116,8 @@
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select t1.id as id1, t2.id as id2
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
@@ -4134,8 +4137,8 @@
# PK join with aggregate.
explain select count(*) from t1 full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select count(*) from t1 full join t2 on t1.id = t2.id;
count(*)
4
@@ -4182,7 +4185,7 @@
explain select count(*) from t1 full join t2 on t1.grp = t2.grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL grp 5 NULL 4 Using index
-1 SIMPLE t2 ref grp grp 5 test.t1.grp 1 Using where; Using index
+1 SIMPLE t2 ref grp grp 5 test.t1.grp 4 Using where; Using index
select count(*) from t1 full join t2 on t1.grp = t2.grp;
count(*)
6
@@ -4231,8 +4234,8 @@
explain select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
a1 b1 a2 b2
@@ -4301,10 +4304,10 @@
explain select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
i1 i2 i4
@@ -4328,9 +4331,9 @@
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
select t1.id as i1, t3.id as i3, t2.id as i2
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
i1 i3 i2
@@ -4355,10 +4358,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t3.id as i3, t2.id as i2, t4.id as i4
from (t1 join t3 on t1.id = t3.id)
full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
@@ -4395,10 +4398,10 @@
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2, t3.b as b3
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
@@ -4431,9 +4434,9 @@
full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join t2 on t1.a = t2.a;
@@ -4464,10 +4467,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join (t2 join t3 as t4 on t2.a = t4.a and t2.b = t4.b)
@@ -6204,7 +6207,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6227,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6247,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6268,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6312,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6335,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6358,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6382,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6407,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6434,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6477,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6497,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6520,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6542,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6563,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6586,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
-1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6824,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` left join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7543,7 +7553,7 @@
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 index NULL a 5 NULL 3 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
@@ -7744,12 +7754,12 @@
1 PRIMARY b ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.b.col_int_nokey 1 100.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (flat, BNL join)
-3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 100.00
-4 DEPENDENT UNION t3 system NULL NULL NULL NULL 1 100.00
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 100.00
+4 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 1 100.00
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
-2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
+2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 1 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8131,9 +8141,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8192,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8278,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8414,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8438,11 +8448,11 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 5 40.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8476,10 +8486,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 100.00 Using where; Using index
+1 MATERIALIZED t3 ref a a 5 test.t2.a 4 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8569,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t3 range a a 5 NULL 2 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a
@@ -10557,8 +10574,8 @@
explain select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
a1 a2
@@ -10581,9 +10598,9 @@
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
select t1.a as a1, t5.a as a5, t2.a as a2
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
a1 a5 a2
@@ -10605,10 +10622,10 @@
explain select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using where; Using index
select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
a1 a2 a4
@@ -10633,10 +10650,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 2 Using where; Using index
select t1.a as a1, t5.a as a5, t2.a as a2, t4.a as a4
from (t1 join t5 on t1.b = t5.b)
full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;

View File

@@ -0,0 +1,289 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,innodb,noidx,simplify_joins.result 2026-09-04 15:01:50
@@ -4113,8 +4113,8 @@
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select t1.id as id1, t2.id as id2
from t1 full join t2 on t1.id = t2.id
where coalesce(t1.id, t2.id) > 2;
@@ -4134,8 +4134,8 @@
# PK join with aggregate.
explain select count(*) from t1 full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
select count(*) from t1 full join t2 on t1.id = t2.id;
count(*)
4
@@ -4182,7 +4182,7 @@
explain select count(*) from t1 full join t2 on t1.grp = t2.grp;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL grp 5 NULL 4 Using index
-1 SIMPLE t2 ref grp grp 5 test.t1.grp 1 Using where; Using index
+1 SIMPLE t2 ref grp grp 5 test.t1.grp 4 Using where; Using index
select count(*) from t1 full join t2 on t1.grp = t2.grp;
count(*)
6
@@ -4231,8 +4231,8 @@
explain select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 3 Using index
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2
from t1 full join t2 on t1.a = t2.a;
a1 b1 a2 b2
@@ -4301,10 +4301,10 @@
explain select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t2.id as i2, t4.id as i4
from t1 full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
i1 i2 i4
@@ -4328,9 +4328,9 @@
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where; Using index
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.id 1 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
select t1.id as i1, t3.id as i3, t2.id as i2
from (t1 join t3 on t1.id = t3.id) full join t2 on t1.id = t2.id;
i1 i3 i2
@@ -4355,10 +4355,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t3 index NULL PRIMARY 4 NULL 3 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where; Using index
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using where
select t1.id as i1, t3.id as i3, t2.id as i2, t4.id as i4
from (t1 join t3 on t1.id = t3.id)
full join (t2 join t4 on t2.id = t4.id) on t1.id = t2.id;
@@ -4395,10 +4395,10 @@
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t3 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t2.a as a2, t2.b as b2, t3.b as b3
from t1 full join (t2 join t3 on t2.a = t3.a and t2.b = t3.b)
on t1.a = t2.a;
@@ -4431,9 +4431,9 @@
full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 3 Using where
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join t2 on t1.a = t2.a;
@@ -4464,10 +4464,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t3 index NULL PRIMARY 8 NULL 3 Using index
-1 MATERIALIZED t1 index NULL PRIMARY 8 NULL 4 Using index
-1 MATERIALIZED t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index
-1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where; Using index
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 4
+1 MATERIALIZED t2 ALL PRIMARY NULL NULL NULL 3 Using where
+1 MATERIALIZED t4 eq_ref PRIMARY PRIMARY 8 test.t2.a,test.t2.b 1 Using where
select t1.a as a1, t1.b as b1, t3.b as b3, t2.a as a2, t2.b as b2
from (t1 join t3 on t1.a = t3.a and t1.b = t3.b)
full join (t2 join t3 as t4 on t2.a = t4.a and t2.b = t4.b)
@@ -6785,9 +6785,9 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
-1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
@@ -6817,13 +6817,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` join `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6928,12 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on(1)) on(1) left join `test`.`t4` on(1) where `test`.`t3`.`a` <= 1000
drop table t1;
drop table t2;
drop table t3;
@@ -7543,7 +7543,7 @@
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 index NULL a 5 NULL 3 Using index
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t1.pk, t1.a, t2.b from t1 full join t2 on t2.b = t1.a
where t1.a = 20 or t1.a is null;
@@ -7744,10 +7744,10 @@
1 PRIMARY b ALL NULL NULL NULL NULL 20 100.00 Using temporary; Using filesort
1 PRIMARY c eq_ref PRIMARY PRIMARY 4 test.b.col_int_nokey 1 100.00 Using where
1 PRIMARY a ALL NULL NULL NULL NULL 20 100.00 Using where; Using join buffer (flat, BNL join)
-3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 1 100.00
-4 DEPENDENT UNION t3 system NULL NULL NULL NULL 1 100.00
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 1 100.00
+4 DEPENDENT UNION t3 ALL NULL NULL NULL NULL 1 100.00
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
-2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
+2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 1 100.00 Using where; Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
@@ -8438,7 +8438,7 @@
from (t1 join t3 on t1.a = t3.a) full join t2 on t1.a = t2.a and t2.a > 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t2 ref a a 4 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 4 test.t1.a 5 40.00 Using where; Using index
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
@@ -8476,10 +8476,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
+1 MATERIALIZED t3 index a a 5 NULL 4 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8559,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
-1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
+1 MATERIALIZED t3 range a a 5 NULL 2 100.00 Using where; Using index
+1 MATERIALIZED t2 ref a a 4 test.t3.a 5 40.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -10557,8 +10557,8 @@
explain select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
select t1.a as a1, t2.a as a2
from t1 full join t2 on t1.a = t2.a;
a1 a2
@@ -10581,9 +10581,9 @@
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
-1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 Using where
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
select t1.a as a1, t5.a as a5, t2.a as a2
from (t1 join t5 on t1.b = t5.b) full join t2 on t1.a = t2.a;
a1 a5 a2
@@ -10605,10 +10605,10 @@
explain select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 index NULL t1_b 5 NULL 3 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using where; Using index
select t1.a as a1, t2.a as a2, t4.a as a4
from t1 full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;
a1 a2 a4
@@ -10633,10 +10633,10 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
-1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
-1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using index condition
-1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 1 Using index condition
+1 MATERIALIZED t1 index NULL t1_b 5 NULL 3 Using index
+1 MATERIALIZED t5 index NULL t5_b 5 NULL 3 Using index
+1 MATERIALIZED t2 range PRIMARY,t2_b t2_b 5 NULL 3 Using where; Using index
+1 MATERIALIZED t4 ref t4_b t4_b 5 test.t2.b 2 Using where; Using index
select t1.a as a1, t5.a as a5, t2.a as a2, t4.a as a4
from (t1 join t5 on t1.b = t5.b)
full join (t2 join t4 on t2.b = t4.b) on t1.a = t2.a;

View File

@@ -0,0 +1,453 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,myisam,no_flatten_join_nests,noidx.result 2026-09-04 15:02:09
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -966,7 +966,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` join `test`.`t1`) where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -988,7 +988,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1009,7 +1009,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t2` left join `test`.`t1` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1041,7 +1041,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where `test`.`t1`.`a` is not null
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1053,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1073,7 +1073,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -6204,7 +6204,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6224,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6244,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6265,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6309,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6332,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6355,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6379,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6404,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6431,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6474,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6494,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6517,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6539,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6560,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6583,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6717,7 +6717,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6739,7 +6739,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6761,7 +6761,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6789,7 +6789,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (`test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6805,7 +6805,7 @@
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6817,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` join `test`.`t4`) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6876,7 +6876,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (`test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6928,12 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (incremental, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t3` left join (`test`.`t1` left join `test`.`t2` on(1)) on(1)) left join `test`.`t4` on(1)) where `test`.`t3`.`a` <= 1000
drop table t1;
drop table t2;
drop table t3;
@@ -7749,7 +7749,7 @@
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -8131,9 +8131,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8182,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8268,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8404,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8442,7 +8442,7 @@
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8479,7 +8479,7 @@
1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8559,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -9153,7 +9153,7 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
@@ -9872,10 +9872,10 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,464 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,myisam,no_full_join_rewrite,noidx.result 2026-09-04 15:02:26
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t2`.`b`) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 0.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t1` full join `test`.`t4` on(1) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,54 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,myisam,no_outer_join_to_inner,noidx.result 2026-09-04 15:02:43
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -8981,8 +8981,8 @@
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (incremental, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,7 +9072,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
@@ -9627,7 +9627,7 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3

View File

@@ -0,0 +1,776 @@
--- full_join.result 2026-09-04 15:04:29
+++ full_join,myisam,no_simplify_joins,noidx.result 2026-09-04 15:03:00
@@ -34,7 +34,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
select * from t1 full outer join t2 on t1.a = t2.a;
a a
1 1
@@ -50,7 +50,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a`)) where 1
# NATURAL FULL [OUTER] JOIN.
select * from t1 natural full outer join t2;
a
@@ -67,7 +67,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
select * from t1 natural full join t2;
a
1
@@ -83,7 +83,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1
# FULL JOIN inside a view.
create view v1 as select t1.a as t1a, t2.a as t2a from t1 full join t2 on t1.a = t2.a;
select * from v1;
@@ -200,7 +200,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
select * from (select t1.a from t1 natural full outer join t2 union select * from t1) dt;
a
1
@@ -219,7 +219,7 @@
3 UNION t1 ALL NULL NULL NULL NULL 2 100.00
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
+Note 1003 /* select#1 */ select `dt`.`a` AS `a` from (/* select#2 */ select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)) where 1 union /* select#3 */ select `test`.`t1`.`a` AS `a` from `test`.`t1`) `dt`
# FULL JOIN inside a CTE.
with cte as (select t1.a from t1 natural full join t2) select * from cte;
a
@@ -236,7 +236,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))select `test`.`t1`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`) where 1
+Note 1003 with cte as (select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`)))select `test`.`t1`.`a` AS `a` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a`))) where 1
# FULL JOIN referencing a missing table must error cleanly.
select * from t1, t2 full join t_not_exist on t2.c=t_not_exist.e and t_not_exist.f=t1.a;
ERROR 42S02: Table 'test.t_not_exist' doesn't exist
@@ -557,8 +557,8 @@
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null and t2.pk is not null;
pk x y pk x y
6 0 0 6 0 0
-7 1 1 6 0 0
6 0 0 7 1 1
+7 1 1 6 0 0
7 1 1 7 1 1
select * from t1 inner join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1;
pk x y pk x y
@@ -569,15 +569,15 @@
# FULL to LEFT JOIN, these two queries should be equal:
select * from t1 full join t2 on t1.x >= 0 and t1.x <= 1 and t2.x >= 0 and t2.x <= 1 where t1.pk is not null;
pk x y pk x y
-6 0 0 6 0 0
-7 1 1 6 0 0
-6 0 0 7 1 1
-7 1 1 7 1 1
1 -5 -5 NULL NULL NULL
2 -4 -4 NULL NULL NULL
3 -3 -3 NULL NULL NULL
4 -2 -2 NULL NULL NULL
5 -1 -1 NULL NULL NULL
+6 0 0 6 0 0
+6 0 0 7 1 1
+7 1 1 6 0 0
+7 1 1 7 1 1
8 2 2 NULL NULL NULL
9 3 3 NULL NULL NULL
10 4 4 NULL NULL NULL
@@ -636,13 +636,13 @@
# FULL NATURAL to RIGHT JOIN
select * from t1 natural full join t2 where t2.pk is not null;
pk x y
+6 0 0
+7 1 1
1 -5 25
2 -4 16
3 -3 9
4 -2 4
5 -1 1
-6 0 0
-7 1 1
8 2 4
9 3 9
10 4 16
@@ -963,10 +963,10 @@
t1.a is not null and t1.b is not null and
t2.a is not null and t2.b is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` join `test`.`t1` where `test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null and `test`.`t1`.`a` is not null and `test`.`t1`.`b` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null and `test`.`t2`.`b` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 join t1 where
t2.a = t1.a and t2.b = t1.b and
@@ -985,10 +985,10 @@
2 2
explain extended select * from t1 natural full join t2 where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where t1.a is not null;
a b
@@ -1006,10 +1006,10 @@
3 3
explain extended select * from t1 natural full join t2 where t2.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`b` = `test`.`t2`.`b`) where `test`.`t2`.`a` is not null
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where `test`.`t2`.`a` is not null
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b from
t2 left join t1 on t1.a = t2.a and t1.b = t2.b where t2.a is not null;
a b
@@ -1037,11 +1037,12 @@
explain extended select t1.a from
t1 natural full join (t2 natural join t3) where t1.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t3`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t2`.`b` = `test`.`t3`.`b`)) where 1
select t1.a AS a from t1 left join (t2 join t3) on
t2.a = t1.a and t3.a = t1.a and t2.b = t1.b and t3.b = t1.b where
t1.a is not null;
@@ -1053,7 +1054,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where 1 group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select *, avg(t2.a) from t1 natural full join t2 where t1.a is not null group by t1.a;
a b avg(t2.a)
1 1 1.0000
@@ -1070,10 +1071,10 @@
explain extended select *, avg(t2.a) from t1 natural full join t2 where
t1.a is not null group by t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`) where `test`.`t1`.`a` is not null group by `test`.`t1`.`a`
+Note 1003 select coalesce(`test`.`t1`.`a`,`test`.`t2`.`a`) AS `a`,coalesce(`test`.`t1`.`b`,`test`.`t2`.`b`) AS `b`,avg(`test`.`t2`.`a`) AS `avg(t2.a)` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t2`.`b` = `test`.`t1`.`b`)) where 1 group by `test`.`t1`.`a`
select coalesce(t1.a, t2.a) AS a, coalesce(t1.b, t2.b) AS b,
avg(t2.a) AS avg_t2_a from
t1 left join t2 on t2.a = t1.a and t2.b = t1.b where
@@ -3153,11 +3154,13 @@
from fj a join fj b on a.id1 = b.id1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
with fj as (
select t1.id as id1, t2.id as id2, t5.id as id5
from t1 full join (t2 join t5 on t2.id = t5.id) on t1.id = t2.id
@@ -6204,7 +6207,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6224,7 +6227,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t3`,`t1`,`t2`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t3,t1,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6244,7 +6247,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`) */ `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t2,t3) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6265,7 +6268,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t3`.`c` AS `c`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t3` join (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`))) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_order(t1,t3,t2) */ *
from t3 inner join (t1 full join t2 on t1.a=t2.b)
on (t3.c=t1.a or t2.b=5);
@@ -6309,7 +6312,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6332,7 +6335,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t1`,`t2`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t1,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6355,7 +6358,7 @@
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t1`,`t2`,`t3`,`t4`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t3,t4) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6379,7 +6382,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
-Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
+Note 1003 select /*+ JOIN_ORDER(@`select#1` `t4`,`t2`,`t1`,`t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t3`.`c` = `test`.`t4`.`d` or `test`.`t4`.`d` = 5
select /*+ join_order(t4,t2,t1,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6404,7 +6407,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t4`,`t2`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t4,t2,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6431,7 +6434,7 @@
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Warning 4219 Hint JOIN_ORDER(`t1`,`t2`,`t4`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from ((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4` where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c`,`test`.`t4`.`d` AS `d` from (((`test`.`t1` join `test`.`t2`) full join `test`.`t3` on(`test`.`t3`.`c` = `test`.`t1`.`a`)) join `test`.`t4`) where `test`.`t4`.`d` = `test`.`t3`.`c` or `test`.`t4`.`d` = 5
select /*+ join_order(t1,t2,t4,t3) */ *
from ((t1, t2) full join t3 on t3.c=t1.a) inner join t4
on (t4.d=t3.c or t4.d=5);
@@ -6474,7 +6477,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6494,7 +6497,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_PREFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6517,7 +6520,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_PREFIX(`t1`,`t3`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_prefix(t1, t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6539,7 +6542,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
1 SIMPLE t3 ALL NULL NULL NULL NULL 4 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t3`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t3`.`c` = `test`.`t1`.`a` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6560,7 +6563,7 @@
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
-Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select /*+ JOIN_SUFFIX(@`select#1` `t1`,`t2`) */ `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t1, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6583,7 +6586,7 @@
1 SIMPLE t2 ALL NULL NULL NULL NULL 6 100.00 Using where
Warnings:
Warning 4219 Hint JOIN_SUFFIX(`t3`,`t2`) is ignored as conflicting/duplicated
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3` where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`c` AS `c` from ((`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`b`)) join `test`.`t3`) where `test`.`t1`.`a` = `test`.`t3`.`c` or `test`.`t2`.`b` = 5
select /*+ join_suffix(t3, t2) */ *
from (t1 full join t2 on t1.a=t2.b) inner join t3
on (t3.c=t1.a or t2.b=5);
@@ -6711,13 +6714,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# IS NOT NULL drives the same rewrite path.
select t1.a, t2.a, t3.a, t4.a
from t1 left join t2 on (true)
@@ -6733,13 +6737,14 @@
full join t4 on (true)
where t4.a is not null;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` is not null
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` is not null
# RIGHT JOIN canonicalizes to LEFT JOIN, same trigger applies.
select t1.a, t2.a, t3.a, t4.a
from t1 right join t2 on (true)
@@ -6755,13 +6760,14 @@
full join t4 on (true)
where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join ((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (((`test`.`t2` left join `test`.`t1` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
# Reproducer matching the original ticket. All left tables are
# empty so only null complement rows for t4 reach the WHERE,
# and GROUP BY collapses them.
@@ -6783,13 +6789,14 @@
where t4.a <= 3000
group by field1;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using temporary; Using filesort
-1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 0 0.00 Using where
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using temporary; Using filesort
+1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 0 0.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 0 0.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `field1` from `test`.`t4` left join ((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) on(1) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
+Note 1003 select `test`.`t1`.`a` AS `field1` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 group by `test`.`t1`.`a`
# The guard must not block the normal FULL JOIN rewrite when
# the left side is a base table. A plain t1 FULL JOIN t4 with
# the same WHERE predicate still rewrites and the UNION oracle
@@ -6802,10 +6809,10 @@
explain extended
select t1.a, t4.a from t1 full join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 100.00 Using where
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` full join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000
select t1.a, t4.a from t1 left join t4 on (true) where t4.a <= 3000
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
@@ -6817,13 +6824,13 @@
union
select t1.a, t4.a from t1 right join t4 on (true) where t4.a <= 3000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
-1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00
+1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
2 UNION t4 ALL NULL NULL NULL NULL 2 100.00 Using where
2 UNION t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL
Warnings:
-Note 1003 /* select#1 */ select 1 AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from `test`.`t4` left join `test`.`t1` on(1) where `test`.`t4`.`a` <= 3000
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t1` left join `test`.`t4` on(1)) where `test`.`t4`.`a` <= 3000 union /* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t4`.`a` AS `a` from (`test`.`t4` left join `test`.`t1` on(1)) where `test`.`t4`.`a` <= 3000
drop table t1;
drop table t2;
drop table t3;
@@ -6866,17 +6873,18 @@
full join t6 on (true)
where t6.a <= 300000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
-1 SIMPLE t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 SIMPLE t6 ALL NULL NULL NULL NULL 2 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t4 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from `test`.`t6` left join ((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) on(1) where `test`.`t6`.`a` <= 300000
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t4`.`a` AS `a`,`test`.`t5`.`a` AS `a`,`test`.`t6`.`a` AS `a` from (((((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) full join `test`.`t5` on(1)) full join `test`.`t6` on(1)) where `test`.`t6`.`a` <= 300000
drop table t1;
drop table t2;
drop table t3;
@@ -6928,12 +6936,14 @@
full join t4 on (true)
where t3.a <= 1000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 system NULL NULL NULL NULL 1 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1 100.00 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00
+1 SIMPLE t4 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED <derived> ALL NULL NULL NULL NULL 0 0.00
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 1 100.00 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 1 100.00 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a` from (`test`.`t1` left join `test`.`t2` on(1)) left join `test`.`t4` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a` from (((`test`.`t1` left join `test`.`t2` on(1)) full join `test`.`t3` on(1)) full join `test`.`t4` on(1)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -7749,7 +7759,7 @@
2 SUBQUERY s1 index NULL col_varchar_key 12 NULL 20 100.00 Using index
2 SUBQUERY s2 ref col_varchar_key col_varchar_key 7 test.s1.col_varchar_key 3 100.00 Using where; Using index
Warnings:
-Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from `test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from (`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
+Note 1003 /* select#1 */ select `test`.`a`.`col_int_nokey` AS `field1`,(/* select#2 */ select count(`test`.`s2`.`col_varchar_key`) from (`test`.`t2` `s1` full join `test`.`t2` `s2` on(`test`.`s2`.`col_varchar_key` = `test`.`s1`.`col_varchar_key` and `test`.`s1`.`col_varchar_key` is not null)) where 1) AS `field2`,`test`.`a`.`col_int_key` AS `field3`,`test`.`a`.`pk` AS `field4`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) AS `field5` from ((`test`.`t1` `b` full join `test`.`t1` `c` on(`test`.`c`.`pk` = `test`.`b`.`col_int_nokey` and `test`.`b`.`col_int_nokey` is not null)) left join `test`.`t1` `a` on(`test`.`c`.`col_int_nokey` = `test`.`b`.`pk`)) where 1 order by `test`.`a`.`col_int_key`,`test`.`a`.`col_int_nokey`,`test`.`a`.`pk`,concat(`test`.`a`.`col_varchar_key`,`test`.`a`.`col_varchar_nokey`) limit 2
drop table t1;
drop table t2;
drop table t3;
@@ -7928,8 +7938,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 left join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7954,8 +7964,8 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3 inner join (t1 full join t2 on t1.a = t2.b)
on t3.c = t1.a;
c a b
@@ -7965,8 +7975,8 @@
where t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from t3, (t1 full join t2 on t1.a = t2.b)
where t3.c = t1.a;
c a b
@@ -7990,8 +8000,8 @@
on t1.a = t3.c;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
select * from (t1 full join t2 on t1.a = t2.b) right join t3
on t1.a = t3.c;
a b c
@@ -8019,9 +8029,9 @@
on t3.c = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3b ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
+1 SIMPLE t3b ALL NULL NULL NULL NULL 2
select * from t3 left join ((t1 full join t2 on t1.a = t2.b) join t3 t3b)
on t3.c = t1.a;
c a b c
@@ -8131,9 +8141,9 @@
select t1.a, t2.a from t1 full join t2 on t1.a = t2.a and t1.a < 3;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 5 100.00 Using index
-1 SIMPLE t2 ref a a 5 test.t1.a 1 40.00 Using where; Using index
+1 SIMPLE t2 ref a a 5 test.t1.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t1`.`a` < 3 and `test`.`t1`.`a` is not null)) where 1
# Impossible ON range on an indexed column. There are no matches, so
# every row is null-complemented; the impossible range must not fold
# the FULL JOIN to an empty result.
@@ -8182,7 +8192,7 @@
1 SIMPLE t1 index NULL a 5 NULL 3 100.00 Using index
1 SIMPLE t2 index NULL b 5 NULL 3 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` full join `test`.`t2` on(1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from (`test`.`t1` full join `test`.`t2` on(1)) where 1
select * from t1 natural full join t2;
a b
1 1
@@ -8268,7 +8278,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index NULL a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(1 = 1) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(1 = 1)) where 1
# ON true: same shape with the boolean literal.
explain select t1.a, t2.a from t1 full join t2 on true;
id select_type table type possible_keys key key_len ref rows Extra
@@ -8404,7 +8414,7 @@
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE t2 index a a 4 NULL 5 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from `test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a` from (`test`.`t1` full join `test`.`t2` on(`test`.`t2`.`a` is not null and `test`.`t1`.`a` < 3)) where 1
# A sargable range in the ON of a FULL JOIN whose left operand is a
# nested join. Range analysis reaches an indexed column of a table
# inside the nest, and every row of both sides must still survive.
@@ -8442,7 +8452,7 @@
1 MATERIALIZED t3 index NULL a 5 NULL 4 100.00 Using index
1 MATERIALIZED t1 index NULL a 4 NULL 5 100.00 Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from (`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t1`.`a` > 3 and `test`.`t1`.`a` is not null) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t3`.`a` AS `a3`,`test`.`t2`.`a` AS `a2` from ((`test`.`t1` join `test`.`t3`) full join `test`.`t2` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t1`.`a` is not null)) where 1
# The same range with the nested join on the right. The nest is
# computed into a temporary table, so an access path built from the ON
# would leave rows out of the temporary table that the FULL JOIN still
@@ -8479,7 +8489,7 @@
1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 100.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3 and `test`.`t2`.`a` = `test`.`t3`.`a`)) where 1
# A range over the left operand's column, which reaches the columns of
# the nest through the equality in the same ON expression.
select t1.a as a1, t2.a as a2, t3.a as a3
@@ -8559,10 +8569,10 @@
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 index NULL a 4 NULL 5 100.00 Using index
1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 0.00 Using where
-1 MATERIALIZED t2 range a a 4 NULL 2 20.00 Using where; Using index
+1 MATERIALIZED t2 index a a 4 NULL 5 20.00 Using where; Using index
1 MATERIALIZED t3 ref a a 5 test.t2.a 1 50.00 Using where; Using index
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from `test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`a` = `test`.`t1`.`a` and `test`.`t3`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` > 3) where 1
+Note 1003 select `test`.`t1`.`a` AS `a1`,`test`.`t2`.`a` AS `a2`,`test`.`t3`.`a` AS `a3` from (`test`.`t1` full join (`test`.`t2` join `test`.`t3`) on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` = `test`.`t3`.`a` and `test`.`t3`.`a` > 3)) where 1
drop table t1;
drop table t2;
drop table t3;
@@ -8622,10 +8632,12 @@
on t1.a=t2.a
where t1.a > 0;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t3 ALL NULL NULL NULL NULL 2
select t1.a, t4.a
from (t1 join t4 on t1.a=t4.a) full join (t2 join t3 on t2.a=t3.a)
on t1.a=t2.a
@@ -8826,9 +8838,9 @@
left join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
left join t3 on t3.a = t2.a;
@@ -8920,9 +8932,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 left join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -8951,9 +8964,9 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 right join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
right join t3 on t3.a = t2.a;
@@ -8980,9 +8993,10 @@
right join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3
from (t1 right join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
right join t3 on t3.a = t2.a;
@@ -9072,9 +9086,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 inner join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9152,9 +9166,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 inner join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9627,9 +9642,9 @@
inner join t3 on t3.a = t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t3.a as a3
from t5 left join (t1 full join t2 on t1.a = t2.a) on t5.a = t1.a
inner join t3 on t3.a = t2.a;
@@ -9842,9 +9857,10 @@
on t5.a = t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 3
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (incremental, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0 Using where
+1 MATERIALIZED t2 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 Using where
select t5.a as a5, t1.a as a1, t2.a as a2, t4.a as a4
from t5 inner join
(t1 full join (t2 left join t4 on t2.a = t4.a) on t1.a = t2.a)
@@ -9872,10 +9888,11 @@
cross join t4;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 ALL NULL NULL NULL NULL 2
+1 SIMPLE <derived> ALL NULL NULL NULL NULL 0
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t4 ALL NULL NULL NULL NULL 2 Using join buffer (flat, BNL join)
-1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
-1 SIMPLE t5 ALL NULL NULL NULL NULL 3 Using where; Using join buffer (incremental, BNL join)
+1 MATERIALIZED t1 ALL NULL NULL NULL NULL 3
+1 MATERIALIZED t5 ALL NULL NULL NULL NULL 3 Using where
select t1.a as a1, t5.a as a5, t2.a as a2, t3.a as a3, t4.a as a4
from (t1 left join t5 on t1.a = t5.a) full join t2 on t1.a = t2.a
inner join t3 on t3.a = t2.a

View File

@@ -0,0 +1,29 @@
# The optimizer switch axis of the FULL JOIN tests. One run has the join
# simplification pass allowed to transform the join tree, the others hold
# back one transformation each, so the plans for every query in the file
# can be compared side by side.
#
# This axis is crossed with the engine axis of full_join_engine.combinations
# and the index axis of full_join_index.combinations. The expected output
# of a run is a diff against the result file of the run that holds every
# default, which keeps the comparison to the lines that actually change.
#
# Every run answers every query correctly, so a diff holds plan lines, the
# rewritten query an EXPLAIN EXTENDED prints, and row ordering. Any row
# that appears on one side of a diff and not the other is a defect in the
# run it comes from.
[simplify_joins]
optimizer_switch=simplify_joins=on
[no_simplify_joins]
optimizer_switch=simplify_joins=off
[no_outer_join_to_inner]
optimizer_switch=outer_join_to_inner=off
[no_full_join_rewrite]
optimizer_switch=full_join_rewrite=off
[no_flatten_join_nests]
optimizer_switch=flatten_join_nests=off

View File

@@ -1885,23 +1885,23 @@ create view vf as
select t1.a as a, t1.b as b, t2.c as c from t1 full join t2 on t1.a = t2.a;
select * from vf natural full join t3 order by a;
a b c d
NULL NULL 500 NULL
NULL NULL 600 NULL
1 10 NULL NULL
2 20 200 NULL
4 NULL NULL 4000
5 NULL NULL 5000
NULL NULL 500 NULL
NULL NULL 600 NULL
select coalesce(dt.a, t3.a) as a, dt.b, dt.c, t3.d
from (select t1.a as a, t1.b as b, t2.c as c
from t1 full join t2 on t1.a = t2.a) dt
full join t3 on dt.a = t3.a order by a;
a b c d
NULL NULL 500 NULL
NULL NULL 600 NULL
1 10 NULL NULL
2 20 200 NULL
4 NULL NULL 4000
5 NULL NULL 5000
NULL NULL 500 NULL
NULL NULL 600 NULL
drop view v1, v12, vf;
# A nested join on each side of a NATURAL FULL JOIN. The common
# columns are those the two nests share, and the COALESCE the
@@ -11170,6 +11170,201 @@ count(*)
2010
drop table t1, t2;
# ====================================================================
# Section 31: A WHERE clause the nest holds only part of
# ====================================================================
#
# A predicate over nothing but a nest beside a FULL JOIN is held back
# from the plan and checked once the nest has produced a row, which
# Section 27 covers on its own. Here the WHERE also carries
# predicates over a table outside the FULL JOIN. Those stay in the
# WHERE and the reduced WHERE has to be rebuilt around them, once as
# the single predicate that is left and once as a conjunction of two.
create table t1 (a int, b int);
create table t2 (a int, b int);
create table t3 (b int, c int);
create table t4 (x int, y int);
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1,1),(2,2),(4,4);
insert into t3 values (1,1),(2,2),(5,5);
insert into t4 values (1,1),(2,2);
select * from t1 full join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0;
a b a b b c x y
2 2 2 2 2 2 1 1
2 2 2 2 2 2 2 2
3 3 NULL NULL NULL NULL 1 1
3 3 NULL NULL NULL NULL 2 2
select * from t1 left join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0
union
select * from t1 right join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0;
a b a b b c x y
2 2 2 2 2 2 1 1
2 2 2 2 2 2 2 2
3 3 NULL NULL NULL NULL 1 1
3 3 NULL NULL NULL NULL 2 2
select * from t1 full join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0 and t4.y < 100;
a b a b b c x y
2 2 2 2 2 2 1 1
2 2 2 2 2 2 2 2
3 3 NULL NULL NULL NULL 1 1
3 3 NULL NULL NULL NULL 2 2
select * from t1 left join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0 and t4.y < 100
union
select * from t1 right join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a, t4
where (t3.c is null or t3.c > 1) and t4.x > 0 and t4.y < 100;
a b a b b c x y
2 2 2 2 2 2 1 1
2 2 2 2 2 2 2 2
3 3 NULL NULL NULL NULL 1 1
3 3 NULL NULL NULL NULL 2 2
drop table t1;
drop table t2;
drop table t3;
drop table t4;
# ====================================================================
# Section 32: A left side predicate the right partner cannot check
# ====================================================================
#
# A WHERE predicate over the left side of a surviving FULL JOIN is
# held back and checked on the right partner, so that the match is
# recorded before the predicate can reject the row. A predicate that
# also reads a table the plan places after the right partner cannot be
# checked there, since that table has not been read yet, and it goes
# back into the WHERE. t3 is large enough that the plan places it
# last. The second query leaves two predicates behind, so the WHERE
# the predicate returns to is a conjunction and the predicate joins
# the conjunction that is already there.
create table t1 (a int, b int);
create table t2 (a int, b int);
create table t3 (x int, y int);
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1,1),(2,2),(4,4);
insert into t3 select seq, seq from seq_1_to_200;
select count(*) from t1 full join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1);
count(*)
800
select count(*) from
(select t1.a as a1, t2.a as a2, t3.x as x from t1 left join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1)
union
select t1.a, t2.a, t3.x from t1 right join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1)) d;
count(*)
800
select count(*) from t1 full join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1) and t3.x > 0 and t3.y < 1000;
count(*)
800
select count(*) from
(select t1.a as a1, t2.a as a2, t3.x as x from t1 left join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1) and t3.x > 0 and t3.y < 1000
union
select t1.a, t2.a, t3.x from t1 right join t2 on t1.a = t2.a, t3
where (t1.b is null or t1.b + t3.x > 1) and t3.x > 0 and t3.y < 1000) d;
count(*)
800
# A predicate over both sides stays in the WHERE. Distributing the
# WHERE over the plan still takes from each disjunct the part the
# left table alone decides and ORs those parts together, and that
# condition is none of the WHERE's conjuncts. It names the left
# side alone, so it waits for the match too.
select * from t1 full join t2 on t1.a = t2.a
where (t1.b = 1 and t2.b = 1) or t1.a is null;
a b a b
1 1 1 1
NULL NULL 4 4
select * from t1 left join t2 on t1.a = t2.a
where (t1.b = 1 and t2.b = 1) or t1.a is null
union
select * from t1 right join t2 on t1.a = t2.a
where (t1.b = 1 and t2.b = 1) or t1.a is null;
a b a b
1 1 1 1
NULL NULL 4 4
drop table t1;
drop table t2;
drop table t3;
# ====================================================================
# Section 33: A nest whose temporary table outgrows the heap
# ====================================================================
#
# The nest beside a FULL JOIN is computed into a temporary table that
# starts out in memory. A nest wider and longer than the memory limit
# allows has to be moved to disk partway through, which is a path the
# small tables everywhere else in this file never reach. The limits
# are lowered for the query and put back afterwards.
create table t1 (a int);
create table t2 (b int, pad char(200));
create table t3 (b int, c int);
insert into t1 values (1),(2),(3);
insert into t2 select seq, repeat('x',200) from seq_1_to_150;
insert into t3 select seq, seq from seq_1_to_150;
set @save_tmp_table_size= @@tmp_table_size;
set @save_max_heap_table_size= @@max_heap_table_size;
set tmp_table_size= 16384;
set max_heap_table_size= 16384;
select count(*), sum(length(t2.pad)) from
t1 full join (t2 join t3 on t2.b = t3.b) on t1.a = t2.b;
count(*) sum(length(t2.pad))
150 30000
select count(*), sum(length(pad)) from
(select t1.a as a, t2.b as b, t3.c as c, t2.pad as pad
from t1 left join (t2 join t3 on t2.b = t3.b) on t1.a = t2.b
union
select t1.a, t2.b, t3.c, t2.pad
from t1 right join (t2 join t3 on t2.b = t3.b) on t1.a = t2.b) d;
count(*) sum(length(pad))
150 30000
set tmp_table_size= @save_tmp_table_size;
set max_heap_table_size= @save_max_heap_table_size;
drop table t1;
drop table t2;
drop table t3;
# ====================================================================
# Section 34: The name a nest is traced under
# ====================================================================
#
# The optimizer trace names every table it considers. A nest beside a
# FULL JOIN has no name of its own and the temporary table it is
# computed into does not exist yet when the join order is traced, so
# the trace uses the name EXPLAIN gives it. Nothing else in this file
# turns the trace on, so the query is run twice, once for the row set
# and once for what the trace holds.
create table t1 (a int, b int);
create table t2 (a int, b int);
create table t3 (b int, c int);
insert into t1 values (1,1),(2,2),(3,3);
insert into t2 values (1,1),(2,2),(4,4);
insert into t3 values (1,1),(2,2),(5,5);
select * from t1 full join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a;
a b a b b c
1 1 1 1 1 1
2 2 2 2 2 2
3 3 NULL NULL NULL NULL
select * from t1 left join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a
union
select * from t1 right join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a;
a b a b b c
1 1 1 1 1 1
2 2 2 2 2 2
3 3 NULL NULL NULL NULL
set @save_optimizer_trace= @@optimizer_trace;
set optimizer_trace='enabled=on';
select * from t1 full join (t2 join t3 on t2.b = t3.b) on t1.a = t2.a;
select trace like '%<derived>%' as nest_named
from information_schema.optimizer_trace;
nest_named
1
set optimizer_trace= @save_optimizer_trace;
drop table t1;
drop table t2;
drop table t3;
# ====================================================================
# Section 35: An ON expression below the top of a nest operand
# ====================================================================
#

File diff suppressed because it is too large Load Diff