List:Commits« Previous MessageNext Message »
From:Alexey Botchkov Date:October 1 2009 11:33am
Subject:bzr commit into mysql-5.1-bugteam branch (holyfoot:3146) Bug#46018
View as plain text  
#At file:///home/hf/work/mysql_common/46018/ based on revid:davi.arnaut@stripped

 3146 Alexey Botchkov	2009-10-01
      Bug#46018      group_concat(distinct ...) uses max_heap_table_size for memory allocations
          Use min(max_heap_table_size, tmp_table_size) instead
      
      per-file comments:
        sql/item_sum.cc
      Bug#46018      group_concat(distinct ...) uses max_heap_table_size for memory allocations
          Item_sum_**::setup fixed, so they use ram_limitation() for Unique-s they embed
      
        sql/item_sum.h
      Bug#46018      group_concat(distinct ...) uses max_heap_table_size for memory allocations
         Item_sum::ram_limitation() declared

    modified:
      sql/item_sum.cc
      sql/item_sum.h
=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc	2009-08-24 19:47:08 +0000
+++ b/sql/item_sum.cc	2009-10-01 11:33:30 +0000
@@ -29,6 +29,17 @@
 #include "sql_select.h"
 
 /**
+  Calculate the affordable RAM limit for structures like TREE or Unique
+  used in Item_sum_*
+*/
+
+ulonglong Item_sum::ram_limitation(THD *thd)
+{
+  return min(thd->variables.tmp_table_size,
+      thd->variables.max_heap_table_size);
+}
+
+/**
   Prepare an aggregate function item for checking context conditions.
 
     The function initializes the members of the Item_sum object created
@@ -1045,7 +1056,7 @@ bool Item_sum_distinct::setup(THD *thd)
     are converted to binary representation as well.
   */
   tree= new Unique(simple_raw_key_cmp, &tree_key_length, tree_key_length,
-                   thd->variables.max_heap_table_size);
+                   ram_limitation(thd));
 
   is_evaluated= FALSE;
   DBUG_RETURN(tree == 0);
@@ -2683,8 +2694,7 @@ bool Item_sum_count_distinct::setup(THD 
       }
     }
     DBUG_ASSERT(tree == 0);
-    tree= new Unique(compare_key, cmp_arg, tree_key_length,
-                     thd->variables.max_heap_table_size);
+    tree= new Unique(compare_key,cmp_arg,tree_key_length, ram_limitation(thd));
     /*
       The only time tree_key_length could be 0 is if someone does
       count(distinct) on a char(0) field - stupid thing to do,
@@ -3529,7 +3539,7 @@ bool Item_func_group_concat::setup(THD *
     unique_filter= new Unique(group_concat_key_cmp_with_distinct,
                               (void*)this,
                               tree_key_length,
-                              thd->variables.max_heap_table_size);
+                              ram_limitation(thd));
   
   DBUG_RETURN(FALSE);
 }

=== modified file 'sql/item_sum.h'
--- a/sql/item_sum.h	2009-06-11 16:21:32 +0000
+++ b/sql/item_sum.h	2009-10-01 11:33:30 +0000
@@ -256,6 +256,7 @@ protected:  
   Item **orig_args, *tmp_orig_args[2];
   table_map used_tables_cache;
   bool forced_const;
+  static ulonglong ram_limitation(THD *thd);
 
 public:  
 


Attachment: [text/bzr-bundle] bzr/holyfoot@mysql.com-20091001113330-mkznaj8vsv3oe0lc.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (holyfoot:3146) Bug#46018Alexey Botchkov1 Oct