List:Internals« Previous MessageNext Message »
From:timour Date:August 17 2005 2:19pm
Subject:bk commit into 5.0 tree (timour:1.1991)
View as plain text  
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.1991 05/08/17 17:19:31 timour@stripped +4 -0
  WL#2486 - natural and using join according to SQL:2003
  - fixed a problem with RIGHT JOIN ON and enabled corresponding tests in select.test
  - fixed a memory leak

  sql/table.h
    1.106 05/08/17 17:19:28 timour@stripped +1 -1
    Inherit from Sql_alloc for proper memory allocation.
    The change fixes a memory leak.

  sql/sql_base.cc
    1.285 05/08/17 17:19:28 timour@stripped +23 -4
    Fixed a problem with RIGHT JOINs that have operand(s) which are NATURAL JOIN(s).

  mysql-test/t/select.test
    1.64 05/08/17 17:19:28 timour@stripped +2 -4
    Fixed a problem with RIGHT JOIN ON queries, enabling the corresponding tests.

  mysql-test/r/select.result
    1.78 05/08/17 17:19:28 timour@stripped +17 -0
    Fixed a problem with RIGHT JOIN ON queries, enabling the corresponding tests.

# 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.284/sql/sql_base.cc	2005-08-17 14:19:58 +03:00
+++ 1.285/sql/sql_base.cc	2005-08-17 17:19:28 +03:00
@@ -3790,10 +3790,29 @@
     {
       TABLE_LIST *cur_table_ref= cur_left_neighbor;
       cur_left_neighbor= nested_it++;
-     if (cur_table_ref->nested_join &&
-         store_top_level_join_columns(thd, cur_table_ref,
-                                      cur_left_neighbor, cur_right_neighbor))
-         DBUG_RETURN(TRUE);
+      /*
+        The order of RIGHT JOIN operands is reversed in 'join list' to
+        transform it into a LEFT JOIN. However, in this procedure we need
+        the join operands in their lexical order, so below we reverse the
+        join operands. Notice that this happens only in the first loop, and
+        not in the second one, as in the second loop cur_left_neighbor == NULL.
+        This is the correct behavior, because the second loop
+        sets cur_table_ref reference correctly after the join operands are
+        swapped in the first loop.
+      */
+      if (cur_left_neighbor &&
+          cur_table_ref->outer_join & JOIN_TYPE_RIGHT)
+      {
+        DBUG_ASSERT(cur_table_ref);
+        /* This can happen only for JOIN ... ON. */
+        DBUG_ASSERT(table_ref->nested_join->join_list.elements == 2);
+        swap_variables(TABLE_LIST*, cur_left_neighbor, cur_table_ref);
+      }
+
+      if (cur_table_ref->nested_join &&
+          store_top_level_join_columns(thd, cur_table_ref,
+                                       cur_left_neighbor, cur_right_neighbor))
+        DBUG_RETURN(TRUE);
      cur_right_neighbor= cur_table_ref;
     }
   }

--- 1.105/sql/table.h	2005-08-12 18:04:50 +03:00
+++ 1.106/sql/table.h	2005-08-17 17:19:28 +03:00
@@ -374,7 +374,7 @@
   Field (for tables), or a Field_translator (for views).
 */
 
-class Natural_join_column
+class Natural_join_column: public Sql_alloc
 {
 public:
   Field_translator *view_field;  /* Column reference of merge view. */

--- 1.77/mysql-test/r/select.result	2005-08-16 16:39:32 +03:00
+++ 1.78/mysql-test/r/select.result	2005-08-17 17:19:28 +03:00
@@ -2218,6 +2218,23 @@
 1
 2
 3
+select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
+a	a
+NULL	1
+1	2
+2	2
+3	2
+1	3
+2	3
+3	3
+select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
+a	a
+2	1
+3	1
+2	2
+3	2
+2	3
+3	3
 select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
 a
 1

--- 1.63/mysql-test/t/select.test	2005-08-16 16:39:33 +03:00
+++ 1.64/mysql-test/t/select.test	2005-08-17 17:19:28 +03:00
@@ -1850,10 +1850,8 @@
 select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
 select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
 # right join on
-# TODO: WL#2486 - there is a problem in the order of tables in RIGHT JOIN
-#       check how we set next_name_resolution_table
-# select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
-# select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
+select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
+select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
 # right [outer] joing using
 select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
 select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
Thread
bk commit into 5.0 tree (timour:1.1991)timour17 Aug