summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_math.test
Commit message (Collapse)AuthorAgeFilesLines
* Create 'main' test directory and move 't' and 'r' thereMichael Widenius2018-03-291-661/+0
|
* Merge 10.2 into bb-10.2-extMarko Mäkelä2017-09-201-0/+4
|\
| * MDEV-13673 Bad result in viewSergei Golubchik2017-09-181-0/+5
| | | | | | | | | | | | | | When printing an expression, like a/(b*c), we need to print parentheses, even though / and * have the same precedence. Basically, we should always treat the second argument as having one level higher precedence than it normally is.
* | MDEV-12803 Improve function parameter data type controlAlexander Barkov2017-05-291-2/+2
| |
* | MDEV-12858 + MDEV+12859 + MDEV-12862 - a join patch fixing a few data type ↵Alexander Barkov2017-05-221-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | problems with CREATE..SELECT MDEV-12858 Out-of-range error for CREATE..SELECT unsigned_int_column+1 MDEV-12859 Out-of-range error for CREATE..SELECT @a:=EXTRACT(MINUTE_MICROSECOND FROM..) MDEV-12862 Data type of @a:=1e0 depends on the session character set 1. Moving a part of Item::create_tmp_field() into a new helper method Item::create_tmp_field_int() and reusing it in Item::create_tmp_field() and Item_func_signed::create_tmp_field(). Fixing the code in Item::create_tmp_field_int() to call Type_handler::make_table_field() instead of doing "new Field_long[long]" directly. This change revealed a problem reported in MDEV-12862. 2. Changing the "long vs longlong" cut-off length for - Item_func::create_tmp_field() - Item_sum::create_tmp_field() - Item_func_get_user_var::create_tmp_field() from MY_INT32_NUM_DECIMAL_DIGITS to (MY_INT32_NUM_DECIMAL_DIGITS - 2). This fixes MDEV-12858. After this change, the "convert_int_length" parameter to Item::create_tmp_field() is not needed any more, because (MY_INT32_NUM_DECIMAL_DIGITS - 2) is always passed. So removing the "convert_int_length" parameter. 3. Fixing Item::create_tmp_field() to pass max_char_length() instead of max_length to the constructor of Field_double(). This fixes MDEV-12862. 4. Additionally, fixing - Type_handler_{tiny|short|int24|long|longlong}::make_table_field() - Type_handler_{float|double}::make_table_field() to pass max_char_length() instead of max_length to Field contructors. This is needed by the change (1). 5. Adding new tests, and recording new correct results in the old tests in: - mysql-test/r/type_ranges.result - storage/tokudb/mysql-test/tokudb/r/type_ranges.result
* | MDEV-12856 Wrong .. metadata for DIV + MDEV-12857..errors on ↵Alexander Barkov2017-05-211-0/+16
| | | | | | | | | | | | | | | | | | CREATE..SELECT..DIV This is a joint patch for: MDEV-12856 Wrong result set metadata for DIV MDEV-12857 Out-of-range errors on CREATE..SELECT 2222222222 DIV 1
* | Merge remote-tracking branch 'origin/10.2' into bb-10.2-extAlexander Barkov2017-02-271-1/+1
|\ \ | |/
| * MDEV-7635: Update tests to adapt to the new default sql_modeNirbhay Choubey2017-02-101-1/+1
| |
* | MDEV-12001 Split Item_func_round::fix_length_and_dec to virtual methods in ↵Alexander Barkov2017-02-071-0/+16
|/ | | | | | | | | | | | | | | | | | | | Type_handler This patch makes the following changes (according to the task description): - Adds Type_handler::Item_func_round_fix_length_and_dec(). - Splits the code from Item_func_round::fix_length_and_dec() into new Item_func_round methods fix_arg_int(), fix_arg_decimal(), fix_arg_double(). - Calls the new Item_func_round methods from the relevant implementations of Type_handler_xxx::Item_func_round_fix_length_and_dec(). - Adds a new error message ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION - Makes ROUND() return the new error for GEOMETRY Additionally: - Inherits Item_func_round directly from Item_func_numhybrid as it uses nothing from Item_func_num1. - Fixes "MDEV-12000 ROUND(expr,const_expr_returning_NULL) creates DOUBLE(0,0)". Now if args[1] returns NULL, the data type is set to DOUBLE with NOT_FIXED_DEC decimals instead of 0 decimals.
* Merge branch '10.1' into 10.2Sergei Golubchik2016-09-091-3/+6
|\
| * Merge branch '10.0' into 10.1Sergei Golubchik2016-08-251-3/+6
| |\
| | * Merge branch '5.5' into 10.0Sergei Golubchik2016-08-101-3/+6
| | |\
| | | * MDEV-10467 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()Alexander Barkov2016-08-031-0/+12
| | | | | | | | | | | | | | | | Backporting MDEV-5781 from 10.0.
* | | | test case for CRC32() SQL functionDaniel Black2016-08-051-0/+5
| | | |
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-06-301-0/+8
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-05-041-0/+8
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-04-261-0/+8
| | |\ \ | | | |/
| | | * another test case for ER_DATA_OUT_OF_RANGE on insertSergei Golubchik2016-04-201-0/+8
| | | | | | | | | | | | | | | | tests it with a non-const table too
* | | | parse negative numbers into one itemSergei Golubchik2016-06-301-1/+5
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | use Item->neg to convert generate negative Item_num's instead of Item_func_neg(Item_num). Based on the following commit: Author: Monty <monty@mariadb.org> Date: Mon May 30 22:44:00 2016 +0300 Make negative number their own token The negation (-) operator will call Item->neg() one underlying numeric constants and remove itself (like the NOT() function does today for other NOT functions. This simplifies things - -1 is not anymore an expression but a basic_const_item - improves optimizer - DEFAULT -1 doesn't need special handling anymore - When we add DEFAULT expressions, -1 will be treated exactly like 1 - printing of items doesn't anymore put braces around all negative numbers Other things fixed: - Fixed that longlong converted to decimal's has a more appropriate size - Fixed that "-0.0" read into a decimal is interpreted as 0.0
* | | MDEV-6066: Merge new defaults from 5.6 and 5.7 (defaults changed, QC can be ↵Oleksandr Byelkin2015-09-041-0/+2
|/ / | | | | | | stopped with no-zero size)
* | MDEV-5858 MySQL Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D ↵Sergei Golubchik2014-03-201-0/+9
| | | | | | | | | | | | | | | | == N*(-9) don't use mysql-5.6 change. correct fix: zero-out rounded tail after the number was shifted because of the carry digit (otherwise the carry digit will be zeroed out too).
* | MDEV-5781 Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query ↵Alexander Barkov2014-03-231-0/+18
|/ | | | with STDDEV_POP, ROUND and variable
* Fix FreeBSD test errors. Also link with libexecinfo on FreeBSD for ↵Vladislav Vaintroub2012-05-041-0/+1
| | | | stacktrace functionality.
* Bug#12711164 - 61676: RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE ↵Tor Didriksen2011-07-181-0/+11
| | | | | | | | | | | | | | | SENSE Truncate result of decimal division before converting to integer. mysql-test/r/func_math.result: New test case. mysql-test/t/func_math.test: New test case. sql/item_func.cc: Item_func_int_div::val_int(): Truncate result of decimal division before converting to integer.
* Bug#12537160 ASSERTION FAILED: STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER.Tor Didriksen2011-07-181-0/+11
| | | | | | | | | | | | | | Turns out the DBUG_ASSERT added by fix for Bug#11792200 was overly pessimistic: 'stop0' is used in the main loop of do_div_mod, but we only dereference 'buf0' for div operations, not for mod. mysql-test/r/func_math.result: New test case. mysql-test/t/func_math.test: New test case. strings/decimal.c: Move DBUG_ASSERT down to where we actually dereference the loop pointer.
* 5.1 -> 5.5 mergeSergey Glukhov2011-05-261-0/+6
|\
| * Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISIONSergey Glukhov2011-05-261-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Assertion happens due to missing NULL value check in Item_func_round::fix_length_and_dec() function. The fix: added NULL value check for second parameter. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: added NULL value check for second parameter.
* | 5.1 -> 5.5 mergeSergey Glukhov2011-04-201-0/+16
|\ \ | |/
| * Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF ↵Sergey Glukhov2011-04-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DECIMAL COLUMN FUNCTION Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA When ROUND evaluates decimal result it uses Item::decimal value as fraction value for the result. In some cases Item::decimal is greater than real result fraction value and uninitialised memory of result(decimal) buffer can be used in further calculations. Issue is introduced by Bug33143 fix. The fix is to remove erroneous assignment. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: remove erroneous assignment
* | 5.1 -> 5.5 mergeSergey Glukhov2011-03-281-0/+9
|\ \ | |/
| * Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION ↵Sergey Glukhov2011-03-281-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > 0 && SCALE <= PR Assert fails due to overflow which happens in Item_func_int_val::fix_num_length_and_dec() as geometry functions have max_length value equal to max_field_size(4294967295U). The fix is to skip max_length calculation for some boundary cases. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: skip max_length calculation if argument max_length is near max_field_size.
* | Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONSTor Didriksen2011-03-031-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was a buffer overrun in do_div_mod(), overwriting the internal buffer of auto variable 'tmp' in Item_func_int_div::val_int. Result on windows: 'this' is set to zero, and crash. Ran fine on other platforms (no valgrind warnings), but this is undefined behaviour on any platform of course. include/decimal.h: Add const qualifiers to function prototypes which are used by sql/my_decimal.h mysql-test/r/func_math.result: New test case. mysql-test/t/func_math.test: New test case. sql/my_decimal.h: Remove several C-style casts: - some of the were up-casts, and thus un-necessary - some of them should have been const-casts, but it is better to make the underlying library functions in (decimal.[h|c]) const instead. strings/decimal.c: Check for buffer overrun in do_div_mod() Add const qualifiers to functions which are used by sql/my_decimal.h
* | Bug #59498 div function broken in mysql-trunkTor Didriksen2011-01-141-0/+5
| | | | | | | | | | | | | | | | | | mysql-test/r/func_math.result: New test case. mysql-test/t/func_math.test: New test case. sql/item_func.cc: Check for null before converting value to my_decimal.
* | Bug #59241 invalid memory read in do_div_mod with doubly assigned variablesTor Didriksen2011-01-141-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix: copy my_decimal by value, to avoid dangling pointers. mysql-test/r/func_math.result: New test case. mysql-test/t/func_math.test: New test case. sql/item_cmpfunc.cc: No need to call fix_buffer_pointer() anymore. sql/item_func.cc: Copy my_decimal by value, to avoid dangling pointers. sql/my_decimal.h: Implement proper copy constructor and assignment operator for my_decimal. sql/sql_analyse.cc: No need to call fix_buffer_pointer() anymore. strings/decimal.c: Remove #line directive: it messes up TAGS and it confuses gdb when debugging.
* | 5.1-bugteam->5.5-bugteam mergeSergey Glukhov2010-12-241-0/+9
|\ \ | |/
| * Bug#57810 case/when/then : Assertion failed: length || !scaleSergey Glukhov2010-12-241-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ASSERT happens due to improper calculation of the max_length in Item_func_div object, if dividend has max_length == 0 then Item_func_div::max_length is set to 0 under some circumstances. The fix: If decimals == NOT_FIXED_DEC then set Item_func_div::max_length to max possible DOUBLE length value. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: The fix: If decimals == NOT_FIXED_DEC then set Item_func_div::max_length to max possible DOUBLE length value.
* | mergeGeorgi Kodinov2010-11-261-0/+8
|\ \ | |/
| * Bug#57477 SIGFPE when dividing a huge number a negative numberSergey Glukhov2010-10-271-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is dividing by const value when the result is out of supported range. The fix: -return LONGLONG_MIN if the result is out of supported range for DIV operator. -return 0 if divisor is -1 for MOD operator. mysql-test/r/func_math.result: test case mysql-test/t/func_math.test: test case sql/item_func.cc: -return LONGLONG_MIN if the result is out of supported range for DIV operator. -return 0 if divisor is -1 for MOD operator.
* | Bug #58137 char(0) column cause: my_gcvt: Assertion `width > 0 && to != ↵Tor Didriksen2010-11-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | ((void *)0)' failed mysql-test/r/func_math.result: Add test for Bug #58137 mysql-test/t/func_math.test: Add test for Bug #58137 sql/field.cc: Skip calling my_gcvt() if we are trying to insert a double into a char(0) column.
* | Bug#57209 valgrind + Assertion failed: dst > bufTor Didriksen2010-10-081-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Buffer overrun when trying to format DBL_MAX mysql-test/r/func_math.result: Add test case for Bug#57209 mysql-test/t/func_math.test: Add test case for Bug#57209 sql/item_strfunc.cc: Allocate a larger buffer for the result.
* | Bug #8433: Overflow must be an error Alexey Kopytov2010-03-181-2/+139
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All numeric operators and functions on integer, floating point and DECIMAL values now throw an 'out of range' error rather than returning an incorrect value or NULL, when the result is out of supported range for the corresponding data type. Some test cases in the test suite had to be updated accordingly either because the test case itself relied on a value returned in case of a numeric overflow, or because a numeric overflow was the root cause of the corresponding bugs. The latter tests are no longer relevant, since the expressions used to trigger the corresponding bugs are not valid anymore. However, such test cases have been adjusted and kept "for the record". mysql-test/r/func_math.result: Added test cases for bug #8433. Updated results of the test case for bug #31236. mysql-test/r/func_misc.result: Streamlined test cases. mysql-test/r/func_test.result: Streamlined test cases. mysql-test/r/select.result: Streamlined test cases. mysql-test/r/sp.result: Streamlined test cases. mysql-test/r/strict.result: Streamlined test cases. mysql-test/r/type_newdecimal.result: Streamlined test cases. mysql-test/suite/sys_vars/r/sql_slave_skip_counter_basic.result: Streamlined test cases. mysql-test/suite/sys_vars/t/sql_slave_skip_counter_basic.test: Streamlined test cases. mysql-test/t/func_math.test: Added test cases for bug #8433. Updated results of the test case for bug #31236. mysql-test/t/func_misc.test: Streamlined test cases. mysql-test/t/func_test.test: Streamlined test cases. mysql-test/t/select.test: Streamlined test cases. mysql-test/t/sp.test: Streamlined test cases. mysql-test/t/strict.test: Streamlined test cases. mysql-test/t/type_newdecimal.test: Streamlined test cases. sql/item_create.cc: Changed Item_func_cot() to be defined as a standalone Item rather than a combination of "1 / TAN(x)". sql/item_func.cc: Throw an 'out of range' error rather than returning an incorrect value or NULL, when the result of a numeric operator or a function is out of supported range for the corresponding data type. sql/item_func.h: Added validation helpers as inline methods of Item_func. sql/share/errmsg-utf8.txt: New ER_DATA_OUT_OF_RANGE error.
* | Backport of the patch for bug #8457 "Precision math: DIV Alexey Kopytov2009-10-131-0/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | returns incorrect result with large decimal value" For the DIV operator, neither operands nor result were checked for integer overflows. This patch changes the DIV behavior for non-integer operands as follows: if either of the operands has a non-integer type, convert both operands to the DECIMAL type, then calculate the division using DECIMAL arithmetics. Convert the resulting DECIMAL value into BIGINT [UNSIGNED] if it fits into the corresponding range, or throw an 'out of range' error otherwise. mysql-test/r/func_math.result: Added a test case for bug #8457. Fixed results for a test case depending on the wrong behavior. mysql-test/r/type_varchar.result: Fixed results for a test case depending on the wrong behavior. mysql-test/t/func_math.test: Added a test case for bug #8457. sql/item_func.cc: If either of the operands has a non-integer type, convert both operands to the DECIMAL type, then calculate the division using DECIMAL arithmetics. Convert the resulting DECIMAL value into BIGINT [UNSIGNED] if it fits into the corresponding range, or throw an 'out of range' error otherwise.
* 5.0-bugteam->5.1-bugteam mergeSergey Glukhov2009-06-021-0/+9
|\
| * Bug#45152 crash with round() function on longtext column in a derived tableSergey Glukhov2009-06-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The crash happens due to wrong max_length value which is set on Item_func_round::fix_length_and_dec() stage. The value is set to args[0]->max_length which is too big in case of LONGTEXT(LONGBLOB) fields. The fix is to set max_length using float_length() function. mysql-test/r/func_math.result: test result mysql-test/t/func_math.test: test case sql/item_func.cc: The crash happens due to wrong max_length value which is set on Item_func_round::fix_length_and_dec() stage. The value is set to args[0]->max_length which is too big in case of LONGTEXT(LONGBLOB) fields. The fix is to set max_length using float_length() function.
* | Bug #44768: SIGFPE crash when selecting rand from a view containing nullGleb Shchepa2009-05-181-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RAND(N) function where the N is a field of "constant" table (table of single row) failed with a SIGFPE. Evaluation of RAND(N) rely on constant status of its argument. Current server "seeded" random value for each constant argument only once, in the Item_func_rand::fix_fields method. Then the server skipped a call to seed_random() in the Item_func_rand::val_real method for such constant arguments. However, non-constant state of an argument may be changed after the call to fix_fields, if an argument is a field of "constant" table. Thus, pre-initialization of random value in the fix_fields method is too early. Initialization of random value by seed_random() has been removed from Item_func_rand::fix_fields method. The Item_func_rand::val_real method has been modified to call seed_random() on the first evaluation of this method if an argument is a function. mysql-test/r/func_math.result: Added test case for bug #44768. mysql-test/t/func_math.test: Added test case for bug #44768. sql/item_func.cc: Bug #44768: SIGFPE crash when selecting rand from a view containing null 1. Initialization of random value by seed_random() has been removed from Item_func_rand::fix_fields method. 2. The Item_func_rand::val_real method has been modified to call seed_random() on the first evaluation of this method if an argument is a function. sql/item_func.h: Bug #44768: SIGFPE crash when selecting rand from a view containing null 1. The Item_func_rand::first_eval has been added to trace the first evaluation of the val_real method. 2. The Item_func_rand::cleanup method has been added to cleanup the first_eval flag.
* | Manual merge to 5.1.Alexey Kopytov2009-02-231-0/+21
|\ \ | |/
| * Fix for bug #15936: "round" differs on Windows to UnixAlexey Kopytov2009-02-231-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both of our own implementations of rint(3) were inconsistent with the most common behavior of rint() on those platforms that have it: round to nearest, break ties by rounding to nearest even. Fixed by leaving just one implementation of rint() in our source tree, and changing its behavior to match the most common native implementations on other platforms. configure.in: Added checks for fenv.h and fesetround(). include/config-win.h: Removed the incorrect implementation of rint() for Windows. include/my_global.h: Added an rint() implementation for platforms that do not have it. mysql-test/r/func_math.result: Added a test case for bug #15936. mysql-test/t/func_math.test: Added a test case for bug #15936. sql/mysqld.cc: Explicitly set the FPU rounding mode with fesetround().
* | Fix for bug #31236: Inconsistent division by zero behavior for unknown2008-02-201-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. BitKeeper/deleted/.del-matherr.c: Rename: sql/matherr.c -> BitKeeper/deleted/.del-matherr.c configure.in: Removed DONT_USE_FINITE, it is not used anywhere. include/my_global.h: isfinite() is a C99 macro which absoletes finite(). First try to use it, then fall back to finite() if the target platform has it, otherwise use our own implementation. mysql-test/r/func_math.result: Added a test case for bug #31236. mysql-test/r/strict.result: Fixed a test case which relied on old behavior. mysql-test/t/func_math.test: Added a test case for bug #31236. mysql-test/t/strict.test: Fixed a test case which relied on old behavior. sql/field.cc: No need to check if the finite() or its equivalent is available. sql/item_func.cc: Use fix_result() wherever the result can be one of +-inf or nan, assuming the function arguments are valid numbers. Removed fix_result() from functions that are defined for all possible input numbers. sql/item_func.h: Moved fix_result() from Item_dec_func to Item_func which is a common ancestor for Item_dec_func and Item_num_op. sql/unireg.h: Removed POSTFIX_ERROR because no code returns it.
* | merge 5.0-opt -> 5.1-optunknown2007-10-011-2/+0
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | mysql-test/r/func_math.result: Auto merged mysql-test/t/func_math.test: Auto merged mysql-test/t/view_grant.test: Auto merged sql/item_func.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_view.cc: Auto merged
| * removed undeterministic test result from the fux for bug 30587unknown2007-10-011-2/+0
| |