From 96c373c51a2a6f3d0c2190bbc2f641c455f67319 Mon Sep 17 00:00:00 2001 From: Roy Lyseng Date: Fri, 21 Dec 2012 09:53:42 +0100 Subject: 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. --- sql/strfunc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/strfunc.cc') diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 0c0742b3805..f39901a6ca5 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -85,7 +85,7 @@ ulonglong find_set(TYPELIB *lib, const char *str, uint length, CHARSET_INFO *cs, *set_warning= 1; } else - found|= ((longlong) 1 << (find - 1)); + found|= 1ULL << (find - 1); if (pos >= end) break; start= pos + mblen; -- cgit v1.2.1