List:Commits« Previous MessageNext Message »
From:kgeorge Date:June 8 2006 8:41am
Subject:bk commit into 5.0 tree (gkodinov:1.2162) BUG#15355
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kgeorge. When kgeorge 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.2162 06/06/08 11:41:26 gkodinov@stripped +3 -0
  Bug #15355: Common natural join column not resolved in prepared statement nested 
    query
  
  The top-most, left-most NATURAL/USING join must be set as a 
  first_name_resolution_table in context even when operating on prepared statements.
  Only recalculating the row layout can be skipped in that case.
  This is needed for subsequent fix_fields() calls (something that is not done for 
  the Item_field instances created when expanding the '*' in insert_fields).

  sql/sql_base.cc
    1.339 06/06/08 11:41:21 gkodinov@stripped +11 -11
    The context must be set even when executed as prepared statement.

  mysql-test/t/join.test
    1.32 06/06/08 11:41:21 gkodinov@stripped +25 -0
    testsuite for the bug

  mysql-test/r/join.result
    1.38 06/06/08 11:41:21 gkodinov@stripped +20 -0
    testsuite for the bug

# 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:	gkodinov
# Host:	rakia.(none)
# Root:	/home/kgeorge/mysql/5.0/B15355

--- 1.338/sql/sql_base.cc	2006-05-26 11:51:15 +03:00
+++ 1.339/sql/sql_base.cc	2006-06-08 11:41:21 +03:00
@@ -4184,10 +4184,6 @@
   if (from_clause->elements == 0)
     return FALSE; /* We come here in the case of UNIONs. */
 
-  /* For stored procedures do not redo work if already done. */
-  if (!context->select_lex->first_execution)
-    return FALSE;
-
   List_iterator_fast<TABLE_LIST> table_ref_it(*from_clause);
   TABLE_LIST *table_ref; /* Current table reference. */
   /* Table reference to the left of the current. */
@@ -4200,14 +4196,18 @@
   {
     table_ref= left_neighbor;
     left_neighbor= table_ref_it++;
-    if (store_top_level_join_columns(thd, table_ref,
-                                     left_neighbor, right_neighbor))
-      return TRUE;
-    if (left_neighbor)
+    /* For stored procedures do not redo work if already done. */
+    if (context->select_lex->first_execution)
     {
-      TABLE_LIST *first_leaf_on_the_right;
-      first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();
-      left_neighbor->next_name_resolution_table= first_leaf_on_the_right;
+      if (store_top_level_join_columns(thd, table_ref,
+                                       left_neighbor, right_neighbor))
+        return TRUE;
+      if (left_neighbor)
+      {
+        TABLE_LIST *first_leaf_on_the_right;
+        first_leaf_on_the_right= table_ref->first_leaf_for_name_resolution();
+        left_neighbor->next_name_resolution_table= first_leaf_on_the_right;
+      }
     }
     right_neighbor= table_ref;
   }

--- 1.37/mysql-test/r/join.result	2006-05-12 13:07:56 +03:00
+++ 1.38/mysql-test/r/join.result	2006-06-08 11:41:21 +03:00
@@ -744,3 +744,23 @@
 a2
 1
 drop table t1,t2,t3,t4;
+create table t1 (c int, b int);
+create table t2 (a int, b int);
+create table t3 (b int, c int);
+create table t4 (y int, c int);
+create table t5 (y int, z int);
+insert into t1 values (3,2);
+insert into t2 values (1,2);
+insert into t3 values (2,3);
+insert into t4 values (1,3);
+insert into t5 values (1,4);
+prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2))
+natural join t4) natural join t5";
+execute stmt1;
+y	c	b	a	z
+1	3	2	1	4
+select * from ((t3 natural join (t1 natural join t2)) natural join t4)
+natural join t5;
+y	c	b	a	z
+1	3	2	1	4
+drop table t1, t2, t3, t4, t5;

--- 1.31/mysql-test/t/join.test	2006-03-06 11:11:04 +02:00
+++ 1.32/mysql-test/t/join.test	2006-06-08 11:41:21 +03:00
@@ -563,4 +563,29 @@
 
 drop table t1,t2,t3,t4;
 
+#
+# BUG#15355: Common natural join column not resolved in prepared statement nested query
+#
+create table t1 (c int, b int);
+create table t2 (a int, b int);
+create table t3 (b int, c int);
+create table t4 (y int, c int);
+create table t5 (y int, z int);
+
+insert into t1 values (3,2);
+insert into t2 values (1,2);
+insert into t3 values (2,3);
+insert into t4 values (1,3);
+insert into t5 values (1,4);
+
+-- this fails
+prepare stmt1 from "select * from ((t3 natural join (t1 natural join t2))
+natural join t4) natural join t5";
+execute stmt1;
+
+-- this works
+select * from ((t3 natural join (t1 natural join t2)) natural join t4)
+  natural join t5;
+drop table t1, t2, t3, t4, t5;
+
 # End of tests for WL#2486 - natural/using join
Thread
bk commit into 5.0 tree (gkodinov:1.2162) BUG#15355kgeorge8 Jun