summaryrefslogtreecommitdiff
path: root/sql/item_subselect.cc
diff options
context:
space:
mode:
authorRoy Lyseng <roy.lyseng@oracle.com>2012-12-21 09:53:42 +0100
committerRoy Lyseng <roy.lyseng@oracle.com>2012-12-21 09:53:42 +0100
commit96c373c51a2a6f3d0c2190bbc2f641c455f67319 (patch)
tree79c2a5d1c358ea18f9d7b7b91ae2995add41808f /sql/item_subselect.cc
parent56db769e1009acf89ae64545ecc1bb57b1c86358 (diff)
downloadmariadb-git-96c373c51a2a6f3d0c2190bbc2f641c455f67319.tar.gz
Bug#15972635: Incorrect results returned in 32 table join with HAVING
The problem is a shift operation that is not 64-bit safe. The consequence is that used tables information for a join with 32 tables or more will be incorrect. Fixed by adding a type cast in Item_sum::update_used_tables(). Also used the opportunity to fix some other potential bugs by adding an explicit type-cast to an integer in a left-shift operation. Some of them were quite harmless, but was fixed in order to get the same signed-ness as the other operand of the operation it was used in. sql/item_cmpfunc.cc Adjusted signed-ness for some integers in left-shift. sql/item_subselect.cc Added type-cast to nesting_map (which is a 32/64 bit type, so potential bug for deeply nested queries). sql/item_sum.cc Added type-cast to nesting_map (32/64-bit type) and table_map (64-bit type). sql/opt_range.cc Added type-cast to ulonglong (which is a 64-bit type). sql/sql_base.cc Added type-cast to nesting_map (which is a 32/64-bit type). sql/sql_select.cc Added type-cast to nesting_map (32/64-bit type) and key_part_map (64-bit type). sql/strfunc.cc Changed type-cast from longlong to ulonglong, to preserve signed-ness.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r--sql/item_subselect.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index d3b06f5983a..dd6257db30a 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1042,7 +1042,8 @@ Item_in_subselect::single_value_transformer(JOIN *join,
}
save_allow_sum_func= thd->lex->allow_sum_func;
- thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
+ thd->lex->allow_sum_func|=
+ (nesting_map)1 << thd->lex->current_select->nest_level;
/*
Item_sum_(max|min) can't substitute other item => we can use 0 as
reference, also Item_sum_(max|min) can't be fixed after creation, so