From: Date: August 23 2005 7:03pm Subject: bk commit into 5.0 tree (timour:1.1910) BUG#6276 List-Archive: http://lists.mysql.com/internals/28701 X-Bug: 6276 Message-Id: <20050823170338.38B71155E2E@lamia.home> Below is the list of changes that have just been committed into a local 5.0 repository of timka. When timka does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.1910 05/08/23 20:03:32 timour@stripped +3 -0 Fix for BUG#6276. sql/sql_base.cc 1.291 05/08/23 20:03:29 timour@stripped +5 -0 Add a true ON condition for outer joins without common columns. mysql-test/t/select.test 1.70 05/08/23 20:03:29 timour@stripped +20 -0 Test for BUG#6276. mysql-test/r/select.result 1.85 05/08/23 20:03:29 timour@stripped +31 -0 Test for BUG#6276. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: timour # Host: lamia.home # Root: /home/timka/mysql/src/5.0-2486 --- 1.290/sql/sql_base.cc 2005-08-23 18:15:46 +03:00 +++ 1.291/sql/sql_base.cc 2005-08-23 20:03:29 +03:00 @@ -3851,6 +3851,11 @@ */ 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) { --- 1.84/mysql-test/r/select.result 2005-08-23 19:00:25 +03:00 +++ 1.85/mysql-test/r/select.result 2005-08-23 20:03:29 +03:00 @@ -2829,3 +2829,34 @@ 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; --- 1.69/mysql-test/t/select.test 2005-08-23 19:00:25 +03:00 +++ 1.70/mysql-test/t/select.test 2005-08-23 20:03:29 +03:00 @@ -2406,3 +2406,23 @@ 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;