diff options
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/func_math.test | 141 | ||||
-rw-r--r-- | mysql-test/t/func_misc.test | 2 | ||||
-rw-r--r-- | mysql-test/t/func_test.test | 2 | ||||
-rw-r--r-- | mysql-test/t/select.test | 4 | ||||
-rw-r--r-- | mysql-test/t/sp.test | 9 | ||||
-rw-r--r-- | mysql-test/t/strict.test | 1 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 1 |
7 files changed, 151 insertions, 9 deletions
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index b999b1e8c1b..44af2f5ad3f 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -283,12 +283,20 @@ DROP TABLE t1; # # Bug #31236: Inconsistent division by zero behavior for floating point numbers # +# After the fix for bug #8433 we throw an error in the below test cases +# rather than just return a NULL value. +--error ER_DATA_OUT_OF_RANGE SELECT 1e308 + 1e308; +--error ER_DATA_OUT_OF_RANGE SELECT -1e308 - 1e308; +--error ER_DATA_OUT_OF_RANGE SELECT 1e300 * 1e300; +--error ER_DATA_OUT_OF_RANGE SELECT 1e300 / 1e-300; +--error ER_DATA_OUT_OF_RANGE SELECT EXP(750); +--error ER_DATA_OUT_OF_RANGE SELECT POW(10, 309); --echo # @@ -314,10 +322,139 @@ DROP TABLE t1; # DIV returns incorrect result with large decimal value # Bug #46606:Casting error for large numbers in 5.4 when 'div' is used ---error ER_WARN_DATA_OUT_OF_RANGE +--error ER_DATA_OUT_OF_RANGE select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x; ---error ER_WARN_DATA_OUT_OF_RANGE +--error ER_DATA_OUT_OF_RANGE select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x; SHOW WARNINGS; --echo End of 5.1 tests + +--echo # +--echo # Bug #8433: Overflow must be an error +--echo # + +# Floating point overflows +# ======================== +--error ER_DATA_OUT_OF_RANGE +SELECT 1e308 + 1e308; +--error ER_DATA_OUT_OF_RANGE +SELECT -1e308 - 1e308; +--error ER_DATA_OUT_OF_RANGE +SELECT 1e300 * 1e300; +--error ER_DATA_OUT_OF_RANGE +SELECT 1e300 / 1e-300; +--error ER_DATA_OUT_OF_RANGE +SELECT EXP(750); +--error ER_DATA_OUT_OF_RANGE +SELECT POW(10, 309); +--error ER_DATA_OUT_OF_RANGE +SELECT COT(0); +--error ER_DATA_OUT_OF_RANGE +SELECT DEGREES(1e307); + +# Integer overflows +# ================= + +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775808 + 9223372036854775808; +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551615 + 1; +--error ER_DATA_OUT_OF_RANGE +SELECT 1 + 18446744073709551615; +--error ER_DATA_OUT_OF_RANGE +SELECT -2 + CAST(1 AS UNSIGNED); +--error ER_DATA_OUT_OF_RANGE +SELECT CAST(1 AS UNSIGNED) + -2; +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 + -9223372036854775808; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775807 + 9223372036854775807; + +--error ER_DATA_OUT_OF_RANGE +SELECT CAST(0 AS UNSIGNED) - 9223372036854775809; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775808 - 9223372036854775809; +--error ER_DATA_OUT_OF_RANGE +SELECT CAST(1 AS UNSIGNED) - 2; +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551615 - (-1); +--error ER_DATA_OUT_OF_RANGE +SELECT -1 - 9223372036854775808; +--error ER_DATA_OUT_OF_RANGE +SELECT -1 - CAST(1 AS UNSIGNED); +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 - 1; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775807 - -9223372036854775808; + +# To test SIGNED overflow when subtraction arguments are both UNSIGNED +set SQL_MODE='NO_UNSIGNED_SUBTRACTION'; +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551615 - 1; +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551615 - CAST(1 AS UNSIGNED); +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551614 - (-1); +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775807 - -1; +set SQL_MODE=default; + +--error ER_DATA_OUT_OF_RANGE +SELECT 4294967296 * 4294967296; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775808 * 2; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775808 * 2; +# The following one triggers condition #3 from the comments in +# Item_func_mul::int_op() +--error ER_DATA_OUT_OF_RANGE +SELECT 7158278827 * 3221225472; +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775807 * (-2); +--error ER_DATA_OUT_OF_RANGE +SELECT CAST(1 as UNSIGNED) * (-1); +--error ER_DATA_OUT_OF_RANGE +SELECT 9223372036854775807 * 2; + +--error ER_DATA_OUT_OF_RANGE +SELECT ABS(-9223372036854775808); + +--error ER_DATA_OUT_OF_RANGE +SELECT -9223372036854775808 DIV -1; +--error ER_DATA_OUT_OF_RANGE +SELECT 18446744073709551615 DIV -1; + + +# Have to create a table because the negation op may convert literals to DECIMAL +CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED); +INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809); + +--error ER_DATA_OUT_OF_RANGE +SELECT -a FROM t1; +--error ER_DATA_OUT_OF_RANGE +SELECT -b FROM t1; + +DROP TABLE t1; + +# Decimal overflows +# ================= + +SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999; +--error ER_DATA_OUT_OF_RANGE +SELECT @a + @a; +--error ER_DATA_OUT_OF_RANGE +SELECT @a * @a; +--error ER_DATA_OUT_OF_RANGE +SELECT -@a - @a; +--error ER_DATA_OUT_OF_RANGE +SELECT @a / 0.5; + +# Non-overflow tests to improve code coverage +# =========================================== +SELECT COT(1/0); +SELECT -1 + 9223372036854775808; +SELECT 2 DIV -2; +SELECT -(1 DIV 0); +# Crashed the server with SIGFPE before the bugfix +SELECT -9223372036854775808 MOD -1; diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 6590b43f2dc..43cc6de6649 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -22,7 +22,7 @@ select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_ut # between two calls should be -1 set @a= uuid_short(); set @b= uuid_short(); -select cast(@a - @b as signed); +select @b - @a; # # Test for core dump with nan diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 77bf3be5e72..f697e0b477a 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -24,7 +24,7 @@ select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; select 1 like 2 xor 2 like 1; select 10 % 7, 10 mod 7, 10 div 3; explain extended select 10 % 7, 10 mod 7, 10 div 3; -select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2; +select 18446744073709551615, 18446744073709551615 DIV 1, 18446744073709551615 DIV 2; explain extended select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2; create table t1 (a int); diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 80a714882be..1e53461f665 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1989,7 +1989,7 @@ DROP TABLE t1; # create table t1 (a int(11) unsigned, b int(11) unsigned); -insert into t1 values (1,0), (1,1), (1,2); +insert into t1 values (1,0), (1,1), (18446744073709551615,0); select a-b from t1 order by 1; select a-b , (a-b < 0) from t1 order by 1; select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; @@ -2910,6 +2910,7 @@ DROP TABLE t1,t2; # cases to prevent fixing this accidently. It is intended behaviour) # +SET SQL_MODE='NO_UNSIGNED_SUBTRACTION'; CREATE TABLE t1 (i TINYINT UNSIGNED NOT NULL); INSERT t1 SET i = 0; UPDATE t1 SET i = -1; @@ -2919,6 +2920,7 @@ SELECT * FROM t1; UPDATE t1 SET i = i - 1; SELECT * FROM t1; DROP TABLE t1; +SET SQL_MODE=default; # BUG#17379 diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index b4727ad3df7..310803531d9 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -7076,11 +7076,14 @@ select bug20777(9223372036854775807) as '9223372036854775807 2**63-1'; select bug20777(9223372036854775808) as '9223372036854775808 2**63+0'; select bug20777(9223372036854775809) as '9223372036854775809 2**63+1'; select bug20777(9223372036854775810) as '9223372036854775810 2**63+2'; +--error ER_DATA_OUT_OF_RANGE select bug20777(-9223372036854775808) as 'lower bounds signed bigint'; select bug20777(9223372036854775807) as 'upper bounds signed bigint'; +--error ER_DATA_OUT_OF_RANGE select bug20777(0) as 'lower bounds unsigned bigint'; select bug20777(18446744073709551615) as 'upper bounds unsigned bigint'; select bug20777(18446744073709551616) as 'upper bounds unsigned bigint + 1'; +--error ER_DATA_OUT_OF_RANGE select bug20777(-1) as 'lower bounds unsigned bigint - 1'; create table examplebug20777 as select @@ -7091,10 +7094,8 @@ create table examplebug20777 as select bug20777(9223372036854775809) as '2**63+1', bug20777(18446744073709551614) as '2**64-2', bug20777(18446744073709551615) as '2**64-1', - bug20777(18446744073709551616) as '2**64', - bug20777(0) as '0', - bug20777(-1) as '-1'; -insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616, 0, -1); + bug20777(18446744073709551616) as '2**64'; +insert into examplebug20777 values (1, 9223372036854775806, 9223372036854775807, 223372036854775808, 9223372036854775809, 18446744073709551614, 18446744073709551615, 8446744073709551616); show create table examplebug20777; select * from examplebug20777 order by i; diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index d1e136bf5fa..0dd324d5df2 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -822,6 +822,7 @@ INSERT INTO t1 (col2) VALUES (-1.1E-3); INSERT INTO t1 (col1) VALUES ('+1.8E+309'); --error 1264 INSERT INTO t1 (col2) VALUES ('-1.2E-3'); +--error ER_DATA_OUT_OF_RANGE UPDATE t1 SET col1 =col1 * 5000 WHERE col1 > 0; --error 1365 UPDATE t1 SET col2 =col2 / 0 WHERE col2 > 0; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 8af9d4c263e..3f418a339cc 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1090,6 +1090,7 @@ create table t1 (c1 decimal(64)); --disable_ps_protocol insert into t1 values( 89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); +--error ER_DATA_OUT_OF_RANGE insert into t1 values( 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); |