1
drop table if exists t1;
2
select floor(5.5),floor(-5.5);
5
explain extended select floor(5.5),floor(-5.5);
6
id select_type table type possible_keys key key_len ref rows filtered Extra
7
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
9
Note 1003 /* select#1 */ select floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
10
select ceiling(5.5),ceiling(-5.5);
11
ceiling(5.5) ceiling(-5.5)
13
explain extended select ceiling(5.5),ceiling(-5.5);
14
id select_type table type possible_keys key key_len ref rows filtered Extra
15
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
17
Note 1003 /* select#1 */ select ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
18
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);
19
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
20
52.6 52.64 50 0 -52.6 -50
21
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);
22
id select_type table type possible_keys key key_len ref rows filtered Extra
23
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
25
Note 1003 /* select#1 */ 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)`
26
select round(5.5),round(-5.5);
27
round(5.5) round(-5.5)
29
explain extended select round(5.5),round(-5.5);
30
id select_type table type possible_keys key key_len ref rows filtered Extra
31
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
33
Note 1003 /* select#1 */ select round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
34
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
35
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
37
select abs(-10), sign(-5), sign(5), sign(0);
38
abs(-10) sign(-5) sign(5) sign(0)
40
explain extended select abs(-10), sign(-5), sign(5), sign(0);
41
id select_type table type possible_keys key key_len ref rows filtered Extra
42
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
44
Note 1003 /* select#1 */ select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
45
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);
46
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
47
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
48
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);
49
id select_type table type possible_keys key key_len ref rows filtered Extra
50
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
52
Note 1003 /* select#1 */ 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)`
53
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
54
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
55
10 10.000000000000002 NULL NULL NULL
56
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
57
id select_type table type possible_keys key key_len ref rows filtered Extra
58
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
60
Note 1003 /* select#1 */ 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)`
61
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
62
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
63
3 3.9068905956085187 NULL NULL NULL
64
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
65
id select_type table type possible_keys key key_len ref rows filtered Extra
66
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
68
Note 1003 /* select#1 */ 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)`
69
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
70
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
71
2 1.255272505103306 NULL NULL NULL
72
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
73
id select_type table type possible_keys key key_len ref rows filtered Extra
74
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
76
Note 1003 /* select#1 */ 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)`
77
select pow(10,log10(10)),power(2,4);
78
pow(10,log10(10)) power(2,4)
80
explain extended select pow(10,log10(10)),power(2,4);
81
id select_type table type possible_keys key key_len ref rows filtered Extra
82
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
84
Note 1003 /* select#1 */ select pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)`
85
set @@rand_seed1=10000000,@@rand_seed2=1000000;
86
select rand(999999),rand();
88
0.014231365187309091 0.028870999839968048
89
explain extended select rand(999999),rand();
90
id select_type table type possible_keys key key_len ref rows filtered Extra
91
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
93
Note 1003 /* select#1 */ select rand(999999) AS `rand(999999)`,rand() AS `rand()`
94
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);
95
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)
96
3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
97
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);
98
id select_type table type possible_keys key key_len ref rows filtered Extra
99
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
101
Note 1003 /* select#1 */ 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)`
102
select degrees(pi()),radians(360);
103
degrees(pi()) radians(360)
104
180 6.283185307179586
105
select format(atan(-2, 2), 6);
106
format(atan(-2, 2), 6)
108
select format(atan(pi(), 0), 6);
109
format(atan(pi(), 0), 6)
111
select format(atan2(-2, 2), 6);
112
format(atan2(-2, 2), 6)
114
select format(atan2(pi(), 0), 6);
115
format(atan2(pi(), 0), 6)
123
SELECT ACOS(0.2*5.0);
126
SELECT ACOS(0.5*2.0);
129
SELECT ASIN(0.8+0.2);
132
SELECT ASIN(1.2-0.2);
135
select format(4.55, 1), format(4.551, 1);
136
format(4.55, 1) format(4.551, 1)
138
explain extended select degrees(pi()),radians(360);
139
id select_type table type possible_keys key key_len ref rows filtered Extra
140
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
142
Note 1003 /* select#1 */ select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
144
ERROR 42S22: Unknown column 'rand' in 'field list'
145
create table t1 (col1 int, col2 decimal(60,30));
146
insert into t1 values(1,1234567890.12345);
147
select format(col2,7) from t1;
149
1,234,567,890.1234500
150
select format(col2,8) from t1;
152
1,234,567,890.12345000
153
insert into t1 values(7,1234567890123456.12345);
154
select format(col2,6) from t1 where col1=7;
156
1,234,567,890,123,456.123450
161
select ceil(0.000000000000000009);
162
ceil(0.000000000000000009)
164
create table t1 select round(1, 6);
165
show create table t1;
167
t1 CREATE TABLE `t1` (
168
`round(1, 6)` int(1) NOT NULL DEFAULT '0'
169
) ENGINE=MyISAM DEFAULT CHARSET=latin1
177
CREATE TABLE t1 (a INT);
178
INSERT INTO t1 VALUES (1),(1),(1),(2);
179
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
181
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
186
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
188
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
192
INSERT INTO t1 VALUES (3);
193
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
195
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
201
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED)
203
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(a) * 1000 AS UNSIGNED)
208
"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED)
209
FROM t1 WHERE a = 1";
211
EXECUTE stmt USING @var;
212
CAST(RAND(2) * 1000 AS UNSIGNED) CAST(RAND(?) * 1000 AS UNSIGNED)
217
SET timestamp=UNIX_TIMESTAMP('2001-01-01 00:00:00');
218
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
219
insert into t1 values ('http://www.foo.com/', now());
220
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
224
Warning 1292 Truncated incorrect time value: '17540424:00:00'
226
SET timestamp=DEFAULT;
227
set sql_mode='traditional';
232
Warning 1365 Division by 0
237
Warning 1365 Division by 0
242
Warning 1365 Division by 0
247
Warning 1365 Division by 0
252
Warning 1365 Division by 0
254
select round(111,-10);
257
select round(-5000111000111000155,-1);
258
round(-5000111000111000155,-1)
260
select round(15000111000111000155,-1);
261
round(15000111000111000155,-1)
263
select truncate(-5000111000111000155,-1);
264
truncate(-5000111000111000155,-1)
266
select truncate(15000111000111000155,-1);
267
truncate(15000111000111000155,-1)
271
(f1 varchar(32) not null,
272
f2 smallint(5) unsigned not null,
273
f3 int(10) unsigned not null default '0')
274
engine=myisam default charset=utf8;
275
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
277
(f1 int(10) unsigned not null,
278
f2 int(10) unsigned not null,
279
f3 smallint(5) unsigned not null)
280
engine=myisam default charset=utf8;
281
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
282
select format(t2.f2-t2.f1+1,0) from t1,t2
283
where t1.f2 = t2.f3 order by t1.f1;
284
format(t2.f2-t2.f1+1,0)
289
select cast(-2 as unsigned), 18446744073709551614, -2;
290
cast(-2 as unsigned) 18446744073709551614 -2
291
18446744073709551614 18446744073709551614 -2
292
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
293
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
294
18446744073709551614 18446744073709551614 2
295
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
296
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
297
18446744073709551614 18446744073709551614 -2
298
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
299
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
300
18446744073709551614 18446744073709551614 -2
301
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
302
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
303
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
304
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
305
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
306
4294967296 4294967296 NULL
307
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
308
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
309
18446744073709551614 18446744073709551614 -2
310
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
311
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
313
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
314
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
315
18446744073709551614 18446744073709551614 -2
316
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
317
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
319
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
320
round(10000000000000000000, -19) truncate(10000000000000000000, -19)
321
10000000000000000000 10000000000000000000
322
select round(1e0, -309), truncate(1e0, -309);
323
round(1e0, -309) truncate(1e0, -309)
325
select round(1e1,308), truncate(1e1, 308);
326
round(1e1,308) truncate(1e1, 308)
328
select round(1e1, 2147483648), truncate(1e1, 2147483648);
329
round(1e1, 2147483648) truncate(1e1, 2147483648)
331
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295);
332
round(1.1e1, 4294967295) truncate(1.1e1, 4294967295)
334
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296);
335
round(1.12e1, 4294967296) truncate(1.12e1, 4294967296)
337
select round(1.5, 2147483640), truncate(1.5, 2147483640);
338
round(1.5, 2147483640) truncate(1.5, 2147483640)
339
1.500000000000000000000000000000 1.500000000000000000000000000000
340
select round(1.5, -2147483649), round(1.5, 2147483648);
341
round(1.5, -2147483649) round(1.5, 2147483648)
342
0 1.500000000000000000000000000000
343
select truncate(1.5, -2147483649), truncate(1.5, 2147483648);
344
truncate(1.5, -2147483649) truncate(1.5, 2147483648)
345
0 1.500000000000000000000000000000
346
select round(1.5, -4294967296), round(1.5, 4294967296);
347
round(1.5, -4294967296) round(1.5, 4294967296)
348
0 1.500000000000000000000000000000
349
select truncate(1.5, -4294967296), truncate(1.5, 4294967296);
350
truncate(1.5, -4294967296) truncate(1.5, 4294967296)
351
0 1.500000000000000000000000000000
352
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
353
round(1.5, -9223372036854775808) round(1.5, 9223372036854775808)
354
0 1.500000000000000000000000000000
355
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
356
truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808)
357
0 1.500000000000000000000000000000
358
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
359
round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615)
360
1.500000000000000000000000000000 1.500000000000000000000000000000
361
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
362
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
363
18446744073709551610 18446744073709551610
364
select round(4, -4294967200), truncate(4, -4294967200);
365
round(4, -4294967200) truncate(4, -4294967200)
367
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
368
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
370
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
371
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
373
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
374
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
375
2.13598703592091e96 2.13598703592091e96 -32
376
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
377
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
378
SELECT a DIV 900 y FROM t1 GROUP BY y;
382
SELECT DISTINCT a DIV 900 y FROM t1;
386
SELECT b DIV 900 y FROM t1 GROUP BY y;
390
Warning 1366 Incorrect decimal value: '' for column '' at row -1
391
Warning 1292 Truncated incorrect DECIMAL value: 'str1'
392
Warning 1366 Incorrect decimal value: '' for column '' at row -1
393
Warning 1292 Truncated incorrect DECIMAL value: 'str2'
394
SELECT c DIV 900 y FROM t1 GROUP BY y;
398
CREATE TABLE t1(a LONGBLOB);
399
INSERT INTO t1 VALUES('1'),('2'),('3');
400
SELECT DISTINCT (a DIV 254576881) FROM t1;
403
SELECT (a DIV 254576881) FROM t1 UNION ALL
404
SELECT (a DIV 254576881) FROM t1;
413
CREATE TABLE t1(a SET('a','b','c'));
414
INSERT INTO t1 VALUES ('a');
415
SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
419
CREATE TABLE t1 (a DOUBLE);
420
INSERT INTO t1 VALUES (-1.1), (1.1),
426
# Check numbers with absolute values > 2^53 - 1
427
# (see comments for MAX_EXACT_INTEGER)
428
(-1e16 - 0.5), (1e16 + 0.5),
429
(-1e16 - 1.5), (1e16 + 1.5);
430
SELECT a, ROUND(a) FROM t1;
444
-1e16 -10000000000000000
445
1e16 10000000000000000
446
-1.0000000000000002e16 -10000000000000002
447
1.0000000000000002e16 10000000000000002
449
CREATE TABLE t1(f1 LONGTEXT) engine=myisam;
450
INSERT INTO t1 VALUES ('a');
451
SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a';
453
SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a';
457
SELECT 1e308 + 1e308;
458
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
459
SELECT -1e308 - 1e308;
460
ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
461
SELECT 1e300 * 1e300;
462
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
463
SELECT 1e300 / 1e-300;
464
ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)'
466
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
468
ERROR 22003: DOUBLE value is out of range in 'pow(10,309)'
470
# Bug #44768: SIGFPE crash when selecting rand from a view
473
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
474
SELECT RAND(a) FROM v1;
478
SELECT RAND(a) FROM (SELECT NULL AS a) b;
481
CREATE TABLE t1 (i INT);
482
INSERT INTO t1 VALUES (NULL);
483
SELECT RAND(i) FROM t1;
488
# Bug#57477 SIGFPE when dividing a huge number a negative number
490
SELECT -9999999999999999991 DIV -1;
491
ERROR 22003: BIGINT value is out of range in '(-(9999999999999999991) DIV -(1))'
492
SELECT -9223372036854775808 DIV -1;
493
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
494
SELECT -9223372036854775808 MOD -1;
495
-9223372036854775808 MOD -1
497
SELECT -9223372036854775808999 MOD -1;
498
-9223372036854775808999 MOD -1
500
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
501
ERROR 22003: BIGINT value is out of range in '(123456789012345678901234567890.123456789012345678901234567890 DIV 1)'
502
select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
503
ERROR 22003: BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)'
506
Warning 1292 Truncated incorrect DECIMAL value: ''
507
Error 1690 BIGINT value is out of range in '('123456789012345678901234567890.123456789012345678901234567890' DIV 1)'
509
# Bug#57810 case/when/then : Assertion failed: length || !scale
511
SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
512
CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END
514
CREATE TABLE t1 SELECT CAST((CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END) AS CHAR) as C;
515
SHOW CREATE TABLE t1;
517
t1 CREATE TABLE `t1` (
518
`C` varchar(23) DEFAULT NULL
519
) ENGINE=MyISAM DEFAULT CHARSET=latin1
522
# Bug#11764994 57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
524
CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
526
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
529
# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
531
CREATE TABLE t1(f1 DECIMAL(22,1));
532
INSERT INTO t1 VALUES (0),(1);
533
SELECT ROUND(f1, f1) FROM t1;
537
SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
543
# Bug#11764671 57533: UNINITIALISED VALUES IN COPY_AND_CONVERT (SQL_STRING.CC) WITH CERTAIN CHA
545
SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
546
ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'))
549
Warning 1292 Truncated incorrect DOUBLE value: 'a'
551
# Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
553
SELECT SUM(DISTINCT (TRUNCATE((.1), NULL)));
554
SUM(DISTINCT (TRUNCATE((.1), NULL)))
558
# Bug #8433: Overflow must be an error
560
SELECT 1e308 + 1e308;
561
ERROR 22003: DOUBLE value is out of range in '(1e308 + 1e308)'
562
SELECT -1e308 - 1e308;
563
ERROR 22003: DOUBLE value is out of range in '(-(1e308) - 1e308)'
564
SELECT 1e300 * 1e300;
565
ERROR 22003: DOUBLE value is out of range in '(1e300 * 1e300)'
566
SELECT 1e300 / 1e-300;
567
ERROR 22003: DOUBLE value is out of range in '(1e300 / 1e-300)'
569
ERROR 22003: DOUBLE value is out of range in 'exp(750)'
571
ERROR 22003: DOUBLE value is out of range in 'pow(10,309)'
573
ERROR 22003: DOUBLE value is out of range in 'cot(0)'
574
SELECT DEGREES(1e307);
575
ERROR 22003: DOUBLE value is out of range in 'degrees(1e307)'
576
SELECT 9223372036854775808 + 9223372036854775808;
577
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 + 9223372036854775808)'
578
SELECT 18446744073709551615 + 1;
579
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 + 1)'
580
SELECT 1 + 18446744073709551615;
581
ERROR 22003: BIGINT UNSIGNED value is out of range in '(1 + 18446744073709551615)'
582
SELECT -2 + CAST(1 AS UNSIGNED);
583
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(2) + cast(1 as unsigned))'
584
SELECT CAST(1 AS UNSIGNED) + -2;
585
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) + -(2))'
586
SELECT -9223372036854775808 + -9223372036854775808;
587
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) + -(9223372036854775808))'
588
SELECT 9223372036854775807 + 9223372036854775807;
589
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 + 9223372036854775807)'
590
SELECT CAST(0 AS UNSIGNED) - 9223372036854775809;
591
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(0 as unsigned) - 9223372036854775809)'
592
SELECT 9223372036854775808 - 9223372036854775809;
593
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 - 9223372036854775809)'
594
SELECT CAST(1 AS UNSIGNED) - 2;
595
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) - 2)'
596
SELECT 18446744073709551615 - (-1);
597
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 - -(1))'
598
SELECT -1 - 9223372036854775808;
599
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - 9223372036854775808)'
600
SELECT -1 - CAST(1 AS UNSIGNED);
601
ERROR 22003: BIGINT UNSIGNED value is out of range in '(-(1) - cast(1 as unsigned))'
602
SELECT -9223372036854775808 - 1;
603
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) - 1)'
604
SELECT 9223372036854775807 - -9223372036854775808;
605
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(9223372036854775808))'
606
set SQL_MODE='NO_UNSIGNED_SUBTRACTION';
607
SELECT 18446744073709551615 - 1;
608
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - 1)'
609
SELECT 18446744073709551615 - CAST(1 AS UNSIGNED);
610
ERROR 22003: BIGINT value is out of range in '(18446744073709551615 - cast(1 as unsigned))'
611
SELECT 18446744073709551614 - (-1);
612
ERROR 22003: BIGINT value is out of range in '(18446744073709551614 - -(1))'
613
SELECT 9223372036854775807 - -1;
614
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 - -(1))'
615
set SQL_MODE=default;
616
SELECT 4294967296 * 4294967296;
617
ERROR 22003: BIGINT value is out of range in '(4294967296 * 4294967296)'
618
SELECT 9223372036854775808 * 2;
619
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)'
620
SELECT 9223372036854775808 * 2;
621
ERROR 22003: BIGINT UNSIGNED value is out of range in '(9223372036854775808 * 2)'
622
SELECT 7158278827 * 3221225472;
623
ERROR 22003: BIGINT value is out of range in '(7158278827 * 3221225472)'
624
SELECT 9223372036854775807 * (-2);
625
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * -(2))'
626
SELECT CAST(1 as UNSIGNED) * (-1);
627
ERROR 22003: BIGINT UNSIGNED value is out of range in '(cast(1 as unsigned) * -(1))'
628
SELECT 9223372036854775807 * 2;
629
ERROR 22003: BIGINT value is out of range in '(9223372036854775807 * 2)'
630
SELECT ABS(-9223372036854775808);
631
ERROR 22003: BIGINT value is out of range in 'abs(-(9223372036854775808))'
632
SELECT -9223372036854775808 DIV -1;
633
ERROR 22003: BIGINT value is out of range in '(-(9223372036854775808) DIV -(1))'
634
SELECT 18446744073709551615 DIV -1;
635
ERROR 22003: BIGINT UNSIGNED value is out of range in '(18446744073709551615 DIV -(1))'
636
CREATE TABLE t1(a BIGINT, b BIGINT UNSIGNED);
637
INSERT INTO t1 VALUES(-9223372036854775808, 9223372036854775809);
639
ERROR 22003: BIGINT value is out of range in '-('-9223372036854775808')'
641
ERROR 22003: BIGINT value is out of range in '-('9223372036854775809')'
643
SET @a:=999999999999999999999999999999999999999999999999999999999999999999999999999999999;
645
ERROR 22003: DECIMAL value is out of range in '((@`a`) + (@`a`))'
647
ERROR 22003: DECIMAL value is out of range in '((@`a`) * (@`a`))'
649
ERROR 22003: DECIMAL value is out of range in '(-((@`a`)) - (@`a`))'
651
ERROR 22003: DECIMAL value is out of range in '((@`a`) / 0.5)'
655
SELECT -1 + 9223372036854775808;
656
-1 + 9223372036854775808
664
SELECT -9223372036854775808 MOD -1;
665
-9223372036854775808 MOD -1
668
# Bug #57209 valgrind + Assertion failed: dst > buf
670
SELECT floor(log10(format(concat_ws(5445796E25, 5306463, 30837), -358821)))
675
# Bug #58137 char(0) column cause:
676
# my_gcvt: Assertion `width > 0 && to != ((void *)0)' failed
678
CREATE TABLE t1(a char(0));
679
INSERT INTO t1 (SELECT -pi());
681
Warning 1265 Data truncated for column 'a' at row 1
684
# Bug #59241 invalid memory read
685
# in do_div_mod with doubly assigned variables
687
SELECT ((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')));
688
((@a:=@b:=1.0) div (@b:=@a:=get_format(datetime, 'usa')))
691
Warning 1366 Incorrect decimal value: '' for column '' at row -1
693
# Bug #59498 div function broken in mysql-trunk
699
# Bug #11792200 - DIVIDING LARGE NUMBERS CAUSES STACK CORRUPTIONS
701
select (1.175494351E-37 div 1.7976931348623157E+308);
702
(1.175494351E-37 div 1.7976931348623157E+308)
705
Warning 1292 Truncated incorrect DECIMAL value: ''
707
# Bug#12744991 - DECIMAL_ROUND(X,D) GIVES WRONG RESULTS WHEN D == N*(-9)
709
select round(999999999, -9);
712
select round(999999999.0, -9);
713
round(999999999.0, -9)
715
select round(999999999999999999, -18);
716
round(999999999999999999, -18)
718
select round(999999999999999999.0, -18);
719
round(999999999999999999.0, -18)
722
# Bug#12537160 ASSERTION FAILED:
723
# STOP0 <= &TO->BUF[TO->LEN] WITH LARGE NUMBER.
725
select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.1 as foo;
728
select 999999999999999999999999999999999999999999999999999999999999999999999999999999999 % 0.0 as foo;
732
# Bug#12711164 - 61676:
733
# RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE
747
select 5.9 div 2, 1.23456789e3 DIV 2, 1.23456789e9 DIV 2, 1.23456789e19 DIV 2;
748
5.9 div 2 1.23456789e3 DIV 2 1.23456789e9 DIV 2 1.23456789e19 DIV 2
749
2 617 617283945 6172839450000000000