~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/r/func_math.result

  • Committer: Brian Aker
  • Date: 2008-07-07 14:25:25 UTC
  • mto: (77.1.25 codestyle)
  • mto: This revision was merged to the branch mainline in revision 82.
  • Revision ID: brian@tangent.org-20080707142525-xzy2nl3ie2ebwfln
LL() cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
47
10      10.000000000000002      NULL    NULL    NULL    2       NULL    NULL
48
 
Warnings:
49
 
Error   1365    Division by 0
50
 
Error   1365    Division by 0
51
 
Error   1365    Division by 0
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
57
53
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
58
54
ln(exp(10))     exp(ln(sqrt(10))*2)     ln(-1)  ln(0)   ln(NULL)
59
55
10      10.000000000000002      NULL    NULL    NULL
60
 
Warnings:
61
 
Error   1365    Division by 0
62
 
Error   1365    Division by 0
63
56
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
64
57
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
65
58
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
68
61
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
69
62
log2(8) log2(15)        log2(-2)        log2(0) log2(NULL)
70
63
3       3.9068905956085187      NULL    NULL    NULL
71
 
Warnings:
72
 
Error   1365    Division by 0
73
 
Error   1365    Division by 0
74
64
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
75
65
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
76
66
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
79
69
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
80
70
log10(100)      log10(18)       log10(-4)       log10(0)        log10(NULL)
81
71
2       1.255272505103306       NULL    NULL    NULL
82
 
Warnings:
83
 
Error   1365    Division by 0
84
 
Error   1365    Division by 0
85
72
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
86
73
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
87
74
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
178
165
show create table t1;
179
166
Table   Create Table
180
167
t1      CREATE TABLE `t1` (
181
 
  `round(1, 6)` int NOT NULL
182
 
) ENGINE=X
 
168
  `round(1, 6)` int(1) NOT NULL DEFAULT '0'
 
169
) ENGINE=MyISAM DEFAULT CHARSET=latin1
183
170
select * from t1;
184
171
round(1, 6)
185
172
1
189
176
-4
190
177
CREATE TABLE t1 (a INT);
191
178
INSERT INTO t1 VALUES (1),(1),(1),(2);
192
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
193
 
RAND(2) * 1000  RAND(a) * 1000
194
 
655.5866465490186       405.40353712197725
195
 
122.34661925802624      405.40353712197725
196
 
644.97318737672 405.40353712197725
197
 
857.8261098431667       655.5866465490186
198
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1 WHERE a = 1;
199
 
RAND(2) * 1000  RAND(a) * 1000
200
 
655.5866465490186       405.40353712197725
201
 
122.34661925802624      405.40353712197725
202
 
644.97318737672 405.40353712197725
 
179
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
180
FROM t1;
 
181
CAST(RAND(2) * 1000 AS UNSIGNED)        CAST(RAND(a) * 1000 AS UNSIGNED)
 
182
656     405
 
183
122     405
 
184
645     405
 
185
858     656
 
186
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
187
FROM t1 WHERE a = 1;
 
188
CAST(RAND(2) * 1000 AS UNSIGNED)        CAST(RAND(a) * 1000 AS UNSIGNED)
 
189
656     405
 
190
122     405
 
191
645     405
203
192
INSERT INTO t1 VALUES (3);
204
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
205
 
RAND(2) * 1000  RAND(a) * 1000
206
 
655.5866465490186       405.40353712197725
207
 
122.34661925802624      405.40353712197725
208
 
644.97318737672 405.40353712197725
209
 
857.8261098431667       655.5866465490186
210
 
354.21101781931804      905.7697559760601
211
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1 WHERE a = 1;
212
 
RAND(2) * 1000  RAND(a) * 1000
213
 
655.5866465490186       405.40353712197725
214
 
122.34661925802624      405.40353712197725
215
 
644.97318737672 405.40353712197725
 
193
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
194
FROM t1;
 
195
CAST(RAND(2) * 1000 AS UNSIGNED)        CAST(RAND(a) * 1000 AS UNSIGNED)
 
196
656     405
 
197
122     405
 
198
645     405
 
199
858     656
 
200
354     906
 
201
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
202
FROM t1 WHERE a = 1;
 
203
CAST(RAND(2) * 1000 AS UNSIGNED)        CAST(RAND(a) * 1000 AS UNSIGNED)
 
204
656     405
 
205
122     405
 
206
645     405
 
207
PREPARE stmt FROM 
 
208
"SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED)
 
209
    FROM t1 WHERE a = 1";
 
210
set @var=2;
 
211
EXECUTE stmt USING @var;
 
212
CAST(RAND(2) * 1000 AS UNSIGNED)        CAST(RAND(?) * 1000 AS UNSIGNED)
 
213
656     656
 
214
122     122
 
215
645     645
216
216
DROP TABLE t1;
217
 
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb;
 
217
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
218
218
insert into t1 values ('http://www.foo.com/', now());
219
219
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
220
220
a
221
221
http://www.foo.com/
222
222
drop table t1;
 
223
set sql_mode='traditional';
 
224
select ln(-1);
 
225
ln(-1)
 
226
NULL
 
227
Warnings:
 
228
Error   1365    Division by 0
 
229
select log10(-1);
 
230
log10(-1)
 
231
NULL
 
232
Warnings:
 
233
Error   1365    Division by 0
 
234
select log2(-1);
 
235
log2(-1)
 
236
NULL
 
237
Warnings:
 
238
Error   1365    Division by 0
 
239
select log(2,-1);
 
240
log(2,-1)
 
241
NULL
 
242
Warnings:
 
243
Error   1365    Division by 0
 
