~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Renamed more stuff to drizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
48
 
Warnings:
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
56
52
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)`
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
 
10      10      NULL    NULL    NULL
60
 
Warnings:
61
 
Error   1365    Division by 0
62
 
Error   1365    Division by 0
 
55
10      10.000000000000002      NULL    NULL    NULL
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
67
60
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)`
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
 
3       3.90689059560852        NULL    NULL    NULL
71
 
Warnings:
72
 
Error   1365    Division by 0
73
 
Error   1365    Division by 0
 
63
3       3.9068905956085187      NULL    NULL    NULL
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
78
68
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)`
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
 
2       1.25527250510331        NULL    NULL    NULL
82
 
Warnings:
83
 
Error   1365    Division by 0
84
 
Error   1365    Division by 0
 
71
2       1.255272505103306       NULL    NULL    NULL
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
95
82
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
96
83
Warnings:
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();
 
87
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
 
92
Warnings:
 
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
105
101
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((1 / tan(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)`
106
102
select degrees(pi()),radians(360);
107
103
degrees(pi())   radians(360)
108
 
180     6.28318530717959
 
104
180     6.283185307179586
109
105
select format(atan(-2, 2), 6);
110
106
format(atan(-2, 2), 6)
111
107
-0.785398
123
119
0
124
120
SELECT ASIN(1.0);
125
121
ASIN(1.0)
126
 
1.5707963267949
 
122
1.5707963267948966
127
123
SELECT ACOS(0.2*5.0);
128
124
ACOS(0.2*5.0)
129
125
0
132
128
0
133
129
SELECT ASIN(0.8+0.2);
134
130
ASIN(0.8+0.2)
135
 
1.5707963267949
 
131
1.5707963267948966
136
132
SELECT ASIN(1.2-0.2);
137
133
ASIN(1.2-0.2)
138
 
1.5707963267949
 
134
1.5707963267948966
139
135
select format(4.55, 1), format(4.551, 1);
140
136
format(4.55, 1) format(4.551, 1)
141
137
4.6     4.6
144
140
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
145
141
Warnings:
146
142
Note    1003    select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
 
143
select rand(rand);
 
144
ERROR 42S22: Unknown column 'rand' in 'field list'
147
145
create table t1 (col1 int, col2 decimal(60,30));
148
146
insert into t1 values(1,1234567890.12345);
149
147
select format(col2,7) from t1;
167
165
show create table t1;
168
166
Table   Create Table
169
167
t1      CREATE TABLE `t1` (
170
 
  `round(1, 6)` INT NOT NULL
171
 
) ENGINE=X COLLATE = utf8_general_ci
 
168
  `round(1, 6)` int(1) NOT NULL DEFAULT '0'
 
169
) ENGINE=MyISAM DEFAULT CHARSET=latin1
172
170
select * from t1;
173
171
round(1, 6)
174
172
1
176
174
select abs(-2) * -2;
177
175
abs(-2) * -2
178
176
-4
 
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) 
 
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
 
192
INSERT INTO t1 VALUES (3);
 
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
DROP TABLE t1;
 
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));
 
220
a
 
221
http://www.foo.com/
 
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='';
179
250
select round(111,-10);
180
251
round(111,-10)
181
252
0
191
262
select truncate(15000111000111000155,-1);
192
263
truncate(15000111000111000155,-1)
193
264
15000111000111000150
194
 
create TEMPORARY table t1
 
265
set names utf8;
 
266
create table t1
195
267
(f1 varchar(32) not null,
196
 
f2 int not null,
197
 
f3 int not null default '0')
198
 
engine=myisam;
 
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
201
 
(f1 int not null,
202
 
f2 int not null,
203
 
f3 int not null)
204
 
engine=myisam;
 
272
create 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;
209
281
10,000
210
282
10,000
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)
229
 
NULL    4294967296      NULL
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)
235
 
0       4       0
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)
241
 
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
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)
289
362
0       0
290
 
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3);
291
 
mod(-2, 3)      mod(18446744073709551614, 3)    mod(-2, 3)
292
 
-2      2       -2
293
 
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2);
294
 
mod(5, -2)      mod(5, 18446744073709551614)    mod(5, -2)
295
 
1       5       1
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)
 
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));
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;
302
375
y
328
401
0
329
402
0
330
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;
331
410
End of 5.0 tests
332
411
SELECT 1e308 + 1e308;
333
412
1e308 + 1e308