Loading mysql-test/r/select.result +31 −0 Original line number Diff line number Diff line Loading @@ -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; mysql-test/t/select.test +20 −0 Original line number Diff line number Diff line Loading @@ -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; sql/sql_base.cc +5 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading
mysql-test/r/select.result +31 −0 Original line number Diff line number Diff line Loading @@ -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;
mysql-test/t/select.test +20 −0 Original line number Diff line number Diff line Loading @@ -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;
sql/sql_base.cc +5 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading