~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1;
 
2
select floor(5.5),floor(-5.5);
 
3
floor(5.5)      floor(-5.5)
 
4
5       -6
 
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
 
8
Warnings:
 
9
Note    1003    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)
 
12
6       -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
 
16
Warnings:
 
17
Note    1003    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
 
24
Warnings:
 
25
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)`
 
26
select round(5.5),round(-5.5);
 
27
round(5.5)      round(-5.5)
 
28
6       -6
 
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
 
32
Warnings:
 
33
Note    1003    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)
 
36
5.6     5.64    10      0
 
37
select abs(-10), sign(-5), sign(5), sign(0);
 
38
abs(-10)        sign(-5)        sign(5) sign(0)
 
39
10      -1      1       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
 
43
Warnings:
 
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
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      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
 
51
Warnings:
 
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)`
 
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      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
 
59
Warnings:
 
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)`
 
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.90689059560852        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
 
67
Warnings:
 
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)`
 
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.25527250510331        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
 
75
Warnings:
 
76
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)`
 
77
select pow(10,log10(10)),power(2,4);
 
78
pow(10,log10(10))       power(2,4)
 
79
10      16
 
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
 
83
Warnings:
 
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.0142313651873091      0.028870999839968
 
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()`
 
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
 
100
Warnings:
 
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)`
 
102
select degrees(pi()),radians(360);
 
103
degrees(pi())   radians(360)
 
104
180     6.28318530717959
 
105
select format(atan(-2, 2), 6);
 
106
format(atan(-2, 2), 6)
 
107
-0.785398
 
108
select format(atan(pi(), 0), 6);
 
109
format(atan(pi(), 0), 6)
 
110
1.570796
 
111
select format(atan2(-2, 2), 6);
 
112
format(atan2(-2, 2), 6)
 
113
-0.785398
 
114
select format(atan2(pi(), 0), 6);
 
115
format(atan2(pi(), 0), 6)
 
116
1.570796
 
117
SELECT ACOS(1.0);
 
118
ACOS(1.0)
 
119
0
 
120
SELECT ASIN(1.0);
 
121
ASIN(1.0)
 
122
1.5707963267949
 
123
SELECT ACOS(0.2*5.0);
 
124
ACOS(0.2*5.0)
 
125
0
 
126
SELECT ACOS(0.5*2.0);
 
127
ACOS(0.5*2.0)
 
128
0
 
129
SELECT ASIN(0.8+0.2);
 
130
ASIN(0.8+0.2)
 
131
1.5707963267949
 
132
SELECT ASIN(1.2-0.2);
 
133
ASIN(1.2-0.2)
 
134
1.5707963267949
 
135
select format(4.55, 1), format(4.551, 1);
 
136
format(4.55, 1) format(4.551, 1)
 
137
4.6     4.6
 
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
 
141
Warnings:
 
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'
 
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;
 
148
format(col2,7)
 
149
1,234,567,890.1234500
 
150
select format(col2,8) from t1;
 
151
format(col2,8)
 
152
1,234,567,890.12345000
 
153
insert into t1 values(7,1234567890123456.12345);
 
154
select format(col2,6) from t1 where col1=7;
 
155
format(col2,6)
 
156
1,234,567,890,123,456.123450
 
157
drop table t1;
 
158
select ceil(0.09);
 
159
ceil(0.09)
 
160
1
 
161
select ceil(0.000000000000000009);
 
162
ceil(0.000000000000000009)
 
163
1
 
164
create table t1 select round(1, 6);
 
165
show create table t1;
 
166
Table   Create Table
 
167
t1      CREATE TABLE `t1` (
 
168
  `round(1, 6)` int(1) NOT NULL DEFAULT '0'
 
169
) ENGINE=MyISAM DEFAULT CHARSET=latin1
 
170
select * from t1;
 
171
round(1, 6)
 
172
1
 
173
drop table t1;
 
174
select abs(-2) * -2;
 
175
abs(-2) * -2
 
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='';
 
250
select round(111,-10);
 
251
round(111,-10)
 
252
0
 
253
select round(-5000111000111000155,-1);
 
254
round(-5000111000111000155,-1)
 
255
-5000111000111000160
 
256
select round(15000111000111000155,-1);
 
257
round(15000111000111000155,-1)
 
258
15000111000111000160
 
259
select truncate(-5000111000111000155,-1);
 
260
truncate(-5000111000111000155,-1)
 
261
-5000111000111000150
 
262
select truncate(15000111000111000155,-1);
 
263
truncate(15000111000111000155,-1)
 
264
15000111000111000150
 
265
set names utf8;
 
266
create table t1
 
267
(f1 varchar(32) not null,
 
268
f2 smallint(5) unsigned not null,
 
269
f3 int(10) unsigned not null default '0')
 
270
engine=myisam default charset=utf8;
 
271
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
 
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;
 
277
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
 
278
select format(t2.f2-t2.f1+1,0) from t1,t2
 
279
where t1.f2 = t2.f3 order by t1.f1;
 
280
format(t2.f2-t2.f1+1,0)
 
281
10,000
 
282
10,000
 
283
drop table t1, t2;
 
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
 
315
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
 
316
round(10000000000000000000, -19)        truncate(10000000000000000000, -19)
 
317
10000000000000000000    10000000000000000000
 
318
select round(1e0, -309), truncate(1e0, -309);
 
319
round(1e0, -309)        truncate(1e0, -309)
 
320
0       0
 
321
select round(1e1,308), truncate(1e1, 308);
 
322
round(1e1,308)  truncate(1e1, 308)
 
323
10      10
 
324
select round(1e1, 2147483648), truncate(1e1, 2147483648);
 
325
round(1e1, 2147483648)  truncate(1e1, 2147483648)
 
326
10      10
 
327
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295);
 
328
round(1.1e1, 4294967295)        truncate(1.1e1, 4294967295)
 
329
11      11
 
330
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296);
 
331
round(1.12e1, 4294967296)       truncate(1.12e1, 4294967296)
 
332
11.2    11.2
 
333
select round(1.5, 2147483640), truncate(1.5, 2147483640);
 
334
round(1.5, 2147483640)  truncate(1.5, 2147483640)
 
335
1.500000000000000000000000000000        1.500000000000000000000000000000
 
336
select round(1.5, -2147483649), round(1.5, 2147483648);
 
337
round(1.5, -2147483649) round(1.5, 2147483648)
 
338
0       1.500000000000000000000000000000
 
339
select truncate(1.5, -2147483649), truncate(1.5, 2147483648);
 
340
truncate(1.5, -2147483649)      truncate(1.5, 2147483648)
 
341
0       1.500000000000000000000000000000
 
342
select round(1.5, -4294967296), round(1.5, 4294967296);
 
343
round(1.5, -4294967296) round(1.5, 4294967296)
 
344
0       1.500000000000000000000000000000
 
345
select truncate(1.5, -4294967296), truncate(1.5, 4294967296);
 
346
truncate(1.5, -4294967296)      truncate(1.5, 4294967296)
 
347
0       1.500000000000000000000000000000
 
348
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808);
 
349
round(1.5, -9223372036854775808)        round(1.5, 9223372036854775808)
 
350
0       1.500000000000000000000000000000
 
351
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808);
 
352
truncate(1.5, -9223372036854775808)     truncate(1.5, 9223372036854775808)
 
353
0       1.500000000000000000000000000000
 
354
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
 
355
round(1.5, 18446744073709551615)        truncate(1.5, 18446744073709551615)
 
356
1.500000000000000000000000000000        1.500000000000000000000000000000
 
357
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
 
358
round(18446744073709551614, -1) truncate(18446744073709551614, -1)
 
359
18446744073709551610    18446744073709551610
 
360
select round(4, -4294967200), truncate(4, -4294967200);
 
361
round(4, -4294967200)   truncate(4, -4294967200)
 
362
0       0
 
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.13598703592091e+96    2.13598703592091e+96    -32
 
372
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
 
373
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
 
374
SELECT a DIV 900 y FROM t1 GROUP BY y;
 
375
y
 
376
22201025555
 
377
22255916666
 
378
SELECT DISTINCT a DIV 900 y FROM t1;
 
379
y
 
380
22201025555
 
381
22255916666
 
382
SELECT b DIV 900 y FROM t1 GROUP BY y;
 
383
y
 
384
0
 
385
SELECT c DIV 900 y FROM t1 GROUP BY y;
 
386
y
 
387
0
 
388
DROP TABLE t1;
 
389
CREATE TABLE t1(a LONGBLOB);
 
390
INSERT INTO t1 VALUES('1'),('2'),('3');
 
391
SELECT DISTINCT (a DIV 254576881) FROM t1;
 
392
(a DIV 254576881)
 
393
0
 
394
SELECT (a DIV 254576881) FROM t1 UNION ALL 
 
395
SELECT (a DIV 254576881) FROM t1;
 
396
(a DIV 254576881)
 
397
0
 
398
0
 
399
0
 
400
0
 
401
0
 
402
0
 
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;
 
410
CREATE TABLE t1 (a DOUBLE);
 
411
INSERT INTO t1 VALUES (-1.1), (1.1),
 
412
(-1.5), (1.5),
 
413
(-1.9), (1.9),
 
414
(-2.1), (2.1),
 
415
(-2.5), (2.5),
 
416
(-2.9), (2.9),
 
417
# Check numbers with absolute values > 2^53 - 1 
 
418
# (see comments for MAX_EXACT_INTEGER)
 
419
(-1e16 - 0.5), (1e16 + 0.5),
 
420
(-1e16 - 1.5), (1e16 + 1.5);
 
421
SELECT a, ROUND(a) FROM t1;
 
422
a       ROUND(a)
 
423
-1.1    -1
 
424
1.1     1
 
425
-1.5    -2
 
426
1.5     2
 
427
-1.9    -2
 
428
1.9     2
 
429
-2.1    -2
 
430
2.1     2
 
431
-2.5    -2
 
432
2.5     2
 
433
-2.9    -3
 
434
2.9     3
 
435
-1e+16  -10000000000000000
 
436
1e+16   10000000000000000
 
437
-1e+16  -10000000000000002
 
438
1e+16   10000000000000002
 
439
DROP TABLE t1;
 
440
CREATE TABLE t1(f1 LONGTEXT) engine=myisam;
 
441
INSERT INTO t1 VALUES ('a');
 
442
SELECT 1 FROM (SELECT ROUND(f1) AS a FROM t1) AS s WHERE a LIKE 'a';
 
443
1
 
444
SELECT 1 FROM (SELECT ROUND(f1, f1) AS a FROM t1) AS s WHERE a LIKE 'a';
 
445
1
 
446
DROP TABLE t1;
 
447
End of 5.0 tests
 
448
SELECT 1e308 + 1e308;
 
449
1e308 + 1e308
 
450
NULL
 
451
SELECT -1e308 - 1e308;
 
452
-1e308 - 1e308
 
453
NULL
 
454
SELECT 1e300 * 1e300;
 
455
1e300 * 1e300
 
456
NULL
 
457
SELECT 1e300 / 1e-300;
 
458
1e300 / 1e-300
 
459
NULL
 
460
SELECT EXP(750);
 
461
EXP(750)
 
462
NULL
 
463
SELECT POW(10, 309);
 
464
POW(10, 309)
 
465
NULL
 
466
#
 
467
# Bug #44768: SIGFPE crash when selecting rand from a view
 
468
#             containing null
 
469
#
 
470
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
 
471
SELECT RAND(a) FROM v1;
 
472
RAND(a)
 
473
0.155220427694936
 
474
DROP VIEW v1;
 
475
SELECT RAND(a) FROM (SELECT NULL AS a) b;
 
476
RAND(a)
 
477
0.155220427694936
 
478
CREATE TABLE t1 (i INT);
 
479
INSERT INTO t1 VALUES (NULL);
 
480
SELECT RAND(i) FROM t1;
 
481
RAND(i)
 
482
0.155220427694936
 
483
DROP TABLE t1;
 
484
#
 
485
End of 5.1 tests