diff options
author | Alexey Botchkov <holyfoot@mysql.com> | 2009-11-17 15:24:23 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@mysql.com> | 2009-11-17 15:24:23 +0400 |
commit | 5b8a24cf04b4aa76b301036f58fb624a4ff361e0 (patch) | |
tree | b01533f7105fd4c9b16c327c83553918dbd9dbe2 /sql/item_sum.cc | |
parent | 8afc2658d7fc473932151a8bde1d0b50d96f7169 (diff) | |
parent | cd994f0ee4c67e892d35e9f928b67491b0e264b1 (diff) | |
download | mariadb-git-5b8a24cf04b4aa76b301036f58fb624a4ff361e0.tar.gz |
merging.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r-- | sql/item_sum.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 68aa52f561c..f72b64fc66e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -29,6 +29,18 @@ #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 @@ -833,7 +845,7 @@ bool Aggregator_distinct::setup(THD *thd) } DBUG_ASSERT(tree == 0); tree= new Unique(compare_key, cmp_arg, tree_key_length, - thd->variables.max_heap_table_size); + item_sum->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, @@ -902,7 +914,7 @@ bool Aggregator_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); + item_sum->ram_limitation(thd)); DBUG_RETURN(tree == 0); } @@ -3514,7 +3526,7 @@ bool Item_func_group_concat::setup(THD *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); } |