diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 4 | ||||
-rw-r--r-- | sql/item_func.cc | 22 | ||||
-rw-r--r-- | sql/item_func.h | 19 | ||||
-rw-r--r-- | sql/matherr.c | 42 | ||||
-rw-r--r-- | sql/unireg.h | 1 |
5 files changed, 19 insertions, 69 deletions
diff --git a/sql/field.cc b/sql/field.cc index 4a1db17b154..4b07da2c1c1 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2261,13 +2261,11 @@ int Field_decimal::store(double nr) return 1; } -#ifdef HAVE_FINITE - if (!finite(nr)) // Handle infinity as special case + if (!isfinite(nr)) // Handle infinity as special case { overflow(nr < 0.0); return 1; } -#endif reg4 uint i; size_t length; diff --git a/sql/item_func.cc b/sql/item_func.cc index 399aba12707..d9a32b596ed 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1093,7 +1093,7 @@ double Item_func_plus::real_op() double value= args[0]->val_real() + args[1]->val_real(); if ((null_value=args[0]->null_value || args[1]->null_value)) return 0.0; - return value; + return fix_result(value); } @@ -1171,7 +1171,7 @@ double Item_func_minus::real_op() double value= args[0]->val_real() - args[1]->val_real(); if ((null_value=args[0]->null_value || args[1]->null_value)) return 0.0; - return value; + return fix_result(value); } @@ -1211,7 +1211,7 @@ double Item_func_mul::real_op() double value= args[0]->val_real() * args[1]->val_real(); if ((null_value=args[0]->null_value || args[1]->null_value)) return 0.0; - return value; + return fix_result(value); } @@ -1269,7 +1269,7 @@ double Item_func_div::real_op() signal_divide_by_null(); return 0.0; } - return value/val2; + return fix_result(value/val2); } @@ -1643,7 +1643,7 @@ double Item_func_exp::val_real() double value= args[0]->val_real(); if ((null_value=args[0]->null_value)) return 0.0; /* purecov: inspected */ - return exp(value); + return fix_result(exp(value)); } double Item_func_sqrt::val_real() @@ -1662,7 +1662,7 @@ double Item_func_pow::val_real() double val2= args[1]->val_real(); if ((null_value=(args[0]->null_value || args[1]->null_value))) return 0.0; /* purecov: inspected */ - return pow(value,val2); + return fix_result(pow(value,val2)); } // Trigonometric functions @@ -1674,7 +1674,7 @@ double Item_func_acos::val_real() volatile double value= args[0]->val_real(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; - return fix_result(acos(value)); + return acos(value); } double Item_func_asin::val_real() @@ -1684,7 +1684,7 @@ double Item_func_asin::val_real() volatile double value= args[0]->val_real(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; - return fix_result(asin(value)); + return asin(value); } double Item_func_atan::val_real() @@ -1700,7 +1700,7 @@ double Item_func_atan::val_real() return 0.0; return fix_result(atan2(value,val2)); } - return fix_result(atan(value)); + return atan(value); } double Item_func_cos::val_real() @@ -1709,7 +1709,7 @@ double Item_func_cos::val_real() double value= args[0]->val_real(); if ((null_value=args[0]->null_value)) return 0.0; - return fix_result(cos(value)); + return cos(value); } double Item_func_sin::val_real() @@ -1718,7 +1718,7 @@ double Item_func_sin::val_real() double value= args[0]->val_real(); if ((null_value=args[0]->null_value)) return 0.0; - return fix_result(sin(value)); + return sin(value); } double Item_func_tan::val_real() 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 diff --git a/sql/matherr.c b/sql/matherr.c deleted file mode 100644 index 4998d8b4961..00000000000 --- a/sql/matherr.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2000-2001 MySQL AB - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - -/* Fix that we got POSTFIX_ERROR when doing unreasonable math (not core) */ - -#include <my_global.h> -#include <errno.h> - - /* Fix that we gets POSTFIX_ERROR when error in math */ - -#if defined(HAVE_MATHERR) -int matherr(struct exception *x) -{ - if (x->type != PLOSS) - x->retval=POSTFIX_ERROR; - switch (x->type) { - case DOMAIN: - case SING: - my_errno=EDOM; - break; - case OVERFLOW: - case UNDERFLOW: - my_errno=ERANGE; - break; - default: - break; - } - return(1); /* Take no other action */ -} -#endif diff --git a/sql/unireg.h b/sql/unireg.h index 2e0172ce31d..8731a0ac98a 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -108,7 +108,6 @@ #define READ_RECORD_BUFFER (uint) (IO_SIZE*8) /* Pointer_buffer_size */ #define DISK_BUFFER_SIZE (uint) (IO_SIZE*16) /* Size of diskbuffer */ -#define POSTFIX_ERROR DBL_MAX #define ME_INFO (ME_HOLDTANG+ME_OLDWIN+ME_NOREFRESH) #define ME_ERROR (ME_BELL+ME_OLDWIN+ME_NOREFRESH) |