summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-03-25 23:44:06 -0700
committerunknown <igor@olga.mysql.com>2007-03-25 23:44:06 -0700
commitd95c307f1d3e7dcbd46db9c77f5303142243dc58 (patch)
treec3d65e5d50b84ef7ab0b32510ad95f6bc044e95f /sql/item_sum.cc
parenta220fc4892f558561e208e6e5d36d4e4928b6cb6 (diff)
downloadmariadb-git-d95c307f1d3e7dcbd46db9c77f5303142243dc58.tar.gz
This is a fix for the memory corruption occurred in one of test cases
from func_group.test after the patch for bug #27229 had been applied. The memory corruption happened because in some rare cases the function count_field_types underestimated the number of elements in in the array param->items_to_copy. sql/item_sum.cc: The return value of the Item_sum::update_used_tables method should not depend on the place of aggregation of the set function for which the Item_sum object has been created. sql/sql_select.cc: This is a fix for the memory corruption occurred in one of test cases from func_group.test after the patch for bug #27229 had been applied. The memory corruption happened because in some rare cases the function count_field_types underestimated the number of elements in in the array param->items_to_copy. Currently it's not guaranteed that after JOIN::prepare() the used_tables attribute is calculated for all items. For example for the expression SUM(outer_ref)+1 used_tables() must return OUTER_REF_TABLE_BIT. Yet by the moment when the used_tables attribute is calculated in JOIN::prepare SUM(outer_ref) has not been substituted for Item_aggregate_ref yet. By this reason additional calls of the method update_used_tables are needed for some items passed as parameters to the function create_tmp_table.
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 422e9b4c6ea..368dc9a7d38 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -449,8 +449,7 @@ void Item_sum::update_used_tables ()
used_tables_cache&= PSEUDO_TABLE_BITS;
/* the aggregate function is aggregated into its local context */
- if (aggr_level == nest_level)
- used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
+ used_tables_cache |= (1 << aggr_sel->join->tables) - 1;
}
}