44
44
Note 1003 select abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
45
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
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 NULL NULL NULL 2 NULL NULL
49
Error 1365 Division by 0
50
Error 1365 Division by 0
51
Error 1365 Division by 0
47
10 10.000000000000002 NULL NULL NULL 2 NULL NULL
52
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);
53
49
id select_type table type possible_keys key key_len ref rows filtered Extra
54
50
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
95
82
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
97
84
Note 1003 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 rand(999999) AS `rand(999999)`,rand() AS `rand()`
98
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);
99
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)
100
96
3.141593 1.000000 0.000000 0.000000 0.642093 1.570796 1.570796 0.785398
176
174
select abs(-2) * -2;
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
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
218
insert into t1 values ('http://www.foo.com/', now());
219
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
223
set sql_mode='traditional';
228
Error 1365 Division by 0
233
Error 1365 Division by 0
238
Error 1365 Division by 0
243
Error 1365 Division by 0
248
Error 1365 Division by 0
179
250
select round(111,-10);
191
262
select truncate(15000111000111000155,-1);
192
263
truncate(15000111000111000155,-1)
193
264
15000111000111000150
194
create TEMPORARY table t1
195
267
(f1 varchar(32) not null,
197
f3 int not null default '0')
268
f2 smallint(5) unsigned not null,
269
f3 int(10) unsigned not null default '0')
270
engine=myisam default charset=utf8;
199
271
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
200
create TEMPORARY table t2
273
(f1 int(10) unsigned not null,
274
f2 int(10) unsigned not null,
275
f3 smallint(5) unsigned not null)
276
engine=myisam default charset=utf8;
205
277
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
206
278
select format(t2.f2-t2.f1+1,0) from t1,t2
207
279
where t1.f2 = t2.f3 order by t1.f1;
211
283
drop table t1, t2;
212
select -2, 18446744073709551614, -2;
213
-2 18446744073709551614 -2
214
-2 18446744073709551614 -2
215
select abs(-2), abs(18446744073709551614), abs(-2);
216
abs(-2) abs(18446744073709551614) abs(-2)
217
2 18446744073709551614 2
218
select ceiling(-2), ceiling(18446744073709551614), ceiling(-2);
219
ceiling(-2) ceiling(18446744073709551614) ceiling(-2)
220
-2 18446744073709551614 -2
221
select floor(-2), floor(18446744073709551614), floor(-2);
222
floor(-2) floor(18446744073709551614) floor(-2)
223
-2 18446744073709551614 -2
224
select format(-2, 2), format(18446744073709551614, 2), format(-2, 2);
225
format(-2, 2) format(18446744073709551614, 2) format(-2, 2)
226
-2.00 18,446,744,073,709,551,614.00 -2.00
227
select sqrt(-2), sqrt(18446744073709551614), sqrt(-2);
228
sqrt(-2) sqrt(18446744073709551614) sqrt(-2)
230
select round(-2, 1), round(18446744073709551614, 1), round(-2, 1);
231
round(-2, 1) round(18446744073709551614, 1) round(-2, 1)
232
-2 18446744073709551614 -2
233
select round(4, -2), round(4, 18446744073709551614), round(4, -2);
234
round(4, -2) round(4, 18446744073709551614) round(4, -2)
236
select truncate(-2, 1), truncate(18446744073709551614, 1), truncate(-2, 1);
237
truncate(-2, 1) truncate(18446744073709551614, 1) truncate(-2, 1)
238
-2 18446744073709551614 -2
239
select truncate(4, -2), truncate(4, 18446744073709551614), truncate(4, -2);
240
truncate(4, -2) truncate(4, 18446744073709551614) truncate(4, -2)
285
select cast(-2 as unsigned), 18446744073709551614, -2;
286
cast(-2 as unsigned) 18446744073709551614 -2
287
18446744073709551614 18446744073709551614 -2
288
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
289
abs(cast(-2 as unsigned)) abs(18446744073709551614) abs(-2)
290
18446744073709551614 18446744073709551614 2
291
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
292
ceiling(cast(-2 as unsigned)) ceiling(18446744073709551614) ceiling(-2)
293
18446744073709551614 18446744073709551614 -2
294
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
295
floor(cast(-2 as unsigned)) floor(18446744073709551614) floor(-2)
296
18446744073709551614 18446744073709551614 -2
297
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
298
format(cast(-2 as unsigned), 2) format(18446744073709551614, 2) format(-2, 2)
299
18,446,744,073,709,551,614.00 18,446,744,073,709,551,614.00 -2.00
300
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
301
sqrt(cast(-2 as unsigned)) sqrt(18446744073709551614) sqrt(-2)
302
4294967296 4294967296 NULL
303
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
304
round(cast(-2 as unsigned), 1) round(18446744073709551614, 1) round(-2, 1)
305
18446744073709551614 18446744073709551614 -2
306
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
307
round(4, cast(-2 as unsigned)) round(4, 18446744073709551614) round(4, -2)
309
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
310
truncate(cast(-2 as unsigned), 1) truncate(18446744073709551614, 1) truncate(-2, 1)
311
18446744073709551614 18446744073709551614 -2
312
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
313
truncate(4, cast(-2 as unsigned)) truncate(4, 18446744073709551614) truncate(4, -2)
242
315
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
243
316
round(10000000000000000000, -19) truncate(10000000000000000000, -19)
244
317
10000000000000000000 10000000000000000000
274
347
0 1.500000000000000000000000000000
275
348
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
276
349
round(1.5, -9223372036854775808) round(1.5, 9223372036854775808)
277
0 2.000000000000000000000000000000
350
0 1.500000000000000000000000000000
278
351
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
279
352
truncate(1.5, -9223372036854775808) truncate(1.5, 9223372036854775808)
280
0 1.000000000000000000000000000000
353
0 1.500000000000000000000000000000
281
354
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
282
355
round(1.5, 18446744073709551615) truncate(1.5, 18446744073709551615)
283
0.000000000000000000000000000000 0.000000000000000000000000000000
356
1.500000000000000000000000000000 1.500000000000000000000000000000
284
357
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
285
358
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
286
359
18446744073709551610 18446744073709551610
287
360
select round(4, -4294967200), truncate(4, -4294967200);
288
361
round(4, -4294967200) truncate(4, -4294967200)
290
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3);
291
mod(-2, 3) mod(18446744073709551614, 3) mod(-2, 3)
293
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2);
294
mod(5, -2) mod(5, 18446744073709551614) mod(5, -2)
296
select pow(-2, 5), pow(18446744073709551614, 5), pow(-2, 5);
297
pow(-2, 5) pow(18446744073709551614, 5) pow(-2, 5)
298
-32 2.13598703592091e96 -32
299
CREATE TABLE t1 (a timestamp, b varchar(20), c int);
363
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
364
mod(cast(-2 as unsigned), 3) mod(18446744073709551614, 3) mod(-2, 3)
366
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
367
mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2)
369
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
370
pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5)
371
2.13598703592091e96 2.13598703592091e96 -32
372
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
300
373
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
301
374
SELECT a DIV 900 y FROM t1 GROUP BY y;