List:Commits« Previous MessageNext Message »
From:Olav Sandstaa Date:June 6 2011 12:50pm
Subject:bzr push into mysql-trunk branch (olav.sandstaa:3157 to 3158) Bug#12355958
View as plain text  
 3158 Olav Sandstaa	2011-06-06
      This is preparation patch for Bug#12355958 "FAILING ASSERTION: 
      TRX->LOCK.N_ACTIVE_THRS == 1". It does not contain the fix for
      the bug but will make the bug fix simpler/better.
      
      The Item::with_subselect member variable is public and is used 
      directly in code outside the Item tree. This patch changes it
      to be protected and adds a new method Item::has_subquery() for
      getting the value of it.
      
      The patch should not change any behavior.
     @ sql/item.cc
        Changes in order for initialization of with_subselect in
        Item constructors.
     @ sql/item.h
        Make Item::with_subselect protected and add a getter
        fuction Item::has_subquery().
     @ sql/item_cmpfunc.cc
        Use the new Item::has_subquery() function instead of accessing
        Item::with_subselect directly.
     @ sql/item_func.cc
        Use the new Item::has_subquery() function instead of accessing
        Item::with_subselect directly.
     @ sql/sql_select.cc
        Use the new Item::has_subquery() function instead of accessing
        Item::with_subselect directly.

    modified:
      sql/item.cc
      sql/item.h
      sql/item_cmpfunc.cc
      sql/item_func.cc
      sql/sql_select.cc
 3157 Guilhem Bichot	2011-05-02
      WL#5872 "avoid using global heap memory to remember autoincrement values for statement-based binlog".
      As long as WL3404 "new binlog event Insert_id_list_event to store multiple auto_increment intervals"
      is not implemented, Discrete_intervals_list needs to contain only the first interval,
      so it makes sense to store this interval as a member of Discrete_intervals_list,
      rather than allocating it on the global heap with new(). This is to save one new()
      per statement inserting into an auto-increment column, and is a sub-part of
      WL5774 "Decrease number of malloc's for normal DML queries".
      Even when WL3404 is implemented, it will still make sense to avoid new()
      for the first interval, as we expect one-interval lists to be common.
      Patch includes parts by Sven Sandberg.
     @ sql/structs.h
        1) remove get_head()/current()/tail(), because those were used only
        in private functions where head/current/tail are accessible anyway;
        head/current/tail are implementation details, users of the class
        don't need to see them.
        2) make copy_shallow() and append(Discrete_interval*) private,
        because they are used only in private functions (same arguments as
        above).
        3) Store first interval inside Discrete_intervals_list,
        not on the heap (no new()).

    modified:
      mysql-test/extra/rpl_tests/rpl_auto_increment.test
      mysql-test/suite/rpl/r/rpl_auto_increment.result
      sql/structs.h
=== modified file 'sql/item.cc'

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2011-05-26 15:20:09 +0000
+++ b/sql/item.cc	2011-06-06 12:49:55 +0000
@@ -419,12 +419,11 @@
 Item::Item():
   is_expensive_cache(-1), rsize(0), name(0), orig_name(0), name_length(0),
   fixed(0), is_autogenerated_name(TRUE),
-  collation(&my_charset_bin, DERIVATION_COERCIBLE)
+  collation(&my_charset_bin, DERIVATION_COERCIBLE), with_subselect(false)
 {
   marker= 0;
   maybe_null=null_value=with_sum_func=unsigned_flag=0;
   decimals= 0; max_length= 0;
-  with_subselect= 0;
   cmp_context= (Item_result)-1;
 
   /* Put item in free list so that we can free all items at end */
@@ -470,8 +469,8 @@
   fixed(item->fixed),
   is_autogenerated_name(item->is_autogenerated_name),
   collation(item->collation),
-  with_subselect(item->with_subselect),
-  cmp_context(item->cmp_context)
+  cmp_context(item->cmp_context),
+  with_subselect(item->with_subselect)
 {
   next= thd->free_list;				// Put in free list
   thd->free_list= this;

=== modified file 'sql/item.h'
--- a/sql/item.h	2011-05-26 15:20:09 +0000
+++ b/sql/item.h	2011-06-06 12:49:55 +0000
@@ -567,10 +567,13 @@
   my_bool is_autogenerated_name;        /* indicate was name of this Item
                                            autogenerated or set by user */
   DTCollation collation;
+  Item_result cmp_context;              /* Comparison context */
+ protected:
   my_bool with_subselect;               /* If this item is a subselect or some
                                            of its arguments is or contains a
                                            subselect. Computed by fix_fields. */
-  Item_result cmp_context;              /* Comparison context */
+
+ public:
   // alloc & destruct is done as start of select using sql_alloc
   Item();
   /*
@@ -1301,6 +1304,11 @@
      @retval FALSE Otherwise.
   */
   bool is_blob_field() const;
+
+  /**
+    Checks if this item or any of its decendents contains a subquery.
+  */
+  virtual bool has_subquery() const { return with_subselect; }
 };
 
 

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2011-05-26 05:50:01 +0000
+++ b/sql/item_cmpfunc.cc	2011-06-06 12:49:55 +0000
@@ -4404,7 +4404,7 @@
       const_item_cache= FALSE;
     }  
     with_sum_func=	    with_sum_func || item->with_sum_func;
-    with_subselect|=        item->with_subselect;
+    with_subselect|=        item->has_subquery();
     if (item->maybe_null)
       maybe_null=1;
   }

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-05-26 10:13:07 +0000
+++ b/sql/item_func.cc	2011-06-06 12:49:55 +0000
@@ -218,7 +218,7 @@
       used_tables_cache|=     item->used_tables();
       not_null_tables_cache|= item->not_null_tables();
       const_item_cache&=      item->const_item();
-      with_subselect|=        item->with_subselect;
+      with_subselect|=        item->has_subquery();
     }
   }
   fix_length_and_dec();

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2011-05-26 15:20:09 +0000
+++ b/sql/sql_select.cc	2011-06-06 12:49:55 +0000
@@ -10118,7 +10118,7 @@
       contains a subquery. If this is the case we do not include this
       part of the condition.
     */
-    return !item->with_subselect;
+    return !item->has_subquery();
   }
 
   const Item::Type item_type= item->type();
@@ -11971,7 +11971,7 @@
       *simple_order=0;				// Must do a temp table to sort
     else if (!(order_tables & not_const_tables))
     {
-      if (order->item[0]->with_subselect && 
+      if (order->item[0]->has_subquery() && 
           !(join->select_lex->options & SELECT_DESCRIBE))
         order->item[0]->val_str(&order->item[0]->str_value);
       DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (olav.sandstaa:3157 to 3158) Bug#12355958Olav Sandstaa6 Jun