Commit 9a6aefab authored by timour@mysql.com's avatar timour@mysql.com

Fix for BUG#6276.

parent 2f2347e5
......@@ -2829,3 +2829,34 @@ Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'x'
drop table t1;
drop view v1;
create table t1(a1 int);
create table t2(a2 int);
insert into t1 values(1),(2);
insert into t2 values(1),(2);
create view v2 (c) as select a1 from t1;
select * from t1 natural left join t2;
a1 a2
1 1
1 2
2 1
2 2
select * from t1 natural right join t2;
a2 a1
1 1
1 2
2 1
2 2
select * from v2 natural left join t2;
c a2
1 1
1 2
2 1
2 2
select * from v2 natural right join t2;
a2 c
1 1
1 2
2 1
2 2
drop table t1, t2;
drop view v2;
......@@ -2406,3 +2406,23 @@ insert into t1 values (1,'x',5);
select * from t1 natural join v1;
drop table t1;
drop view v1;
#
# Bug #6276 A SELECT that does a NATURAL OUTER JOIN without common
# columns crashes server because of empty ON condition
#
create table t1(a1 int);
create table t2(a2 int);
insert into t1 values(1),(2);
insert into t2 values(1),(2);
create view v2 (c) as select a1 from t1;
select * from t1 natural left join t2;
select * from t1 natural right join t2;
select * from v2 natural left join t2;
select * from v2 natural right join t2;
drop table t1, t2;
drop view v2;
......@@ -3851,6 +3851,11 @@ store_top_level_join_columns(THD *thd, TABLE_LIST *table_ref,
*/
table_ref_1->natural_join= table_ref_2->natural_join= NULL;
/* Add a TRUE condition to outer joins that have no common columns. */
if (table_ref_2->outer_join &&
!table_ref_1->on_expr && !table_ref_2->on_expr)
table_ref_2->on_expr= new Item_int((longlong) 1,1); /* Always true. */
/* Change this table reference to become a leaf for name resolution. */
if (left_neighbor)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment