From 8d222210c77ba9152e3ba35d937d9b08a8266295 Mon Sep 17 00:00:00 2001 From: "kaa@kaamos.(none)" <> Date: Wed, 20 Feb 2008 00:33:43 +0300 Subject: Fix for bug #31236: Inconsistent division by zero behavior for floating point numbers Some math functions did not check if the result is a valid number (i.e. neither of +-inf or nan). Fixed by validating the result where necessary and returning NULL in case of invalid result. --- sql/item_func.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'sql/item_func.h') diff --git a/sql/item_func.h b/sql/item_func.h index e09b584de95..cdcbbdab150 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -192,6 +192,13 @@ public: void * arg, traverse_order order); bool is_expensive_processor(uchar *arg); virtual bool is_expensive() { return 0; } + inline double fix_result(double value) + { + if (isfinite(value)) + return value; + null_value=1; + return 0.0; + } }; @@ -499,18 +506,6 @@ class Item_dec_func :public Item_real_func decimals=NOT_FIXED_DEC; max_length=float_length(decimals); maybe_null=1; } - inline double fix_result(double value) - { -#ifndef HAVE_FINITE - return value; -#else - /* The following should be safe, even if we compare doubles */ - if (finite(value) && value != POSTFIX_ERROR) - return value; - null_value=1; - return 0.0; -#endif - } }; class Item_func_exp :public Item_dec_func -- cgit v1.2.1 From c6b4d7a7c41a2469a69e0d2a8a883c83cbff3ea9 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/white.intern.koehntopp.de" <> Date: Thu, 28 Feb 2008 14:23:22 +0100 Subject: Bug#34749: Server crash when using NAME_CONST() with an aggregate function NAME_CONST('whatever', -1) * MAX(whatever) bombed since -1 was not seen as constant, but as FUNCTION_UNARY_MINUS(constant) while we are at the same time pretending it was a basic const item. This confused the aggregate handlers in exciting ways. We now make NAME_CONST() behave more consistently. --- sql/item_func.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sql/item_func.h') diff --git a/sql/item_func.h b/sql/item_func.h index 940586fce01..6dcf32cba07 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -54,7 +54,8 @@ public: NOT_FUNC, NOT_ALL_FUNC, NOW_FUNC, TRIG_COND_FUNC, SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC, - EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC }; + EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC, + NEG_FUNC }; enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL, OPTIMIZE_EQUAL }; enum Type type() const { return FUNC_ITEM; } @@ -466,7 +467,7 @@ public: longlong int_op(); my_decimal *decimal_op(my_decimal *); const char *func_name() const { return "-"; } - virtual bool basic_const_item() const { return args[0]->basic_const_item(); } + enum Functype functype() const { return NEG_FUNC; } void fix_length_and_dec(); void fix_num_length_and_dec(); uint decimal_precision() const { return args[0]->decimal_precision(); } -- cgit v1.2.1