← Back to team overview

maria-developers team mailing list archive

Rev 2764: * Better self-recursion protection in Item_subselect::fix_fields. in file:///home/psergey/dev/maria-5.3-subqueries-r7/

 

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

------------------------------------------------------------
revno: 2764
revision-id: psergey@xxxxxxxxxxxx-20100221033618-83dgm2h9ingzmhcc
parent: psergey@xxxxxxxxxxxx-20100220082329-9esvom4n6mpgeqvk
committer: Sergey Petrunya <psergey@xxxxxxxxxxxx>
branch nick: maria-5.3-subqueries-r7
timestamp: Sun 2010-02-21 05:36:18 +0200
message:
  * Better self-recursion protection in Item_subselect::fix_fields. 
    Don't go into branch that calls upper_refs.empty() more than once per
    PREPARE or EXECUTE
  * Avoid crashing when processing references to outside from subquery's HAVING
    (will explain in more details in email)
=== modified file 'sql/item.h'
--- a/sql/item.h	2010-02-17 10:05:27 +0000
+++ b/sql/item.h	2010-02-21 03:36:18 +0000
@@ -2378,7 +2378,12 @@
     return ref ? (*ref)->real_item() : this;
   }
   bool walk(Item_processor processor, bool walk_subquery, uchar *arg)
-  { return (*ref)->walk(processor, walk_subquery, arg); }
+  { 
+    if (ref && *ref)
+      return (*ref)->walk(processor, walk_subquery, arg); 
+    else
+      return FALSE;
+  }
   bool enumerate_field_refs_processor(uchar *arg)
   { return (*ref)->enumerate_field_refs_processor(arg); }
   virtual void print(String *str, enum_query_type query_type);

=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc	2010-02-20 08:23:29 +0000
+++ b/sql/item_subselect.cc	2010-02-21 03:36:18 +0000
@@ -186,7 +186,6 @@
   changed= 1;
   inside_first_fix_fields= FALSE;
 
-    done_first_fix_fields= FALSE;
 
   if (!res)
   {
@@ -218,12 +217,14 @@
       if (!(*ref)->fixed)
 	ret= (*ref)->fix_fields(thd, ref);
       thd->where= save_where;
+  done_first_fix_fields= FALSE;
       return ret;
     }
     // Is it one field subselect?
     if (engine->cols() > max_columns)
     {
       my_error(ER_OPERAND_COLUMNS, MYF(0), 1);
+  done_first_fix_fields= FALSE;
       return TRUE;
     }
     fix_length_and_dec();
@@ -240,6 +241,7 @@
   fixed= 1;
 
 err:
+  done_first_fix_fields= FALSE;
   thd->where= save_where;
   return res;
 }
@@ -282,6 +284,7 @@
   return FALSE;
 }
 
+
 /*
   Adjust attributes after our parent select has been merged into grandparent
 
@@ -310,6 +313,7 @@
   parent_select= new_parent;
 }
 
+
 class Field_fixer: public Field_enumerator
 {
 public:




Follow ups