244
select log(-2,1);
 
245
log(-2,1)
 
246
NULL
 
247
Warnings:
 
248
Error   1365    Division by 0
 
249
set sql_mode='';
223
250
select round(111,-10);
224
251
round(111,-10)
225
252
0
235
262
select truncate(15000111000111000155,-1);
236
263
truncate(15000111000111000155,-1)
237
264
15000111000111000150
 
265
set names utf8;
238
266
create table t1
239
267
(f1 varchar(32) not null,
240
 
f2 int not null,
241
 
f3 int not null default '0')
242
 
engine=myisam;
 
268
f2 smallint(5) unsigned not null,
 
269
f3 int(10) unsigned not null default '0')
 
270
engine=myisam default charset=utf8;
243
271
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
244
272
create table t2
245
 
(f1 int not null,
246
 
f2 int not null,
247
 
f3 int not null)
248
 
engine=myisam;
 
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;
249
277
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
250
278
select format(t2.f2-t2.f1+1,0) from t1,t2
251
279
where t1.f2 = t2.f3 order by t1.f1;
253
281
10,000
254
282
10,000
255
283
drop table t1, t2;
256
 
select -2, 18446744073709551614, -2;
257
 
-2      18446744073709551614    -2
258
 
-2      18446744073709551614    -2
259
 
select abs(-2), abs(18446744073709551614), abs(-2);
260
 
abs(-2) abs(18446744073709551614)       abs(-2)
261
 
2       18446744073709551614    2
262
 
select ceiling(-2), ceiling(18446744073709551614), ceiling(-2);
263
 
ceiling(-2)     ceiling(18446744073709551614)   ceiling(-2)
264
 
-2      18446744073709551614    -2
265
 
select floor(-2), floor(18446744073709551614), floor(-2);
266
 
floor(-2)       floor(18446744073709551614)     floor(-2)
267
 
-2      18446744073709551614    -2
268
 
select format(-2, 2), format(18446744073709551614, 2), format(-2, 2);
269
 
format(-2, 2)   format(18446744073709551614, 2) format(-2, 2)
270
 
-2.00   18,446,744,073,709,551,614.00   -2.00
271
 
select sqrt(-2), sqrt(18446744073709551614), sqrt(-2);
272
 
sqrt(-2)        sqrt(18446744073709551614)      sqrt(-2)
273
 
NULL    4294967296      NULL
274
 
select round(-2, 1), round(18446744073709551614, 1), round(-2, 1);
275
 
round(-2, 1)    round(18446744073709551614, 1)  round(-2, 1)
276
 
-2      18446744073709551614    -2
277
 
select round(4, -2), round(4, 18446744073709551614), round(4, -2);
278
 
round(4, -2)    round(4, 18446744073709551614)  round(4, -2)
279
 
0       4       0
280
 
select truncate(-2, 1), truncate(18446744073709551614, 1), truncate(-2, 1);
281
 
truncate(-2, 1) truncate(18446744073709551614, 1)       truncate(-2, 1)
282
 
-2      18446744073709551614    -2
283
 
select truncate(4, -2), truncate(4, 18446744073709551614), truncate(4, -2);
284
 
truncate(4, -2) truncate(4, 18446744073709551614)       truncate(4, -2)
285
 
0       4       0
 
284
set names default;
 
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)
 
308
4       4       0
 
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)
 
314
4       4       0
286
315
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
287
316
round(10000000000000000000, -19)        truncate(10000000000000000000, -19)
288
317
10000000000000000000    10000000000000000000
318
347
0       1.500000000000000000000000000000
319
348
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
320
349
round(1.5, -9223372036854775808)        round(1.5, 9223372036854775808)
321
 
0       2.000000000000000000000000000000
 
350
0       1.500000000000000000000000000000
322
351
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
323
352
truncate(1.5, -9223372036854775808)     truncate(1.5, 9223372036854775808)
324
 
0       1.000000000000000000000000000000
 
353
0       1.500000000000000000000000000000
325
354
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
326
355
round(1.5, 18446744073709551615)        truncate(1.5, 18446744073709551615)
327
 
0.000000000000000000000000000000        0.000000000000000000000000000000
 
356
1.500000000000000000000000000000        1.500000000000000000000000000000
328
357
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
329
358
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
330
359
18446744073709551610    18446744073709551610
331
360
select round(4, -4294967200), truncate(4, -4294967200);
332
361
round(4, -4294967200)   truncate(4, -4294967200)
333
362
0       0
334
 
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3);
335
 
mod(-2, 3)      mod(18446744073709551614, 3)    mod(-2, 3)
336
 
-2      2       -2
337
 
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2);
338
 
mod(5, -2)      mod(5, 18446744073709551614)    mod(5, -2)
339
 
1       5       1
340
 
select pow(-2, 5), pow(18446744073709551614, 5), pow(-2, 5);
341
 
pow(-2, 5)      pow(18446744073709551614, 5)    pow(-2, 5)
342
 
-32     2.13598703592091e96     -32
343
 
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)
 
365
2       2       -2
 
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)
 
368
5       5       1
 
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));
344
373
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
345
374
SELECT a DIV 900 y FROM t1 GROUP BY y;
346
375
y
372
401
0
373
402
0
374
403
DROP TABLE t1;
 
404
CREATE TABLE t1(a SET('a','b','c'));
 
405
INSERT INTO t1 VALUES ('a');
 
406
SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
 
407
a DIV 2
 
408
0
 
409
DROP TABLE t1;
375
410
End of 5.0 tests
376
411
SELECT 1e308 + 1e308;
377
412
1e308 + 1e308