← Back to team overview

maria-developers team mailing list archive

Rev 2782: Fix union.test failure in buildbot: alternate fix for BUG#49734 in file:///home/psergey/dev/maria-5.3-subqueries-r10/

 

At file:///home/psergey/dev/maria-5.3-subqueries-r10/

------------------------------------------------------------
revno: 2782
revision-id: psergey@xxxxxxxxxxxx-20100320165930-ehfull9rin1bdme4
parent: psergey@xxxxxxxxxxxx-20100320120844-n8dvu5loib2fjvwl
committer: Sergey Petrunya <psergey@xxxxxxxxxxxx>
branch nick: maria-5.3-subqueries-r10
timestamp: Sat 2010-03-20 19:59:30 +0300
message:
  Fix union.test failure in buildbot: alternate fix for BUG#49734
=== modified file 'mysql-test/r/union.result'
--- a/mysql-test/r/union.result	2010-03-20 12:01:47 +0000
+++ b/mysql-test/r/union.result	2010-03-20 16:59:30 +0000
@@ -1632,7 +1632,7 @@
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
 1	PRIMARY	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
 2	UNION	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	
-3	SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
+3	DEPENDENT SUBQUERY	t2	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
 NULL	UNION RESULT	<union1,2>	ALL	NULL	NULL	NULL	NULL	NULL	NULL	Using filesort
 Warnings:
 Note	1276	Field or reference 'test.t1.a' of SELECT #3 was resolved in SELECT #2

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2010-03-20 12:01:47 +0000
+++ b/sql/sql_select.cc	2010-03-20 16:59:30 +0000
@@ -18319,6 +18319,26 @@
        unit;
        unit= unit->next_unit())
   {
+    /*
+      This fix_fields() call is to handle an edge case like this:
+       
+        SELECT ... UNION SELECT ... ORDER BY (SELECT ...)
+      
+      for such queries, we'll get here before having called
+      subquery_expr->fix_fields(), which will cause failure to
+    */
+    if (unit->item && !unit->item->fixed)
+    {
+      Item *ref= unit->item;
+      if (unit->item->fix_fields(thd, &ref))
+        DBUG_VOID_RETURN;
+      DBUG_ASSERT(ref == unit->item);
+    }
+
+    /* 
+      Display subqueries only if they are not parts of eliminated WHERE/ON
+      clauses.
+    */
     if (!(unit->item && unit->item->eliminated))
     {
       if (mysql_explain_union(thd, unit, result))