mariadb/mysql-test/r/func_math.result
2020-05-14 11:57:47 +04:00

1773 lines
60 KiB
Text

drop table if exists t1;
select floor(5.5),floor(-5.5);
floor(5.5) floor(-5.5)
5 -6
explain extended select floor(5.5),floor(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select floor(5.5) AS `floor(5.5)`,floor(-5.5) AS `floor(-5.5)`
select ceiling(5.5),ceiling(-5.5);
ceiling(5.5) ceiling(-5.5)
6 -5
explain extended select ceiling(5.5),ceiling(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-5.5) AS `ceiling(-5.5)`
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
52.6 52.64 50 0 -52.6 -50
explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-1) AS `truncate(52.64,-1)`,truncate(52.64,-2) AS `truncate(52.64,-2)`,truncate(-52.64,1) AS `truncate(-52.64,1)`,truncate(-52.64,-1) AS `truncate(-52.64,-1)`
select round(5.5),round(-5.5);
round(5.5) round(-5.5)
6 -6
explain extended select round(5.5),round(-5.5);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select round(5.5,0) AS `round(5.5)`,round(-5.5,0) AS `round(-5.5)`
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
5.6 5.64 10 0
select abs(-10), sign(-5), sign(5), sign(0);
abs(-10) sign(-5) sign(5) sign(0)
10 -1 1 0
explain extended select abs(-10), sign(-5), sign(5), sign(0);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select abs(-10) AS `abs(-10)`,sign(-5) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
Warning 1365 Division by 0
explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select log(exp(10)) AS `log(exp(10))`,exp(log(sqrt(10)) * 2) AS `exp(log(sqrt(10))*2)`,log(-1) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-1,2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
10 10.000000000000002 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select ln(exp(10)) AS `ln(exp(10))`,exp(ln(sqrt(10)) * 2) AS `exp(ln(sqrt(10))*2)`,ln(-1) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3 3.9068905956085187 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-2) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2 1.255272505103306 NULL NULL NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-4) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
select pow(10,log10(10)),power(2,4);
pow(10,log10(10)) power(2,4)
10 16
explain extended select pow(10,log10(10)),power(2,4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)`
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
rand(999999) rand()
0.014231365187309091 0.028870999839968048
explain extended select rand(999999),rand();
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select rand(999999) AS `rand(999999)`,rand() AS `rand()`
select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
pi() format(sin(pi()/2),6) format(cos(pi()/2),6) format(abs(tan(pi())),6) format(cot(1),6) format(asin(1),6) format(acos(0),6) format(atan(1),6)
3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
explain extended select pi(),format(sin(pi()/2),6),format(cos(pi()/2),6),format(abs(tan(pi())),6),format(cot(1),6),format(asin(1),6),format(acos(0),6),format(atan(1),6);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select pi() AS `pi()`,format(sin(pi() / 2),6) AS `format(sin(pi()/2),6)`,format(cos(pi() / 2),6) AS `format(cos(pi()/2),6)`,format(abs(tan(pi())),6) AS `format(abs(tan(pi())),6)`,format(cot(1),6) AS `format(cot(1),6)`,format(asin(1),6) AS `format(asin(1),6)`,format(acos(0),6) AS `format(acos(0),6)`,format(atan(1),6) AS `format(atan(1),6)`
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
180 6.283185307179586
select format(atan(-2, 2), 6);
format(atan(-2, 2), 6)
-0.785398
select format(atan(pi(), 0), 6);
format(atan(pi(), 0), 6)
1.570796
select format(atan2(-2, 2), 6);
format(atan2(-2, 2), 6)
-0.785398
select format(atan2(pi(), 0), 6);
format(atan2(pi(), 0), 6)
1.570796
SELECT ACOS(1.0);
ACOS(1.0)
0
SELECT ASIN(1.0);
ASIN(1.0)
1.5707963267948966
SELECT ACOS(0.2*5.0);
ACOS(0.2*5.0)
0
SELECT ACOS(0.5*2.0);
ACOS(0.5*2.0)
0
SELECT ASIN(0.8+0.2);
ASIN(0.8+0.2)
1.5707963267948966
SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2)
1.5707963267948966
select format(4.55, 1), format(4.551, 1);
format(4.55, 1) format(4.551, 1)
4.6 4.6
explain extended select degrees(pi()),radians(360);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
select rand(rand);
ERROR 42S22: Unknown column 'rand' in 'field list'
create table t1 (col1 int, col2 decimal(60,30));
insert into t1 values(1,1234567890.12345);
select format(col2,7) from t1;
format(col2,7)
1,234,567,890.1234500
select format(col2,8) from t1;
format(col2,8)
1,234,567,890.12345000
insert into t1 values(7,1234567890123456.12345);
select format(col2,6) from t1 where col1=7;
format(col2,6)
1,234,567,890,123,456.123450
drop table t1;
select ceil(0.09);
ceil(0.09)
1
select ceil(0.000000000000000009);
ceil(0.000000000000000009)
1
create table t1 select round(1, 6);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`round(1, 6)` int(1) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t1;
round(1, 6)
1
drop table t1;
select abs(-2) * -2;
abs(-2) * -2
-4
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(1),(1),(2);
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
FROM t1;
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
656 405
122 405
645 405
858 656
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
FROM t1 WHERE a = 1;
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
656 405
122 405
645 405
INSERT INTO t1 VALUES (3);
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
FROM t1;
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
656 405
122 405
645 405
858 656
354 906
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
FROM t1 WHERE a = 1;
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
656 405
122 405
645 405
PREPARE stmt FROM
"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED)
FROM t1 WHERE a = 1";
set @var=2;
EXECUTE stmt USING @var;
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED)
656 656
122 122
645 645
DROP TABLE t1;
set sql_mode="";
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
set sql_mode=default;
insert into t1 values ('http://www.foo.com/', now());
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
a
http://www.foo.com/
drop table t1;
set sql_mode='traditional';
select ln(-1);
ln(-1)
NULL
Warnings:
Warning 1365 Division by 0
select log10(-1);
log10(-1)
NULL
Warnings:
Warning 1365 Division by 0
select log2(-1);
log2(-1)
NULL
Warnings:
Warning 1365 Division by 0
select log(2,-1);
log(2,-1)
NULL
Warnings:
Warning 1365 Division by 0
select log(-2,1);
log(-2,1)
NULL
Warnings:
Warning 1365 Division by 0
set sql_mode='';
select round(111,-10);
round(111,-10)
0
select round(-5000111000111000155,-1);
round(-5000111000111000155,-1)
-5000111000111000160
select round(15000111000111000155,-1);
round(15000111000111000155,-1)
15000111000111000160
select truncate(-5000111000111000155,-1);
truncate(-5000111000111000155,-1)
-5000111000111000150
select truncate(15000111000111000155,-1);
truncate(15000111000111000155,-1)
15000111000111000150
set names utf8;
create table t1
(f1 varchar(32) not null,
f2 smallint(5) unsigned not null,
f3 int(10) unsigned not null default '0')
engine=myisam default charset=utf8;
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
create table t2
(f1 int(10) unsigned not null,
f2 int(10) unsigned not null,
f3 smallint(5) unsigned not null)
engine=myisam default charset=utf8;
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
select format(t2.f2-t2.f1+1,0) from t1,t2
where t1.f2 = t2.f3 order by t1.f1;
format(t2.f2-t2.f1+1,0)
10,000
10,000
drop table t1, t2;
set names latin1;
select cast(-2 as unsigned), 18446744073709551614, -2;
cast(-2 as unsigned) 18446744073709551614 -2
18446744073709551614 18446744073709551614 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
18446744073709551614 18446744073709551614 2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
18446744073709551614 18446744073709551614 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
18446744073709551614 18446744073709551614 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
4294967296 4294967296 NULL
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
18446744073709551614 18446744073709551614 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
4 4 0
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
18446744073709551614 18446744073709551614 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
4 4 0
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
round(10000000000000000000, -19) truncate(10000000000000000000, -19)
10000000000000000000 10000000000000000000
select round(1e0, -309), truncate(1e0, -309);
round(1e0, -309) truncate(1e0, -309)
0 0
select round(1e1,308), truncate(1e1, 308);
round(1e1,308) truncate(1e1, 308)
10 10
select round(1e1, 2147483648), truncate(1e1, 2147483648);
round(1e1, 2147483648) truncate(1e1, 2147483648)
10 10
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295);
round(1.1e1, 4294967295) truncate(1.1e1, 4294967295)
11 11
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296);
round(1.12e1, 4294967296) truncate(1.12e1, 4294967296)
11.2 11.2
select round(1.5, 2147483640), truncate(1.5, 2147483640);
round(1.5, 2147483640) truncate(1.5, 2147483640)
1.50000000000000000000000000000000000000 1.50000000000000000000000000000000000000
select round(1.5, -2147483649), round(1.5, 2147483648);
round(1.5, -2147483649) round(1.5, 2147483648)
0 1.50000000000000000000000000000000000000
select truncate(1.5, -2147483649), truncate(1.5, 2147483648);
truncate(1.5, -2147483649) truncate(1.5, 2147483648)
0 1.50000000000000000000000000000000000000
select round(1.5, -4294967296), round(1.5, 4294967296);
round(1.5, -4294967296) round(1.5, 4294967296)
0 1.50000000000000000000000000000000000000
select truncate(1.5, -4294967296), truncate(1.5, 4294967296);
truncate(1.5, -4294967296) truncate(1.5, 4294967296)
0 1.50000000000000000000000000000000000000
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
round(1.5, -9223372036854775808) round(1.5, 9223372036854775808)
0 1.50000000000000000000000000000000000000
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808)
0 1.50000000000000000000000000000000000000
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615)
1.50000000000000000000000000000000000000 1.50000000000000000000000000000000000000
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
18446744073709551610 18446744073709551610
select round(4, -4294967200), truncate(4, -4294967200);
round(4, -4294967200) truncate(4, -4294967200)
0 0
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
2 2 -2
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
5 5 1
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
2.13598703592091e96 2.13598703592091e96 -32
Warnings:
Note 1105 Cast to unsigned converted negative integer to it's positive complement
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
SELECT a DIV 900 y FROM t1 GROUP BY y;
y
22201025555
22255916666
SELECT DISTINCT a DIV 900 y FROM t1;
y
22201025555
22255916666
SELECT b DIV 900 y FROM t1 GROUP BY y;
y
0
Warnings:
Warning 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: 'str1'
Warning 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1292 Truncated incorrect DECIMAL value: 'str2'
SELECT c DIV 900 y FROM t1 GROUP BY y;
y
0
DROP TABLE t1;
CREATE TABLE t1(a LONGBLOB);
INSERT INTO t1 VALUES('1'),('2'),('3');
SELECT DISTINCT (a DIV 254576881) FROM t1;
(a DIV 254576881)
0
SELECT (a DIV 254576881) FROM t1 UNION ALL
SELECT (a DIV 254576881) FROM t1;
(a DIV 254576881)
0
0
0
0
0
0
DROP TABLE t1;
CREATE TABLE t1(a SET('a','b','c'));
INSERT INTO t1 VALUES ('a');
SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
a DIV 2
0
DROP TABLE t1;
CREATE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (-1.1), (1.1),
(-1.5), (1.5),
(-1.9), (1.9),
(-2.1), (2.1),
(-2.5), (2.5),
(-2.9), (2.9),
# Check numbers with absolute values > 2^53 - 1
# (see comments for MAX_EXACT_INTEGER)
(-1e16 - 0.5), (1e16 + 0.5),
(-1e16 - 1.5), (1e16 + 1.5);
SELECT a, ROUND(a) FROM t1;
a ROUND(a)
-1.1 -1
1.1 1
-1.5 -2
1.5 2
-1.9 -2
1.9 2
-2.1 -2
2.1 2
-2.5 -2
2.5 2
-2.9 -3
2.9 3
-1e16 -10000000000000000
1e16 10000000000000000
-1.0000000000000002e16 -10000000000000002
1.0000000000000002e16 10000000000000002
DROP TABLE t1;
CREATE TABLE t1(f1 LONGTEXT) engine=myisam;
INSERT INTO t1 VALUES ('a');
SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a';
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a';
1
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
Warning 1292 Truncated incorrect INTEGER value: 'a'
DROP TABLE t1;
End of 5.0 tests
SELECT 1e308 + 1e308;
ERROR 22003: DOUBLE value is out of range in '1e308 + 1e308'
SELECT -1e308 - 1e308;
ERROR 22003: DOUBLE value is out of range in '-1e308 - 1e308'
SELECT 1e300 * 1e300;
ERROR 22003: DOUBLE value is out of range in '1e300 * 1e300'
SELECT 1e300 / 1e-300;
ERROR 22003: DOUBLE value is out of range in '1e300 / 1e-300'
SELECT EXP(750);
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
SELECT POW(10, 309);
ERROR 22003: DOUBLE value is out of range in 'pow(10,309)'
#
# Bug #44768: SIGFPE crash when selecting rand from a view
# containing null
#
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
SELECT RAND(a) FROM v1;
RAND(a)
0.15522042769493574
DROP VIEW v1;
SELECT RAND(a) FROM (SELECT NULL AS a) b;
RAND(a)
0.15522042769493574
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (NULL);
SELECT RAND(i) FROM t1;
RAND(i)
0.15522042769493574
DROP TABLE t1;
#
# Bug#57477 SIGFPE when dividing a huge number a negative number
#
SELECT -9999999999999999991 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9999999999999999991 DIV -1'
SELECT -9223372036854775808 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
SELECT -9223372036854775808 MOD -1;
-9223372036854775808 MOD -1
0
SELECT -9223372036854775808999 MOD -1;
-9223372036854775808999 MOD -1
0
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
ERROR 22003: BIGINT value is out of range in '123456789012345678901234567890.123456789012345678901234567890 DIV 1'
select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
ERROR 22003: BIGINT value is out of range in ''123456789012345678901234567890.123456789012345678901234567890' DIV 1'
SHOW WARNINGS;
Level Code Message
Warning 1916 Got overflow when converting '123456789012345678901234567890' to INT. Value truncated
Error 1690 BIGINT value is out of range in ''123456789012345678901234567890.123456789012345678901234567890' DIV 1'
#
# Bug#57810 case/when/then : Assertion failed: length || !scale
#
SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END
NULL
CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`C` varchar(23) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
# Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
#
CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1;
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1;
#
# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
#
CREATE TABLE t1(f1 DECIMAL(22,1));
INSERT INTO t1 VALUES (0),(1);
SELECT ROUND(f1, f1) FROM t1;
ROUND(f1, f1)
0.0
1.0
SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
ROUND(f1, f1)
0.0
1.0
DROP TABLE t1;
#
# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
#
SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'))
-4939092.0000
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
#
# Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
#
SELECT SUM(DISTINCT (TRUNCATE((.1), NULL)));
SUM(DISTINCT (TRUNCATE((.1), NULL)))
NULL
End of 5.1 tests
#
# Bug #8433: Overflow must be an error
#
SELECT 1e308 + 1e308;
ERROR 22003: DOUBLE value is out of range in '1e308 + 1e308'
SELECT -1e308 - 1e308;
ERROR 22003: DOUBLE value is out of range in '-1e308 - 1e308'
SELECT 1e300 * 1e300;
ERROR 22003: DOUBLE value is out of range in '1e300 * 1e300'
SELECT 1e300 / 1e-300;
ERROR 22003: DOUBLE value is out of range in '1e300 / 1e-300'
SELECT EXP(750);
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
SELECT POW(10, 309);
ERROR 22003: DOUBLE value is out of range in 'pow(10,309)'
SELECT COT(0);
ERROR 22003: DOUBLE value is out of range in 'cot(0)'
SELECT DEGREES(1e307);
ERROR 22003: DOUBLE value is out of range in 'degrees(1e307)'
SELECT 9223372036854775808 + 9223372036854775808;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 + 9223372036854775808'
SELECT 18446744073709551615 + 1;
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 + 1'
SELECT 1 + 18446744073709551615;
ERROR 22003: BIGINT UNSIGNED value is out of range in '1 + 18446744073709551615'
SELECT -2 + CAST(1 AS UNSIGNED);
ERROR 22003: BIGINT UNSIGNED value is out of range in '-2 + cast(1 as unsigned)'
SELECT CAST(1 AS UNSIGNED) + -2;
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) + -2'
SELECT -9223372036854775808 + -9223372036854775808;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 + -9223372036854775808'
SELECT 9223372036854775807 + 9223372036854775807;
ERROR 22003: BIGINT value is out of range in '9223372036854775807 + 9223372036854775807'
SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(0 as unsigned) - 9223372036854775809'
SELECT 9223372036854775808 - 9223372036854775809;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 - 9223372036854775809'
SELECT CAST(1 AS UNSIGNED) - 2;
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) - 2'
SELECT 18446744073709551615 - (-1);
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 - -1'
SELECT -1 - 9223372036854775808;
ERROR 22003: BIGINT UNSIGNED value is out of range in '-1 - 9223372036854775808'
SELECT -1 - CAST(1 AS UNSIGNED);
ERROR 22003: BIGINT UNSIGNED value is out of range in '-1 - cast(1 as unsigned)'
SELECT -9223372036854775808 - 1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 - 1'
SELECT 9223372036854775807 - -9223372036854775808;
ERROR 22003: BIGINT value is out of range in '9223372036854775807 - -9223372036854775808'
set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
SELECT 18446744073709551615 - 1;
ERROR 22003: BIGINT value is out of range in '18446744073709551615 - 1'
SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
ERROR 22003: BIGINT value is out of range in '18446744073709551615 - cast(1 as unsigned)'
SELECT 18446744073709551614 - (-1);
ERROR 22003: BIGINT value is out of range in '18446744073709551614 - -1'
SELECT 9223372036854775807 - -1;
ERROR 22003: BIGINT value is out of range in '9223372036854775807 - -1'
set SQL_MODE=default;
SELECT 4294967296 * 4294967296;
ERROR 22003: BIGINT value is out of range in '4294967296 * 4294967296'
SELECT 9223372036854775808 * 2;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 * 2'
SELECT 9223372036854775808 * 2;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 * 2'
SELECT 7158278827 * 3221225472;
ERROR 22003: BIGINT value is out of range in '7158278827 * 3221225472'
SELECT 9223372036854775807 * (-2);
ERROR 22003: BIGINT value is out of range in '9223372036854775807 * -2'
SELECT CAST(1 as UNSIGNED) * (-1);
ERROR 22003: BIGINT UNSIGNED value is out of range in 'cast(1 as unsigned) * -1'
SELECT 9223372036854775807 * 2;
ERROR 22003: BIGINT value is out of range in '9223372036854775807 * 2'
SELECT ABS(-9223372036854775808);
ERROR 22003: BIGINT value is out of range in 'abs(-9223372036854775808)'
SELECT -9223372036854775808 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
SELECT 18446744073709551615 DIV -1;
ERROR 22003: BIGINT UNSIGNED value is out of range in '18446744073709551615 DIV -1'
CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
SELECT -a FROM t1;
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`a`'
SELECT -b FROM t1;
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`b`'
INSERT INTO t1 VALUES(0,0);
SELECT -a FROM t1;
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`a`'
SELECT -b FROM t1;
ERROR 22003: BIGINT value is out of range in '-`test`.`t1`.`b`'
DROP TABLE t1;
SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999;
SELECT @a + @a;
ERROR 22003: DECIMAL value is out of range in '@`a` + @`a`'
SELECT @a * @a;
ERROR 22003: DECIMAL value is out of range in '@`a` * @`a`'
SELECT -@a - @a;
ERROR 22003: DECIMAL value is out of range in '-@`a` - @`a`'
SELECT @a / 0.5;
ERROR 22003: DECIMAL value is out of range in '@`a` / 0.5'
SELECT COT(1/0);
COT(1/0)
NULL
Warnings:
Warning 1365 Division by 0
SELECT -1 + 9223372036854775808;
-1 + 9223372036854775808
9223372036854775807
SELECT 2 DIV -2;
2 DIV -2
-1
SELECT -(1 DIV 0);
-(1 DIV 0)
NULL
Warnings:
Warning 1365 Division by 0
Warning 1365 Division by 0
SELECT -9223372036854775808 MOD -1;
-9223372036854775808 MOD -1
0
#
# Bug #57209 valgrind + Assertion failed: dst > buf
#
SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821)))
as foo;
foo
2
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '53064635.445796e3130837'
Warning 1292 Truncated incorrect DOUBLE value: '179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,0...'
#
# Bug #58137 char(0) column cause:
# my_gcvt: Assertion `width > 0 && to != ((void *)0)' failed
#
CREATE TABLE t1(a char(0));
INSERT IGNORE INTO t1 (SELECT -pi());
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
DROP TABLE t1;
#
# Bug #59241 invalid memory read
# in do_div_mod with doubly assigned variables
#
SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')));
((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')))
NULL
Warnings:
Warning 1918 Encountered illegal value '' when converting to DECIMAL
Warning 1365 Division by 0
#
# Bug #59498 div function broken in mysql-trunk
#
SELECT 1 div null;
1 div null
NULL
#
# Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS
#
select (1.175494351E-37 div 1.7976931348623157E+308);
(1.175494351E-37 div 1.7976931348623157E+308)
0
Warnings:
Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
#
# Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D == N*(-9)
#
select round(999999999, -9);
round(999999999, -9)
1000000000
select round(999999999.0, -9);
round(999999999.0, -9)
1000000000
select round(999999999999999999, -18);
round(999999999999999999, -18)
1000000000000000000
select round(999999999999999999.0, -18);
round(999999999999999999.0, -18)
1000000000000000000
#
# Bug#12537160 ASSERTION FAILED:
# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER.
#
select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo;
foo
0.0
select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo;
foo
NULL
Warnings:
Warning 1365 Division by 0
#
# Bug#12711164 - 61676:
# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE
#
select 5 div 2;
5 div 2
2
select 5.0 div 2.0;
5.0 div 2.0
2
select 5.0 div 2;
5.0 div 2
2
select 5 div 2.0;
5 div 2.0
2
select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2;
5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2
2 617 617283945 6172839450000000000
#
# MDEV-10467 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()
#
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (1),(2);
SELECT STDDEV_SAMP(ROUND('0', 309)) FROM t1;
STDDEV_SAMP(ROUND('0', 309))
0
DROP TABLE t1;
#
# MDEV-20495 Assertion `precision > 0' failed in decimal_bin_size upon CREATE .. SELECT with zerofilled decimal
#
# Testing that dyadic arithmetic operations are symmetric
# for (+1) and (-1) and produce the same length in CONCAT(),
# because (+1) and (-1) have the same data type: signed int.
CREATE TABLE t1 AS SELECT
CONCAT(+1%2.0),
CONCAT(-1%2.0),
CONCAT(+1/2.0),
CONCAT(-1/2.0),
CONCAT(+1*2.0),
CONCAT(-1*2.0),
CONCAT(+1+2.0),
CONCAT(-1+2.0),
CONCAT(+1-2.0),
CONCAT(-1-2.0);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CONCAT(+1%2.0)` varchar(4) DEFAULT NULL,
`CONCAT(-1%2.0)` varchar(4) DEFAULT NULL,
`CONCAT(+1/2.0)` varchar(8) DEFAULT NULL,
`CONCAT(-1/2.0)` varchar(8) DEFAULT NULL,
`CONCAT(+1*2.0)` varchar(5) DEFAULT NULL,
`CONCAT(-1*2.0)` varchar(5) DEFAULT NULL,
`CONCAT(+1+2.0)` varchar(5) DEFAULT NULL,
`CONCAT(-1+2.0)` varchar(5) DEFAULT NULL,
`CONCAT(+1-2.0)` varchar(5) DEFAULT NULL,
`CONCAT(-1-2.0)` varchar(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 AS SELECT
CONCAT(+1%2),
CONCAT(-1%2),
CONCAT(+1/2),
CONCAT(-1/2),
CONCAT(+1*2),
CONCAT(-1*2),
CONCAT(+1+2),
CONCAT(-1+2),
CONCAT(+1-2),
CONCAT(-1-2);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`CONCAT(+1%2)` varchar(2) DEFAULT NULL,
`CONCAT(-1%2)` varchar(2) DEFAULT NULL,
`CONCAT(+1/2)` varchar(7) DEFAULT NULL,
`CONCAT(-1/2)` varchar(7) DEFAULT NULL,
`CONCAT(+1*2)` varchar(3) DEFAULT NULL,
`CONCAT(-1*2)` varchar(3) DEFAULT NULL,
`CONCAT(+1+2)` varchar(3) DEFAULT NULL,
`CONCAT(-1+2)` varchar(3) DEFAULT NULL,
`CONCAT(+1-2)` varchar(3) DEFAULT NULL,
`CONCAT(-1-2)` varchar(3) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
# Bug #29723340: MYSQL SERVER CRASH AFTER SQL QUERY WITH DATA ?AST
#
create table t1(a int);
insert ignore t1 values("1e-214748364");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
insert ignore t1 values("1e-2147483648");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
insert ignore t1 values("1e-21474836480");
Warnings:
Warning 1265 Data truncated for column 'a' at row 1
insert ignore t1 values("1e+214748364");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert ignore t1 values("1e+2147483647");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
insert ignore t1 values("1e+21474836470");
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
set global max_allowed_packet= cast(2*1024*1024*1024+1024 as unsigned);
Warnings:
Warning 1292 Truncated incorrect max_allowed_packet value: '2147484672'
connect foo,localhost,root;
set @a=2147483647;
insert ignore t1 values (concat('1', repeat('0', @a+18), 'e-', @a-1, '0'));
Warnings:
Warning 1301 Result of repeat() was larger than max_allowed_packet (1073741824) - truncated
disconnect foo;
connection default;
set global max_allowed_packet=default;
select * from t1;
a
0
0
0
2147483647
2147483647
2147483647
NULL
drop table t1;
#
# End of 5.5 tests
#
#
# MDEV-5781 Item_sum_std::val_real(): Assertion `nr >= 0.0' fails on query with STDDEV_POP, ROUND and variable
#
SELECT STDDEV_POP(ROUND(0,@A:=2009)) FROM (SELECT 1 UNION SELECT 2) fake_table;
STDDEV_POP(ROUND(0,@A:=2009))
0.0000
#
# Start of 10.1 tests
#
#
# MDEV-17643 Assertion `nr >= 0.0' failed in Item_sum_std::val_real()
#
CREATE TABLE t1 ( pk int NOT NULL, i1 int NOT NULL, d1 date NOT NULL, t1 time);
INSERT INTO t1 VALUES (7,9,'2007-08-15','03:55:02'),(8,7,'1993-06-05','04:17:51'),(9,7,'2034-07-01','17:31:12'),(10,0,'1998-08-24','08:09:27');
SELECT DISTINCT STDDEV_SAMP(EXPORT_SET(t1, -1379790335835635712, (i1 + 'o'), (MD5(d1)))) FROM t1;
STDDEV_SAMP(EXPORT_SET(t1, -1379790335835635712, (i1 + 'o'), (MD5(d1))))
NULL
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: '98e466c7ff40fe6b95cde24200f376303-13797903358356357128e466c7ff40fe6b95cde24200f376303-13797903358356357128e466c7ff40fe6b95cde...'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: '-1379790335835635712e315457d879863c6ccf2ddee5562fc24-1379790335835635712e315457d879863c6ccf2ddee5562fc24-1379790335835635712e...'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: '7b4dd517b633f1f6304b773523b5279747b4dd517b633f1f6304b773523b5279747b4dd517b633f1f6304b773523b527974-1379790335835635712b4dd51...'
Warning 1292 Truncated incorrect DOUBLE value: 'o'
Warning 1292 Truncated incorrect DOUBLE value: '-1379790335835635712b0e107767ea830fd3318893e40412a43-1379790335835635712b0e107767ea830fd3318893e40412a43-1379790335835635712b...'
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(128));
INSERT INTO t1 VALUES ('1e310');
INSERT INTO t1 VALUES ('-1e310');
INSERT INTO t1 VALUES ('0');
SELECT STDDEV_SAMP(a) FROM t1;
STDDEV_SAMP(a)
NULL
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: '1e310'
Warning 1292 Truncated incorrect DOUBLE value: '-1e310'
DROP TABLE t1;
CREATE OR REPLACE TABLE t1 (a DOUBLE);
INSERT INTO t1 VALUES (1.7e+308);
INSERT INTO t1 VALUES (-1.7e+308);
INSERT INTO t1 VALUES (0);
SELECT STDDEV_SAMP(a) FROM t1;
STDDEV_SAMP(a)
NULL
DROP TABLE t1;
#
# MDEV-21977 main.func_math fails due to undefined behaviour
#
SELECT 9223372036854775808 DIV 1;
9223372036854775808 DIV 1
9223372036854775808
SELECT 9223372036854775808 DIV -1;
ERROR 22003: BIGINT UNSIGNED value is out of range in '9223372036854775808 DIV -1'
SELECT -9223372036854775808 DIV 1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV 1'
SELECT -9223372036854775808 DIV -1;
ERROR 22003: BIGINT value is out of range in '-9223372036854775808 DIV -1'
SELECT 9223372036854775808 MOD 1;
9223372036854775808 MOD 1
0
SELECT 9223372036854775808 MOD -1;
9223372036854775808 MOD -1
0
SELECT -9223372036854775808 MOD 1;
-9223372036854775808 MOD 1
0
SELECT -9223372036854775808 MOD -1;
-9223372036854775808 MOD -1
0
SELECT 1 MOD 9223372036854775808;
1 MOD 9223372036854775808
1
SELECT -1 MOD 9223372036854775808;
-1 MOD 9223372036854775808
-1
SELECT 1 MOD -9223372036854775808;
1 MOD -9223372036854775808
1
SELECT -1 MOD -9223372036854775808;
-1 MOD -9223372036854775808
-1
SELECT 9223372036854775808 MOD 9223372036854775808;
9223372036854775808 MOD 9223372036854775808
0
SELECT 9223372036854775808 MOD -9223372036854775808;
9223372036854775808 MOD -9223372036854775808
0
SELECT -9223372036854775808 MOD 9223372036854775808;
-9223372036854775808 MOD 9223372036854775808
0
SELECT -9223372036854775808 MOD -9223372036854775808;
-9223372036854775808 MOD -9223372036854775808
0
#
# MDEV-22502 MDB crashes in CREATE TABLE AS SELECT when the precision of returning type = 0
#
CREATE TABLE t1 (d decimal(5,5));
INSERT INTO t1 VALUES (0.55555);
SELECT TRUNCATE(d,0) FROM t1;
TRUNCATE(d,0)
0
CREATE TABLE t2 AS SELECT TRUNCATE(d,0) FROM t1;
SELECT * FROM t2;
TRUNCATE(d,0)
0
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`TRUNCATE(d,0)` decimal(1,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1, t2;
#
# MDEV-22503 MDB limits DECIMAL column precision to 16 doing CTAS with floor/ceil over DECIMAL(X,Y) where X > 16
#
CREATE TABLE t44 (d1 decimal(38,0) DEFAULT NULL);
INSERT INTO t44 VALUES (12345678901234567890123456789012345678);
SELECT FLOOR(d1) FROM t44;
FLOOR(d1)
12345678901234567890123456789012345678
CREATE TABLE t45 AS SELECT FLOOR(d1) FROM t44;
SELECT * FROM t45;
FLOOR(d1)
12345678901234567890123456789012345678
SHOW CREATE TABLE t45;
Table Create Table
t45 CREATE TABLE `t45` (
`FLOOR(d1)` decimal(38,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t44, t45;
CREATE PROCEDURE p1(prec INT, scale INT)
BEGIN
DECLARE maxval VARCHAR(128) DEFAULT '';
SET @type= CONCAT('DECIMAL(', prec, ',', scale,')');
SET @stmt= CONCAT('CREATE TABLE t1 (a ', @type, ',b ', @type, 'unsigned)');
PREPARE stmt FROM @stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET maxval= CONCAT(REPEAT('9', prec-scale), '.', REPEAT('9',scale));
INSERT INTO t1 VALUES (maxval, maxval);
CREATE TABLE t2 AS SELECT a, b, FLOOR(a) AS fa, FLOOR(b) AS fb FROM t1;
SHOW CREATE TABLE t2;
SELECT * FROM t2;
DROP TABLE t1, t2;
END;
$$
CREATE PROCEDURE p2(prec INT)
BEGIN
DECLARE scale INT DEFAULT 0;
WHILE scale < prec AND scale <= 30 DO
CALL p1(prec, scale);
SET scale= scale + 1;
END WHILE;
END;
$$
CALL p2(38);
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,0) DEFAULT NULL,
`b` decimal(38,0) unsigned DEFAULT NULL,
`fa` decimal(38,0) DEFAULT NULL,
`fb` decimal(38,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999999999999999
b 99999999999999999999999999999999999999
fa 99999999999999999999999999999999999999
fb 99999999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,1) DEFAULT NULL,
`b` decimal(38,1) unsigned DEFAULT NULL,
`fa` decimal(37,0) DEFAULT NULL,
`fb` decimal(37,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999999999999999.9
b 9999999999999999999999999999999999999.9
fa 9999999999999999999999999999999999999
fb 9999999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,2) DEFAULT NULL,
`b` decimal(38,2) unsigned DEFAULT NULL,
`fa` decimal(36,0) DEFAULT NULL,
`fb` decimal(36,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999999999999.99
b 999999999999999999999999999999999999.99
fa 999999999999999999999999999999999999
fb 999999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,3) DEFAULT NULL,
`b` decimal(38,3) unsigned DEFAULT NULL,
`fa` decimal(35,0) DEFAULT NULL,
`fb` decimal(35,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999999999999.999
b 99999999999999999999999999999999999.999
fa 99999999999999999999999999999999999
fb 99999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,4) DEFAULT NULL,
`b` decimal(38,4) unsigned DEFAULT NULL,
`fa` decimal(34,0) DEFAULT NULL,
`fb` decimal(34,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999999999999.9999
b 9999999999999999999999999999999999.9999
fa 9999999999999999999999999999999999
fb 9999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,5) DEFAULT NULL,
`b` decimal(38,5) unsigned DEFAULT NULL,
`fa` decimal(33,0) DEFAULT NULL,
`fb` decimal(33,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999999999.99999
b 999999999999999999999999999999999.99999
fa 999999999999999999999999999999999
fb 999999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,6) DEFAULT NULL,
`b` decimal(38,6) unsigned DEFAULT NULL,
`fa` decimal(32,0) DEFAULT NULL,
`fb` decimal(32,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999999999.999999
b 99999999999999999999999999999999.999999
fa 99999999999999999999999999999999
fb 99999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,7) DEFAULT NULL,
`b` decimal(38,7) unsigned DEFAULT NULL,
`fa` decimal(31,0) DEFAULT NULL,
`fb` decimal(31,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999999999.9999999
b 9999999999999999999999999999999.9999999
fa 9999999999999999999999999999999
fb 9999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,8) DEFAULT NULL,
`b` decimal(38,8) unsigned DEFAULT NULL,
`fa` decimal(30,0) DEFAULT NULL,
`fb` decimal(30,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999999.99999999
b 999999999999999999999999999999.99999999
fa 999999999999999999999999999999
fb 999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,9) DEFAULT NULL,
`b` decimal(38,9) unsigned DEFAULT NULL,
`fa` decimal(29,0) DEFAULT NULL,
`fb` decimal(29,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999999.999999999
b 99999999999999999999999999999.999999999
fa 99999999999999999999999999999
fb 99999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,10) DEFAULT NULL,
`b` decimal(38,10) unsigned DEFAULT NULL,
`fa` decimal(28,0) DEFAULT NULL,
`fb` decimal(28,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999999.9999999999
b 9999999999999999999999999999.9999999999
fa 9999999999999999999999999999
fb 9999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,11) DEFAULT NULL,
`b` decimal(38,11) unsigned DEFAULT NULL,
`fa` decimal(27,0) DEFAULT NULL,
`fb` decimal(27,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999.99999999999
b 999999999999999999999999999.99999999999
fa 999999999999999999999999999
fb 999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,12) DEFAULT NULL,
`b` decimal(38,12) unsigned DEFAULT NULL,
`fa` decimal(26,0) DEFAULT NULL,
`fb` decimal(26,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999.999999999999
b 99999999999999999999999999.999999999999
fa 99999999999999999999999999
fb 99999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,13) DEFAULT NULL,
`b` decimal(38,13) unsigned DEFAULT NULL,
`fa` decimal(25,0) DEFAULT NULL,
`fb` decimal(25,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999.9999999999999
b 9999999999999999999999999.9999999999999
fa 9999999999999999999999999
fb 9999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,14) DEFAULT NULL,
`b` decimal(38,14) unsigned DEFAULT NULL,
`fa` decimal(24,0) DEFAULT NULL,
`fb` decimal(24,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999.99999999999999
b 999999999999999999999999.99999999999999
fa 999999999999999999999999
fb 999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,15) DEFAULT NULL,
`b` decimal(38,15) unsigned DEFAULT NULL,
`fa` decimal(23,0) DEFAULT NULL,
`fb` decimal(23,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999.999999999999999
b 99999999999999999999999.999999999999999
fa 99999999999999999999999
fb 99999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,16) DEFAULT NULL,
`b` decimal(38,16) unsigned DEFAULT NULL,
`fa` decimal(22,0) DEFAULT NULL,
`fb` decimal(22,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999.9999999999999999
b 9999999999999999999999.9999999999999999
fa 9999999999999999999999
fb 9999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,17) DEFAULT NULL,
`b` decimal(38,17) unsigned DEFAULT NULL,
`fa` decimal(21,0) DEFAULT NULL,
`fb` decimal(21,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999.99999999999999999
b 999999999999999999999.99999999999999999
fa 999999999999999999999
fb 999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,18) DEFAULT NULL,
`b` decimal(38,18) unsigned DEFAULT NULL,
`fa` decimal(20,0) DEFAULT NULL,
`fb` decimal(20,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999.999999999999999999
b 99999999999999999999.999999999999999999
fa 99999999999999999999
fb 99999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,19) DEFAULT NULL,
`b` decimal(38,19) unsigned DEFAULT NULL,
`fa` decimal(19,0) DEFAULT NULL,
`fb` decimal(19,0) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999.9999999999999999999
b 9999999999999999999.9999999999999999999
fa 9999999999999999999
fb 9999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,20) DEFAULT NULL,
`b` decimal(38,20) unsigned DEFAULT NULL,
`fa` decimal(18,0) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999.99999999999999999999
b 999999999999999999.99999999999999999999
fa 999999999999999999
fb 999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,21) DEFAULT NULL,
`b` decimal(38,21) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999.999999999999999999999
b 99999999999999999.999999999999999999999
fa 99999999999999999
fb 99999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,22) DEFAULT NULL,
`b` decimal(38,22) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999.9999999999999999999999
b 9999999999999999.9999999999999999999999
fa 9999999999999999
fb 9999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,23) DEFAULT NULL,
`b` decimal(38,23) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999.99999999999999999999999
b 999999999999999.99999999999999999999999
fa 999999999999999
fb 999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,24) DEFAULT NULL,
`b` decimal(38,24) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(16) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999.999999999999999999999999
b 99999999999999.999999999999999999999999
fa 99999999999999
fb 99999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,25) DEFAULT NULL,
`b` decimal(38,25) unsigned DEFAULT NULL,
`fa` bigint(16) DEFAULT NULL,
`fb` bigint(15) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999.9999999999999999999999999
b 9999999999999.9999999999999999999999999
fa 9999999999999
fb 9999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,26) DEFAULT NULL,
`b` decimal(38,26) unsigned DEFAULT NULL,
`fa` bigint(15) DEFAULT NULL,
`fb` bigint(14) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999.99999999999999999999999999
b 999999999999.99999999999999999999999999
fa 999999999999
fb 999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,27) DEFAULT NULL,
`b` decimal(38,27) unsigned DEFAULT NULL,
`fa` bigint(14) DEFAULT NULL,
`fb` bigint(13) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999.999999999999999999999999999
b 99999999999.999999999999999999999999999
fa 99999999999
fb 99999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,28) DEFAULT NULL,
`b` decimal(38,28) unsigned DEFAULT NULL,
`fa` bigint(13) DEFAULT NULL,
`fb` bigint(12) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999.9999999999999999999999999999
b 9999999999.9999999999999999999999999999
fa 9999999999
fb 9999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,29) DEFAULT NULL,
`b` decimal(38,29) unsigned DEFAULT NULL,
`fa` bigint(12) DEFAULT NULL,
`fb` int(11) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999.99999999999999999999999999999
b 999999999.99999999999999999999999999999
fa 999999999
fb 999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(38,30) DEFAULT NULL,
`b` decimal(38,30) unsigned DEFAULT NULL,
`fa` int(11) DEFAULT NULL,
`fb` int(10) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999.999999999999999999999999999999
b 99999999.999999999999999999999999999999
fa 99999999
fb 99999999
CALL p2(30);
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,0) DEFAULT NULL,
`b` decimal(30,0) unsigned DEFAULT NULL,
`fa` decimal(30,0) DEFAULT NULL,
`fb` decimal(31,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999999
b 999999999999999999999999999999
fa 999999999999999999999999999999
fb 999999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,1) DEFAULT NULL,
`b` decimal(30,1) unsigned DEFAULT NULL,
`fa` decimal(29,0) DEFAULT NULL,
`fb` decimal(30,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999999.9
b 99999999999999999999999999999.9
fa 99999999999999999999999999999
fb 99999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,2) DEFAULT NULL,
`b` decimal(30,2) unsigned DEFAULT NULL,
`fa` decimal(28,0) DEFAULT NULL,
`fb` decimal(29,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999999.99
b 9999999999999999999999999999.99
fa 9999999999999999999999999999
fb 9999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,3) DEFAULT NULL,
`b` decimal(30,3) unsigned DEFAULT NULL,
`fa` decimal(27,0) DEFAULT NULL,
`fb` decimal(28,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999999.999
b 999999999999999999999999999.999
fa 999999999999999999999999999
fb 999999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,4) DEFAULT NULL,
`b` decimal(30,4) unsigned DEFAULT NULL,
`fa` decimal(26,0) DEFAULT NULL,
`fb` decimal(27,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999999.9999
b 99999999999999999999999999.9999
fa 99999999999999999999999999
fb 99999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,5) DEFAULT NULL,
`b` decimal(30,5) unsigned DEFAULT NULL,
`fa` decimal(25,0) DEFAULT NULL,
`fb` decimal(26,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999999.99999
b 9999999999999999999999999.99999
fa 9999999999999999999999999
fb 9999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,6) DEFAULT NULL,
`b` decimal(30,6) unsigned DEFAULT NULL,
`fa` decimal(24,0) DEFAULT NULL,
`fb` decimal(25,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999999.999999
b 999999999999999999999999.999999
fa 999999999999999999999999
fb 999999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,7) DEFAULT NULL,
`b` decimal(30,7) unsigned DEFAULT NULL,
`fa` decimal(23,0) DEFAULT NULL,
`fb` decimal(24,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999999.9999999
b 99999999999999999999999.9999999
fa 99999999999999999999999
fb 99999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,8) DEFAULT NULL,
`b` decimal(30,8) unsigned DEFAULT NULL,
`fa` decimal(22,0) DEFAULT NULL,
`fb` decimal(23,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999999.99999999
b 9999999999999999999999.99999999
fa 9999999999999999999999
fb 9999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,9) DEFAULT NULL,
`b` decimal(30,9) unsigned DEFAULT NULL,
`fa` decimal(21,0) DEFAULT NULL,
`fb` decimal(22,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999999.999999999
b 999999999999999999999.999999999
fa 999999999999999999999
fb 999999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,10) DEFAULT NULL,
`b` decimal(30,10) unsigned DEFAULT NULL,
`fa` decimal(20,0) DEFAULT NULL,
`fb` decimal(21,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999999.9999999999
b 99999999999999999999.9999999999
fa 99999999999999999999
fb 99999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,11) DEFAULT NULL,
`b` decimal(30,11) unsigned DEFAULT NULL,
`fa` decimal(19,0) DEFAULT NULL,
`fb` decimal(20,0) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999999.99999999999
b 9999999999999999999.99999999999
fa 9999999999999999999
fb 9999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,12) DEFAULT NULL,
`b` decimal(30,12) unsigned DEFAULT NULL,
`fa` decimal(18,0) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999999.999999999999
b 999999999999999999.999999999999
fa 999999999999999999
fb 999999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,13) DEFAULT NULL,
`b` decimal(30,13) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999999.9999999999999
b 99999999999999999.9999999999999
fa 99999999999999999
fb 99999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,14) DEFAULT NULL,
`b` decimal(30,14) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999999.99999999999999
b 9999999999999999.99999999999999
fa 9999999999999999
fb 9999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,15) DEFAULT NULL,
`b` decimal(30,15) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(17) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999999.999999999999999
b 999999999999999.999999999999999
fa 999999999999999
fb 999999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,16) DEFAULT NULL,
`b` decimal(30,16) unsigned DEFAULT NULL,
`fa` bigint(17) DEFAULT NULL,
`fb` bigint(16) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999999.9999999999999999
b 99999999999999.9999999999999999
fa 99999999999999
fb 99999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,17) DEFAULT NULL,
`b` decimal(30,17) unsigned DEFAULT NULL,
`fa` bigint(16) DEFAULT NULL,
`fb` bigint(15) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999999.99999999999999999
b 9999999999999.99999999999999999
fa 9999999999999
fb 9999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,18) DEFAULT NULL,
`b` decimal(30,18) unsigned DEFAULT NULL,
`fa` bigint(15) DEFAULT NULL,
`fb` bigint(14) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999999.999999999999999999
b 999999999999.999999999999999999
fa 999999999999
fb 999999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,19) DEFAULT NULL,
`b` decimal(30,19) unsigned DEFAULT NULL,
`fa` bigint(14) DEFAULT NULL,
`fb` bigint(13) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999999.9999999999999999999
b 99999999999.9999999999999999999
fa 99999999999
fb 99999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,20) DEFAULT NULL,
`b` decimal(30,20) unsigned DEFAULT NULL,
`fa` bigint(13) DEFAULT NULL,
`fb` bigint(12) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999999.99999999999999999999
b 9999999999.99999999999999999999
fa 9999999999
fb 9999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,21) DEFAULT NULL,
`b` decimal(30,21) unsigned DEFAULT NULL,
`fa` bigint(12) DEFAULT NULL,
`fb` int(11) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999999.999999999999999999999
b 999999999.999999999999999999999
fa 999999999
fb 999999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,22) DEFAULT NULL,
`b` decimal(30,22) unsigned DEFAULT NULL,
`fa` int(11) DEFAULT NULL,
`fb` int(10) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999999.9999999999999999999999
b 99999999.9999999999999999999999
fa 99999999
fb 99999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,23) DEFAULT NULL,
`b` decimal(30,23) unsigned DEFAULT NULL,
`fa` int(10) DEFAULT NULL,
`fb` int(9) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999999.99999999999999999999999
b 9999999.99999999999999999999999
fa 9999999
fb 9999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,24) DEFAULT NULL,
`b` decimal(30,24) unsigned DEFAULT NULL,
`fa` int(9) DEFAULT NULL,
`fb` int(8) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999999.999999999999999999999999
b 999999.999999999999999999999999
fa 999999
fb 999999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,25) DEFAULT NULL,
`b` decimal(30,25) unsigned DEFAULT NULL,
`fa` int(8) DEFAULT NULL,
`fb` int(7) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99999.9999999999999999999999999
b 99999.9999999999999999999999999
fa 99999
fb 99999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,26) DEFAULT NULL,
`b` decimal(30,26) unsigned DEFAULT NULL,
`fa` int(7) DEFAULT NULL,
`fb` int(6) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9999.99999999999999999999999999
b 9999.99999999999999999999999999
fa 9999
fb 9999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,27) DEFAULT NULL,
`b` decimal(30,27) unsigned DEFAULT NULL,
`fa` int(6) DEFAULT NULL,
`fb` int(5) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 999.999999999999999999999999999
b 999.999999999999999999999999999
fa 999
fb 999
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,28) DEFAULT NULL,
`b` decimal(30,28) unsigned DEFAULT NULL,
`fa` int(5) DEFAULT NULL,
`fb` int(4) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 99.9999999999999999999999999999
b 99.9999999999999999999999999999
fa 99
fb 99
Table t2
Create Table CREATE TABLE `t2` (
`a` decimal(30,29) DEFAULT NULL,
`b` decimal(30,29) unsigned DEFAULT NULL,
`fa` int(4) DEFAULT NULL,
`fb` int(3) unsigned DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
a 9.99999999999999999999999999999
b 9.99999999999999999999999999999
fa 9
fb 9
DROP PROCEDURE p2;
DROP PROCEDURE p1;
#
# End of 10.1 tests
#
#
# Start of 10.2 tests
#
# Test zero
select 0=0, 0=-0, 0.0= -0.0, 0.0 = -(0.0), 0.0E1=-0.0E1, 0.0E1=-(0.0E1);
0=0 0=-0 0.0= -0.0 0.0 = -(0.0) 0.0E1=-0.0E1 0.0E1=-(0.0E1)
1 1 1 1 1 1
#
# CRC32 tests
#
select CRC32(NULL), CRC32(''), CRC32('MySQL'), CRC32('mysql'), CRC32('01234567'), CRC32('012345678');
CRC32(NULL) CRC32('') CRC32('MySQL') CRC32('mysql') CRC32('01234567') CRC32('012345678')
NULL 0 3259397556 2501908538 763378421 939184570
explain extended select (3-2)+1, (3/2)*1, 3-(2+1), 3/(2*1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select 3 - 2 + 1 AS `(3-2)+1`,3 / 2 * 1 AS `(3/2)*1`,3 - (2 + 1) AS `3-(2+1)`,3 / (2 * 1) AS `3/(2*1)`