From 88cd7a98a5b52cd9a7c7568c864f73342f0f4d35 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Thu, 8 Jan 2009 03:06:54 +0100 Subject: Fix a few problems after latest bunch of InnoDB snapshot changes: The binlog_innodb test was sensitive to what tests ran before it. Now run FLUSH STATUS before performing operations that need to be checked. sys_var_thd_ulong::update() was improperly casting an option value from ulonglong to ulong before comparing it to the max allowed value. On systems where ulong and ulonglong are of different size, this caused values greater than ULONG_MAX to wrap around (not be truncated to ULONG_MAX, which appears to have been the intention of the original coder), and caused some checks to work incorrectly. This wasn't generally visible to the user, because later checks would prevent the wrapped-around value from being used. But it caused warning messages to differ between 32- and 64-bit platforms. Fix is to just remove the cast. Also added a DBUG_ASSERT to ensure that the value really is capped properly before finally stuffing it into the ulong. --- sql/set_var.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/set_var.cc') diff --git a/sql/set_var.cc b/sql/set_var.cc index a371c1113ef..308735f52f2 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1527,14 +1527,14 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) ulonglong tmp= var->save_result.ulonglong_value; /* Don't use bigger value than given with --maximum-variable-name=.. */ - if ((ulong) tmp > max_system_variables.*offset) + if (tmp > max_system_variables.*offset) { throw_bounds_warning(thd, TRUE, TRUE, name, (longlong) tmp); tmp= max_system_variables.*offset; } if (option_limits) - tmp= (ulong) fix_unsigned(thd, tmp, option_limits); + tmp= fix_unsigned(thd, tmp, option_limits); #if SIZEOF_LONG < SIZEOF_LONG_LONG else if (tmp > ULONG_MAX) { @@ -1543,6 +1543,7 @@ bool sys_var_thd_ulong::update(THD *thd, set_var *var) } #endif + DBUG_ASSERT(tmp <= ULONG_MAX); if (var->type == OPT_GLOBAL) global_system_variables.*offset= (ulong) tmp; else -- cgit v1.2.1