1
by brian
clean slate |
1 |
#
|
2 |
# Test of math functions |
|
3 |
#
|
|
4 |
||
5 |
--disable_warnings
|
|
6 |
drop table if exists t1; |
|
7 |
--enable_warnings
|
|
8 |
||
9 |
select floor(5.5),floor(-5.5); |
|
10 |
explain extended select floor(5.5),floor(-5.5); |
|
11 |
select ceiling(5.5),ceiling(-5.5); |
|
12 |
explain extended select ceiling(5.5),ceiling(-5.5); |
|
13 |
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); |
|
14 |
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); |
|
15 |
select round(5.5),round(-5.5); |
|
16 |
explain extended select round(5.5),round(-5.5); |
|
17 |
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2); |
|
18 |
select abs(-10), sign(-5), sign(5), sign(0); |
|
19 |
explain extended select abs(-10), sign(-5), sign(5), sign(0); |
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
20 |
--error ER_DIVISION_BY_ZERO
|
1
by brian
clean slate |
21 |
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); |
22 |
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); |
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
23 |
--error ER_DIVISION_BY_ZERO
|
1
by brian
clean slate |
24 |
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); |
25 |
explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL); |
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
26 |
--error ER_DIVISION_BY_ZERO
|
1
by brian
clean slate |
27 |
select log2(8),log2(15),log2(-2),log2(0),log2(NULL); |
28 |
explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL); |
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
29 |
--error ER_DIVISION_BY_ZERO
|
1
by brian
clean slate |
30 |
select log10(100),log10(18),log10(-4),log10(0),log10(NULL); |
31 |
explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL); |
|
32 |
select pow(10,log10(10)),power(2,4); |
|
33 |
explain extended select pow(10,log10(10)),power(2,4); |
|
34 |
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); |
|
35 |
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); |
|
36 |
select degrees(pi()),radians(360); |
|
37 |
||
38 |
select format(atan(-2, 2), 6); |
|
39 |
select format(atan(pi(), 0), 6); |
|
40 |
select format(atan2(-2, 2), 6); |
|
41 |
select format(atan2(pi(), 0), 6); |
|
42 |
||
43 |
#
|
|
44 |
# Bug #2338 Trignometric arithmatic problems |
|
45 |
#
|
|
46 |
||
47 |
SELECT ACOS(1.0); |
|
48 |
SELECT ASIN(1.0); |
|
49 |
SELECT ACOS(0.2*5.0); |
|
50 |
SELECT ACOS(0.5*2.0); |
|
51 |
SELECT ASIN(0.8+0.2); |
|
52 |
SELECT ASIN(1.2-0.2); |
|
53 |
||
54 |
#
|
|
55 |
# Bug #3051 FLOOR returns invalid |
|
56 |
#
|
|
57 |
||
58 |
# This can't be tested as it's not portable |
|
59 |
#select floor(log(4)/log(2)); |
|
60 |
#select floor(log(8)/log(2)); |
|
61 |
#select floor(log(16)/log(2)); |
|
62 |
||
63 |
#
|
|
64 |
# Bug #9060 (format returns incorrect result) |
|
65 |
#
|
|
66 |
select format(4.55, 1), format(4.551, 1); |
|
67 |
||
68 |
explain extended select degrees(pi()),radians(360); |
|
69 |
||
70 |
# End of 4.1 tests |
|
71 |
||
72 |
#
|
|
73 |
# Bug #8459 (FORMAT returns incorrect result) |
|
74 |
#
|
|
75 |
create table t1 (col1 int, col2 decimal(60,30)); |
|
76 |
insert into t1 values(1,1234567890.12345); |
|
77 |
select format(col2,7) from t1; |
|
78 |
select format(col2,8) from t1; |
|
79 |
insert into t1 values(7,1234567890123456.12345); |
|
80 |
select format(col2,6) from t1 where col1=7; |
|
81 |
drop table t1; |
|
82 |
||
83 |
||
84 |
#
|
|
85 |
# Bug @10632 (Ceiling function returns wrong answer) |
|
86 |
#
|
|
87 |
select ceil(0.09); |
|
88 |
select ceil(0.000000000000000009); |
|
89 |
||
90 |
#
|
|
91 |
# Bug #9837: problem with round() |
|
92 |
#
|
|
93 |
||
94 |
create table t1 select round(1, 6); |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
95 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i
|
1
by brian
clean slate |
96 |
show create table t1; |
97 |
select * from t1; |
|
98 |
drop table t1; |
|
99 |
||
100 |
#
|
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
101 |
# Bug #11402: abs() forces rest of calculation to |
1
by brian
clean slate |
102 |
#
|
103 |
select abs(-2) * -2; |
|
104 |
||
105 |
# End of 4.1 tests |
|
106 |
||
107 |
#
|
|
108 |
# Bug #8461 truncate() and round() return false results 2nd argument negative. |
|
109 |
#
|
|
110 |
# round(a,-b) log_10(b) > a |
|
111 |
select round(111,-10); |
|
112 |
# round on bigint |
|
113 |
select round(-5000111000111000155,-1); |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
114 |
# round on bigint |
1
by brian
clean slate |
115 |
select round(15000111000111000155,-1); |
116 |
# truncate on bigint |
|
117 |
select truncate(-5000111000111000155,-1); |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
118 |
# truncate on bigint |
1
by brian
clean slate |
119 |
select truncate(15000111000111000155,-1); |
120 |
||
121 |
#
|
|
122 |
# Bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8 |
|
123 |
#
|
|
1063.9.3
by Brian Aker
Partial fix for tests for tmp |
124 |
create TEMPORARY table t1 |
1
by brian
clean slate |
125 |
(f1 varchar(32) not null, |
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
126 |
f2 int not null, |
127 |
f3 int not null default '0') |
|
383.4.1
by Jay Pipes
Fixed syntax errors in func_math test and re-enable the test in the make test target |
128 |
engine=myisam; |
1
by brian
clean slate |
129 |
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000); |
130 |
||
1063.9.3
by Brian Aker
Partial fix for tests for tmp |
131 |
create TEMPORARY table t2 |
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
132 |
(f1 int not null, |
133 |
f2 int not null, |
|
134 |
f3 int not null) |
|
383.4.1
by Jay Pipes
Fixed syntax errors in func_math test and re-enable the test in the make test target |
135 |
engine=myisam; |
1
by brian
clean slate |
136 |
insert into t2 values (16777216,16787215,1),(33554432,33564431,2); |
137 |
||
138 |
select format(t2.f2-t2.f1+1,0) from t1,t2 |
|
139 |
where t1.f2 = t2.f3 order by t1.f1; |
|
140 |
drop table t1, t2; |
|
141 |
||
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
142 |
# Bug 24912 -- misc functions have trouble with |
1
by brian
clean slate |
143 |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
144 |
select -2, 18446744073709551614, -2; |
145 |
select abs(-2), abs(18446744073709551614), abs(-2); |
|
146 |
select ceiling(-2), ceiling(18446744073709551614), ceiling(-2); |
|
147 |
select floor(-2), floor(18446744073709551614), floor(-2); |
|
148 |
select format(-2, 2), format(18446744073709551614, 2), format(-2, 2); |
|
149 |
select sqrt(-2), sqrt(18446744073709551614), sqrt(-2); |
|
150 |
select round(-2, 1), round(18446744073709551614, 1), round(-2, 1); |
|
151 |
select round(4, -2), round(4, 18446744073709551614), round(4, -2); |
|
152 |
select truncate(-2, 1), truncate(18446744073709551614, 1), truncate(-2, 1); |
|
153 |
select truncate(4, -2), truncate(4, 18446744073709551614), truncate(4, -2); |
|
1
by brian
clean slate |
154 |
select round(10000000000000000000, -19), truncate(10000000000000000000, -19); |
155 |
select round(1e0, -309), truncate(1e0, -309); |
|
156 |
select round(1e1,308), truncate(1e1, 308); |
|
157 |
select round(1e1, 2147483648), truncate(1e1, 2147483648); |
|
158 |
select round(1.1e1, 4294967295), truncate(1.1e1, 4294967295); |
|
159 |
select round(1.12e1, 4294967296), truncate(1.12e1, 4294967296); |
|
160 |
select round(1.5, 2147483640), truncate(1.5, 2147483640); |
|
161 |
select round(1.5, -2147483649), round(1.5, 2147483648); |
|
162 |
select truncate(1.5, -2147483649), truncate(1.5, 2147483648); |
|
163 |
select round(1.5, -4294967296), round(1.5, 4294967296); |
|
164 |
select truncate(1.5, -4294967296), truncate(1.5, 4294967296); |
|
165 |
select round(1.5, -9223372036854775808), round(1.5, 9223372036854775808); |
|
166 |
select truncate(1.5, -9223372036854775808), truncate(1.5, 9223372036854775808); |
|
167 |
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615); |
|
168 |
select round(18446744073709551614, -1), truncate(18446744073709551614, -1); |
|
169 |
select round(4, -4294967200), truncate(4, -4294967200); |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
170 |
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3); |
171 |
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2); |
|
172 |
select pow(-2, 5), pow(18446744073709551614, 5), pow(-2, 5); |
|
1
by brian
clean slate |
173 |
|
174 |
#
|
|
175 |
# Bug #30587: mysql crashes when trying to group by TIME div NUMBER |
|
176 |
#
|
|
177 |
||
397
by Brian Aker
Remove tiny/small int. |
178 |
CREATE TABLE t1 (a timestamp, b varchar(20), c int); |
1
by brian
clean slate |
179 |
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); |
180 |
SELECT a DIV 900 y FROM t1 GROUP BY y; |
|
181 |
SELECT DISTINCT a DIV 900 y FROM t1; |
|
182 |
SELECT b DIV 900 y FROM t1 GROUP BY y; |
|
183 |
SELECT c DIV 900 y FROM t1 GROUP BY y; |
|
184 |
DROP TABLE t1; |
|
185 |
||
186 |
CREATE TABLE t1(a LONGBLOB); |
|
187 |
INSERT INTO t1 VALUES('1'),('2'),('3'); |
|
188 |
SELECT DISTINCT (a DIV 254576881) FROM t1; |
|
189 |
SELECT (a DIV 254576881) FROM t1 UNION ALL |
|
190 |
SELECT (a DIV 254576881) FROM t1; |
|
191 |
DROP TABLE t1; |
|
192 |
||
193 |
--echo End of 5.0 tests
|
|
194 |
||
195 |
#
|
|
196 |
# Bug #31236: Inconsistent division by zero behavior for floating point numbers |
|
197 |
#
|
|
198 |
||
199 |
SELECT 1e308 + 1e308; |
|
200 |
SELECT -1e308 - 1e308; |
|
201 |
SELECT 1e300 * 1e300; |
|
202 |
SELECT 1e300 / 1e-300; |
|
203 |
SELECT EXP(750); |
|
204 |
SELECT POW(10, 309); |
|
205 |
||
206 |
--echo End of 5.1 tests
|