1
by brian
clean slate |
1 |
--disable_warnings |
2 |
drop table if exists t1; |
|
3 |
--enable_warnings |
|
4 |
#
|
|
5 |
# constant IN function test
|
|
6 |
#
|
|
7 |
select 1.1 IN (1.0, 1.2); |
|
8 |
select 1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5); |
|
9 |
select 1.1 IN (1.0, 1.2, NULL, 1.4, 0.5); |
|
10 |
select 0.5 IN (1.0, 1.2, NULL, 1.4, 0.5); |
|
11 |
select 1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5); |
|
12 |
select 1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5); |
|
13 |
||
14 |
#
|
|
15 |
# case function test
|
|
16 |
#
|
|
17 |
select case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END; |
|
18 |
select case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END; |
|
19 |
select case 1 when 0.1 then "a" when 1.0 then "b" else "c" END; |
|
20 |
select case 1.0 when 0.1 then "a" when 1 then "b" else "c" END; |
|
21 |
select case 1.001 when 0.1 then "a" when 1 then "b" else "c" END; |
|
22 |
||
23 |
#
|
|
24 |
# non constant IN test
|
|
25 |
#
|
|
26 |
create table t1 (a decimal(6,3)); |
|
27 |
insert into t1 values (1.0), (NULL), (0.1); |
|
28 |
select * from t1; |
|
29 |
select 0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5) from t1; |
|
30 |
drop table t1; |
|
31 |
||
32 |
#
|
|
33 |
# if function test
|
|
34 |
#
|
|
35 |
create table t1 select if(1, 1.1, 1.2), if(0, 1.1, 1.2), if(0.1, 1.1, 1.2), if(0, 1, 1.1), if(0, NULL, 1.2), if(1, 0.22e1, 1.1), if(1E0, 1.1, 1.2); |
|
36 |
select * from t1; |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
37 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
38 |
show create table t1; |
39 |
drop table t1; |
|
40 |
||
41 |
#
|
|
42 |
# NULLIF
|
|
43 |
#
|
|
44 |
create table t1 select nullif(1.1, 1.1), nullif(1.1, 1.2), nullif(1.1, 0.11e1), nullif(1.0, 1), nullif(1, 1.0), nullif(1, 1.1); |
|
45 |
select * from t1; |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
46 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
47 |
show create table t1; |
48 |
drop table t1; |
|
49 |
||
50 |
#
|
|
51 |
# saving in decimal field with overflow
|
|
52 |
#
|
|
53 |
||
54 |
create table t1 (a decimal(4,2)); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
55 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
56 |
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
57 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
58 |
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1); |
59 |
select a from t1; |
|
60 |
drop table t1; |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
61 |
create table t1 (a decimal(4,2)); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
62 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
63 |
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
64 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
65 |
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1); |
66 |
select a from t1; |
|
67 |
drop table t1; |
|
68 |
||
69 |
||
70 |
#
|
|
71 |
# saving in field with overflow from decimal
|
|
72 |
#
|
|
73 |
create table t1 (a bigint); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
74 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
75 |
insert into t1 values (18446744073709551615.0); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
76 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
77 |
insert into t1 values (9223372036854775808.0); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
78 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
79 |
insert into t1 values (-18446744073709551615.0); |
80 |
select * from t1; |
|
81 |
drop table t1; |
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
82 |
create table t1 (a bigint); |
83 |
insert into t1 values (9223372036854775807.0); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
84 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
85 |
insert into t1 values (9999999999999999999999999.000); |
86 |
insert into t1 values (-1.0); |
|
87 |
select * from t1; |
|
88 |
drop table t1; |
|
396
by Brian Aker
Cleanup tiny and small int. |
89 |
create table t1 (a int); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
90 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
91 |
insert into t1 values (18446744073709551615.0); |
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
92 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
93 |
insert into t1 values (9223372036854775808.0); |
94 |
select * from t1; |
|
95 |
drop table t1; |
|
96 |
||
97 |
#
|
|
98 |
# test that functions create decimal fields
|
|
99 |
#
|
|
100 |
create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-1.1); |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
101 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
102 |
show create table t1; |
103 |
drop table t1; |
|
104 |
||
105 |
#
|
|
106 |
# Trydy's tests
|
|
107 |
#
|
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
108 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
109 |
select 1e10/0e0; |
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
110 |
#create table wl1612 (col1 int, col2 decimal(38,10), col3 numeric(38,10));
|
111 |
#insert into wl1612 values(1,12345678901234567890.1234567890,12345678901234567890.1234567890);
|
|
112 |
#select * from wl1612;
|
|
113 |
#insert into wl1612 values(2,01234567890123456789.0123456789,01234567890123456789.0123456789);
|
|
114 |
#select * from wl1612 where col1=2;
|
|
115 |
#insert into wl1612 values(3,1234567890123456789012345678.0123456789,1234567890123456789012345678.0123456789);
|
|
116 |
#select * from wl1612 where col1=3;
|
|
117 |
||
118 |
#select col1/0 from wl1612;
|
|
119 |
#select col2/0 from wl1612;
|
|
120 |
#select col3/0 from wl1612;
|
|
121 |
||
122 |
#insert into wl1612 values(5,5000.0005,5000.0005);
|
|
123 |
#insert into wl1612 values(6,5000.0005,5000.0005);
|
|
124 |
#select sum(col2),sum(col3) from wl1612;
|
|
1
by brian
clean slate |
125 |
#select avg(col2),avg(col3) from wl1612;
|
126 |
||
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
127 |
#insert into wl1612 values(7,500000.000005,500000.000005);
|
128 |
#insert into wl1612 values(8,500000.000005,500000.000005);
|
|
129 |
#select sum(col2),sum(col3) from wl1612 where col1>4;
|
|
1
by brian
clean slate |
130 |
#select avg(col2),avg(col3) from wl1612 where col1>4;
|
131 |
||
132 |
#insert into wl1612 (col1,col2) values(9,123456789012345678901234567890);
|
|
133 |
#insert into wl1612 (col1,col3) values(9,123456789012345678901234567890);
|
|
134 |
||
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
135 |
#insert into wl1612 (col1, col2) values(9,1.01234567891);
|
136 |
#insert into wl1612 (col1, col2) values(10,1.01234567894);
|
|
137 |
#insert into wl1612 (col1, col2) values(11,1.01234567895);
|
|
138 |
#insert into wl1612 (col1, col2) values(12,1.01234567896);
|
|
139 |
#select col1,col2 from wl1612 where col1>8;
|
|
140 |
||
141 |
#insert into wl1612 (col1, col3) values(13,1.01234567891);
|
|
142 |
#insert into wl1612 (col1, col3) values(14,1.01234567894);
|
|
143 |
#insert into wl1612 (col1, col3) values(15,1.01234567895);
|
|
144 |
#insert into wl1612 (col1, col3) values(16,1.01234567896);
|
|
145 |
#select col1,col3 from wl1612 where col1>12;
|
|
146 |
||
147 |
#select col1 from wl1612 where col1>4 and col2=1.01234567891;
|
|
148 |
#-- should return 0 rows
|
|
149 |
#
|
|
150 |
#select col1 from wl1612 where col1>4 and col2=1.0123456789;
|
|
151 |
#-- should return col1 values 9 & 10
|
|
152 |
#
|
|
153 |
#select col1 from wl1612 where col1>4 and col2<>1.0123456789;
|
|
154 |
#-- should return col1 values 5,6,7,8,11,12
|
|
155 |
#
|
|
156 |
#select col1 from wl1612 where col1>4 and col2<1.0123456789;
|
|
157 |
#-- should return 0 rows
|
|
158 |
#
|
|
159 |
#select col1 from wl1612 where col1>4 and col2<=1.0123456789;
|
|
160 |
#-- should return col1 values 9 & 10
|
|
161 |
#
|
|
162 |
#select col1 from wl1612 where col1>4 and col2>1.0123456789;
|
|
163 |
#-- should return col1 values 5,6,7,8,11,12
|
|
164 |
#
|
|
165 |
#select col1 from wl1612 where col1>4 and col2>=1.0123456789;
|
|
1
by brian
clean slate |
166 |
#-- should return col1 values 5,6,7,8,910,11,12
|
167 |
#
|
|
168 |
#select col1, col2 from wl1612 where col1=11 or col1=12;
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
169 |
#select col1 from wl1612 where col1>4 and col2=1.012345679;
|
1
by brian
clean slate |
170 |
#-- should return col1 values 11,12
|
171 |
#
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
172 |
#select col1 from wl1612 where col1>4 and col2<>1.012345679;
|
1
by brian
clean slate |
173 |
#-- should return col1 values 5,6,7,8,9,10
|
174 |
#
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
175 |
#select col1 from wl1612 where col1>4 and col3=1.01234567891;
|
176 |
#-- should return 0 rows
|
|
177 |
#
|
|
178 |
#select col1 from wl1612 where col1>4 and col3=1.0123456789;
|
|
179 |
#-- should return col1 values 13,14
|
|
180 |
#
|
|
181 |
#select col1 from wl1612 where col1>4 and col3<>1.0123456789;
|
|
182 |
#-- should return col1 values 5,6,7,8,15,16
|
|
183 |
#
|
|
184 |
#select col1 from wl1612 where col1>4 and col3<1.0123456789;
|
|
185 |
#-- should return 0 rows
|
|
186 |
#
|
|
187 |
#select col1 from wl1612 where col1>4 and col3<=1.0123456789;
|
|
188 |
#-- should return col1 values 13,14
|
|
189 |
#
|
|
190 |
#select col1 from wl1612 where col1>4 and col3>1.0123456789;
|
|
191 |
#-- should return col1 values 5,6,7,8,15,16
|
|
192 |
#
|
|
193 |
#select col1 from wl1612 where col1>4 and col3>=1.0123456789;
|
|
1
by brian
clean slate |
194 |
#-- should return col1 values 5,6,7,8,13,14,15,16
|
195 |
#
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
196 |
#select col1 from wl1612 where col1>4 and col3=1.012345679;
|
1
by brian
clean slate |
197 |
#-- should return col1 values 15,16
|
198 |
#
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
199 |
#select col1 from wl1612 where col1>4 and col3<>1.012345679;
|
1
by brian
clean slate |
200 |
#-- should return col1 values 5,6,7,8,13,14
|
201 |
#
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
202 |
#drop table wl1612;
|
1
by brian
clean slate |
203 |
#
|
204 |
select 1/3; |
|
205 |
#
|
|
206 |
select 0.8=0.7+0.1; |
|
207 |
#-- should return 1 (true)
|
|
208 |
#
|
|
209 |
select 0.7+0.1; |
|
210 |
#
|
|
211 |
create table wl1612_1 (col1 int); |
|
212 |
insert into wl1612_1 values(10); |
|
213 |
#
|
|
214 |
select * from wl1612_1 where 0.8=0.7+0.1; |
|
215 |
#--should return 1 row (col1=10)
|
|
216 |
#
|
|
217 |
select 0.07+0.07 from wl1612_1; |
|
218 |
#
|
|
219 |
select 0.07-0.07 from wl1612_1; |
|
220 |
#
|
|
221 |
select 0.07*0.07 from wl1612_1; |
|
222 |
#
|
|
223 |
select 0.07/0.07 from wl1612_1; |
|
224 |
#
|
|
225 |
drop table wl1612_1; |
|
226 |
#
|
|
227 |
create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2)); |
|
228 |
insert into wl1612_2 values(1,1); |
|
229 |
insert into wl1612_2 values(+1,+1); |
|
230 |
insert into wl1612_2 values(+01,+01); |
|
231 |
insert into wl1612_2 values(+001,+001); |
|
232 |
#
|
|
233 |
select col1,count(*) from wl1612_2 group by col1; |
|
234 |
#
|
|
235 |
select col2,count(*) from wl1612_2 group by col2; |
|
236 |
#
|
|
237 |
drop table wl1612_2; |
|
238 |
#
|
|
239 |
create table wl1612_3 (col1 decimal(10,2), col2 numeric(10,2)); |
|
240 |
insert into wl1612_3 values('1','1'); |
|
241 |
insert into wl1612_3 values('+1','+1'); |
|
242 |
#
|
|
243 |
insert into wl1612_3 values('+01','+01'); |
|
244 |
insert into wl1612_3 values('+001','+001'); |
|
245 |
#
|
|
246 |
select col1,count(*) from wl1612_3 group by col1; |
|
247 |
#
|
|
248 |
select col2,count(*) from wl1612_3 group by col2; |
|
249 |
#
|
|
250 |
drop table wl1612_3; |
|
251 |
#
|
|
252 |
select mod(234,10) ; |
|
253 |
#-- should return 4
|
|
254 |
#
|
|
255 |
select mod(234.567,10.555); |
|
256 |
#-- should return 2.357
|
|
257 |
#
|
|
258 |
select mod(-234.567,10.555); |
|
259 |
#-- should return -2.357
|
|
260 |
#
|
|
261 |
select mod(234.567,-10.555); |
|
262 |
#-- should return 2.357
|
|
263 |
#
|
|
264 |
select round(15.1); |
|
265 |
#-- should return 15
|
|
266 |
#
|
|
267 |
select round(15.4); |
|
268 |
#-- should return 15
|
|
269 |
#
|
|
270 |
select round(15.5); |
|
271 |
#-- should return 16
|
|
272 |
#
|
|
273 |
select round(15.6); |
|
274 |
#-- should return 16
|
|
275 |
#
|
|
276 |
select round(15.9); |
|
277 |
#-- should return 16
|
|
278 |
#
|
|
279 |
select round(-15.1); |
|
280 |
#-- should return -15
|
|
281 |
#
|
|
282 |
select round(-15.4); |
|
283 |
#-- should return -15
|
|
284 |
#
|
|
285 |
select round(-15.5); |
|
286 |
#-- should return -16
|
|
287 |
#
|
|
288 |
select round(-15.6); |
|
289 |
#-- should return -16
|
|
290 |
#
|
|
291 |
select round(-15.9); |
|
292 |
#-- should return -16
|
|
293 |
#
|
|
294 |
select round(15.1,1); |
|
295 |
#-- should return 15.1
|
|
296 |
#
|
|
297 |
select round(15.4,1); |
|
298 |
#-- should return 15.4
|
|
299 |
#
|
|
300 |
select round(15.5,1); |
|
301 |
#-- should return 15.5
|
|
302 |
#
|
|
303 |
select round(15.6,1); |
|
304 |
#-- should return 15.6
|
|
305 |
#
|
|
306 |
select round(15.9,1); |
|
307 |
#-- should return 15.9
|
|
308 |
#
|
|
309 |
select round(-15.1,1); |
|
310 |
#-- should return -15.1
|
|
311 |
#
|
|
312 |
select round(-15.4,1); |
|
313 |
#-- should return -15.4
|
|
314 |
#
|
|
315 |
select round(-15.5,1); |
|
316 |
#-- should return -15.5
|
|
317 |
#
|
|
318 |
select round(-15.6,1); |
|
319 |
#-- should return -15.6
|
|
320 |
#
|
|
321 |
select round(-15.9,1); |
|
322 |
#-- should return -15.9
|
|
323 |
#
|
|
324 |
select round(15.1,0); |
|
325 |
#-- should return 15
|
|
326 |
#
|
|
327 |
select round(15.4,0); |
|
328 |
#-- should return 15
|
|
329 |
#
|
|
330 |
select round(15.5,0); |
|
331 |
#-- should return 16
|
|
332 |
#
|
|
333 |
select round(15.6,0); |
|
334 |
#-- should return 16
|
|
335 |
#
|
|
336 |
select round(15.9,0); |
|
337 |
#-- should return 16
|
|
338 |
#
|
|
339 |
select round(-15.1,0); |
|
340 |
#-- should return -15
|
|
341 |
#
|
|
342 |
select round(-15.4,0); |
|
343 |
#-- should return -15
|
|
344 |
#
|
|
345 |
select round(-15.5,0); |
|
346 |
#-- should return -16
|
|
347 |
#
|
|
348 |
select round(-15.6,0); |
|
349 |
#-- should return -16
|
|
350 |
#
|
|
351 |
select round(-15.9,0); |
|
352 |
#-- should return -16
|
|
353 |
#
|
|
354 |
select round(15.1,-1); |
|
355 |
#-- should return 20
|
|
356 |
#
|
|
357 |
select round(15.4,-1); |
|
358 |
#-- should return 20
|
|
359 |
#
|
|
360 |
select round(15.5,-1); |
|
361 |
#-- should return 20
|
|
362 |
#
|
|
363 |
select round(15.6,-1); |
|
364 |
#-- should return 20
|
|
365 |
#
|
|
366 |
select round(15.9,-1); |
|
367 |
#-- should return 20
|
|
368 |
#
|
|
369 |
select round(-15.1,-1); |
|
370 |
#-- should return -20
|
|
371 |
#
|
|
372 |
select round(-15.4,-1); |
|
373 |
#-- should return -20
|
|
374 |
#
|
|
375 |
select round(-15.5,-1); |
|
376 |
#-- should return -20
|
|
377 |
#
|
|
378 |
select round(-15.6,-1); |
|
379 |
#-- should return -20
|
|
380 |
#
|
|
381 |
select round(-15.91,-1); |
|
382 |
#-- should return -20
|
|
383 |
#
|
|
384 |
select truncate(5678.123451,0); |
|
385 |
#-- should return 5678
|
|
386 |
#
|
|
387 |
select truncate(5678.123451,1); |
|
388 |
#-- should return 5678.1
|
|
389 |
#
|
|
390 |
select truncate(5678.123451,2); |
|
391 |
#-- should return 5678.12
|
|
392 |
#
|
|
393 |
select truncate(5678.123451,3); |
|
394 |
#-- should return 5678.123
|
|
395 |
#
|
|
396 |
select truncate(5678.123451,4); |
|
397 |
#-- should return 5678.1234
|
|
398 |
#
|
|
399 |
select truncate(5678.123451,5); |
|
400 |
#-- should return 5678.12345
|
|
401 |
#
|
|
402 |
select truncate(5678.123451,6); |
|
403 |
#-- should return 5678.123451
|
|
404 |
#
|
|
405 |
select truncate(5678.123451,-1); |
|
406 |
#-- should return 5670
|
|
407 |
#
|
|
408 |
select truncate(5678.123451,-2); |
|
409 |
#-- should return 5600
|
|
410 |
#
|
|
411 |
select truncate(5678.123451,-3); |
|
412 |
#-- should return 5000
|
|
413 |
#
|
|
414 |
select truncate(5678.123451,-4); |
|
415 |
#-- should return 0
|
|
416 |
#
|
|
417 |
select truncate(-5678.123451,0); |
|
418 |
#-- should return -5678
|
|
419 |
#
|
|
420 |
select truncate(-5678.123451,1); |
|
421 |
#-- should return -5678.1
|
|
422 |
#
|
|
423 |
select truncate(-5678.123451,2); |
|
424 |
#-- should return -5678.12
|
|
425 |
#
|
|
426 |
select truncate(-5678.123451,3); |
|
427 |
#-- should return -5678.123
|
|
428 |
#
|
|
429 |
select truncate(-5678.123451,4); |
|
430 |
#-- should return -5678.1234
|
|
431 |
#
|
|
432 |
select truncate(-5678.123451,5); |
|
433 |
#-- should return -5678.12345
|
|
434 |
#
|
|
435 |
select truncate(-5678.123451,6); |
|
436 |
#-- should return -5678.123451
|
|
437 |
#
|
|
438 |
select truncate(-5678.123451,-1); |
|
439 |
#-- should return -5670
|
|
440 |
#
|
|
441 |
select truncate(-5678.123451,-2); |
|
442 |
#-- should return -5600
|
|
443 |
#
|
|
444 |
select truncate(-5678.123451,-3); |
|
445 |
#-- should return -5000
|
|
446 |
#
|
|
447 |
select truncate(-5678.123451,-4); |
|
448 |
#-- should return 0
|
|
449 |
#
|
|
450 |
#drop table if exists wl1612_4;
|
|
451 |
create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); |
|
452 |
#
|
|
453 |
insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345); |
|
454 |
#
|
|
455 |
select col2/9999999999 from wl1612_4 where col1=1; |
|
456 |
#
|
|
457 |
select col3/9999999999 from wl1612_4 where col1=1; |
|
458 |
#
|
|
459 |
select 9999999999/col2 from wl1612_4 where col1=1; |
|
460 |
#
|
|
461 |
select 9999999999/col3 from wl1612_4 where col1=1; |
|
462 |
#
|
|
463 |
select col2*9999999999 from wl1612_4 where col1=1; |
|
464 |
#
|
|
465 |
select col3*9999999999 from wl1612_4 where col1=1; |
|
466 |
#
|
|
467 |
insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345); |
|
468 |
#
|
|
469 |
select col2/9999999999 from wl1612_4 where col1=2; |
|
470 |
#
|
|
471 |
select col3/9999999999 from wl1612_4 where col1=2; |
|
472 |
#
|
|
473 |
select 9999999999/col2 from wl1612_4 where col1=2; |
|
474 |
#
|
|
475 |
select 9999999999/col3 from wl1612_4 where col1=2; |
|
476 |
#
|
|
477 |
select col2*9999999999 from wl1612_4 where col1=2; |
|
478 |
#
|
|
479 |
select col3*9999999999 from wl1612_4 where col1=2; |
|
480 |
#
|
|
481 |
drop table wl1612_4; |
|
482 |
#
|
|
483 |
#
|
|
484 |
#
|
|
485 |
#
|
|
486 |
#-- Additional tests for WL#1612 Precision math
|
|
487 |
#
|
|
488 |
#-- Comparisons should show that a number is
|
|
489 |
#-- exactly equal to its value as displayed.
|
|
490 |
#
|
|
491 |
select 23.4 + (-41.7), 23.4 - (41.7) = -18.3; |
|
492 |
#
|
|
493 |
select -18.3=-18.3; |
|
494 |
#
|
|
495 |
select 18.3=18.3; |
|
496 |
#
|
|
497 |
select -18.3=18.3; |
|
498 |
#
|
|
499 |
select 0.8 = 0.7 + 0.1; |
|
500 |
||
501 |
#
|
|
502 |
#-- It should be possible to define a column
|
|
503 |
#-- with up to 38 digits precision either before
|
|
504 |
#-- or after the decimal point. Any number which
|
|
505 |
#-- is inserted, if it's within the range, should
|
|
506 |
#-- be exactly the same as the number that gets
|
|
507 |
#-- selected.
|
|
508 |
#
|
|
509 |
drop table if exists t1; |
|
510 |
#
|
|
511 |
create table t1 (col1 decimal(38)); |
|
512 |
#
|
|
513 |
insert into t1 values (12345678901234567890123456789012345678); |
|
514 |
#
|
|
515 |
select * from t1; |
|
516 |
#-- should return:
|
|
517 |
#+----------------------------------------+
|
|
518 |
#| col1 |
|
|
519 |
#+----------------------------------------+
|
|
520 |
#| 12345678901234567890123456789012345678 |
|
|
521 |
#+----------------------------------------+
|
|
522 |
#
|
|
523 |
#drop table t1;
|
|
524 |
#
|
|
525 |
#create table t1 (col1 decimal(38,38));
|
|
526 |
#
|
|
527 |
#insert into t1 values (.12345678901234567890123456789012345678);
|
|
528 |
#
|
|
529 |
#select * from t1;
|
|
530 |
#-- should return:
|
|
531 |
#+------------------------------------------+
|
|
532 |
#| col1 |
|
|
533 |
#+------------------------------------------+
|
|
534 |
#| 0.12345678901234567890123456789012345678 |
|
|
535 |
#+------------------------------------------+
|
|
536 |
#
|
|
537 |
drop table t1; |
|
538 |
#
|
|
539 |
create table t1 (col1 decimal(31,30)); |
|
540 |
#
|
|
541 |
insert into t1 values (0.00000000001); |
|
542 |
#
|
|
543 |
select * from t1; |
|
544 |
#-- should return:
|
|
545 |
#+---------------+
|
|
546 |
#|col1 |
|
|
547 |
#+---------------+
|
|
548 |
#| 0.00000000001 |
|
|
549 |
#+---------------+
|
|
550 |
#
|
|
551 |
drop table t1; |
|
552 |
#
|
|
553 |
#-- The usual arithmetic operators / * + - should work.
|
|
554 |
#
|
|
555 |
#select 77777777777777777777777777777777777777 / 7777777777777777777777777777777777777 = 10;
|
|
556 |
#-- should return 0 (false).
|
|
557 |
#
|
|
558 |
select 7777777777777777777777777777777777777 * 10; |
|
559 |
#-- should return 77777777777777777777777777777777777770
|
|
560 |
#
|
|
561 |
select .7777777777777777777777777777777777777 * |
|
562 |
1000000000000000000; |
|
563 |
#-- should return 777777777777777777.7777777777777777777
|
|
564 |
#
|
|
565 |
select .7777777777777777777777777777777777777 - 0.1; |
|
566 |
#-- should return .6777777777777777777777777777777777777
|
|
567 |
#
|
|
568 |
select .343434343434343434 + .343434343434343434; |
|
569 |
#-- should return .686868686868686868
|
|
570 |
#
|
|
571 |
#-- 5. All arithmetic functions mentioned in the
|
|
572 |
#MySQL Reference Manual should work.
|
|
573 |
#
|
|
574 |
select abs(9999999999999999999999); |
|
575 |
#-- should return 9999999999999999999999
|
|
576 |
#
|
|
577 |
select abs(-9999999999999999999999); |
|
578 |
#-- should return 9999999999999999999999
|
|
579 |
#
|
|
580 |
select ceiling(999999999999999999); |
|
581 |
select ceiling(99999999999999999999); |
|
582 |
#-- should return 99999999999999999999
|
|
583 |
#
|
|
584 |
select ceiling(9.9999999999999999999); |
|
585 |
#-- should return 10
|
|
586 |
#
|
|
587 |
select ceiling(-9.9999999999999999999); |
|
588 |
#-- should return 9
|
|
589 |
#
|
|
590 |
select floor(999999999999999999); |
|
591 |
select floor(9999999999999999999999); |
|
592 |
#-- should return 9999999999999999999999
|
|
593 |
#
|
|
594 |
select floor(9.999999999999999999999); |
|
595 |
#-- should return 9
|
|
596 |
#
|
|
597 |
select floor(-9.999999999999999999999); |
|
598 |
#-- should return -10
|
|
599 |
#
|
|
600 |
select floor(-999999999999999999999.999); |
|
601 |
select ceiling(999999999999999999999.999); |
|
602 |
#
|
|
603 |
#
|
|
604 |
select 99999999999999999999999999999999999999 mod 3; |
|
605 |
#-- should return 0
|
|
606 |
#
|
|
607 |
select round(99999999999999999.999); |
|
608 |
#-- should return 100000000000000000
|
|
609 |
#
|
|
610 |
select round(-99999999999999999.999); |
|
611 |
#-- should return -100000000000000000
|
|
612 |
#
|
|
613 |
select round(99999999999999999.999,3); |
|
614 |
#-- should return 100000000000000000.000
|
|
615 |
#
|
|
616 |
select round(-99999999999999999.999,3); |
|
617 |
#-- should return -100000000000000000.000
|
|
618 |
#
|
|
619 |
select truncate(99999999999999999999999999999999999999,31); |
|
620 |
#-- should return 99999999999999999999999999999999999999.000
|
|
621 |
#
|
|
622 |
select truncate(99.999999999999999999999999999999999999,31); |
|
623 |
#-- should return 99.9999999999999999999999999999999
|
|
624 |
#
|
|
625 |
select truncate(99999999999999999999999999999999999999,-31); |
|
626 |
# should return 90000000000000000000000000000000
|
|
627 |
#
|
|
628 |
#-- 6. Set functions (AVG, SUM, COUNT) should work.
|
|
629 |
#
|
|
630 |
#drop table if exists t1;
|
|
631 |
#
|
|
632 |
#delimiter //
|
|
633 |
#
|
|
634 |
#create procedure p1 () begin
|
|
635 |
# declare v1 int default 1; declare v2 decimal(0,38) default 0;
|
|
636 |
# create table t1 (col1 decimal(0,38));
|
|
637 |
# while v1 <= 10000 do
|
|
638 |
# insert into t1 values (-v2);
|
|
639 |
# set v2 = v2 + 0.00000000000000000000000000000000000001;
|
|
640 |
# set v1 = v1 + 1;
|
|
641 |
# end while;
|
|
642 |
# select avg(col1),sum(col1),count(col1) from t1; end;//
|
|
643 |
#
|
|
644 |
#call p1()//
|
|
645 |
#-- should return
|
|
646 |
# -- avg(col1)=0.00000000000000000000000000000000000001 added 10,000 times, then divided by 10,000
|
|
647 |
# -- sum(col1)=0.00000000000000000000000000000000000001 added 10,000 times
|
|
648 |
#
|
|
649 |
# -- count(col1)=10000
|
|
650 |
#
|
|
651 |
#delimiter ;//
|
|
652 |
#
|
|
653 |
#drop procedure p1;
|
|
654 |
#drop table t1;
|
|
655 |
#
|
|
656 |
#-- When I say DECIMAL(x) I should be able to store x digits.
|
|
657 |
#-- If I can't, there should be an error at CREATE time.
|
|
658 |
#
|
|
659 |
#drop table if exists t1;
|
|
660 |
#
|
|
661 |
#create table t1 (col1 decimal(254));
|
|
662 |
#-- should return SQLSTATE 22003 numeric value out of range
|
|
663 |
#
|
|
664 |
#-- When I say DECIMAL(x,y) there should be no silent change of precision or
|
|
665 |
#-- scale.
|
|
666 |
#
|
|
667 |
#drop table if exists t1;
|
|
668 |
#
|
|
669 |
#create table t1 (col1 decimal(0,38));
|
|
670 |
#
|
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
671 |
#--replace_regex /ENGINE=[a-z]*/ENGINE=X/i
|
1
by brian
clean slate |
672 |
#show create table t1;
|
673 |
#-- should return:
|
|
674 |
#+-------+--------------------------------+
|
|
675 |
#| Table | Create Table |
|
|
676 |
#+-------+--------------------------------+
|
|
677 |
#| t9 | CREATE TABLE `t1` ( |
|
|
678 |
#|`s1` decimal(0,38) default NULL |
|
|
679 |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|
|
680 |
#+-------+--------------------------------+
|
|
681 |
#
|
|
682 |
#drop table t1;
|
|
683 |
#
|
|
684 |
#-- From WL#1612 "The future" point 2.:
|
|
685 |
#-- The standard requires that we treat numbers like "0.5" as
|
|
686 |
#-- DECIMAL or NUMERIC, not as floating-point.
|
|
687 |
#
|
|
688 |
#drop table if exists t1;
|
|
689 |
#
|
|
690 |
#
|
|
691 |
create table t1 as select 0.5; |
|
692 |
#
|
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
693 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
694 |
show create table t1; |
695 |
#-- should return:
|
|
696 |
#+-------+-----------------------------------+
|
|
697 |
#| Table | Create Table |
|
|
698 |
#+-------+-----------------------------------+
|
|
699 |
#| t7 | CREATE TABLE `t1` ( |
|
|
700 |
#| `0.5` decimal(3,1) NOT NULL default '0.0' |
|
|
701 |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|
|
702 |
#+-------+-----------------------------------+
|
|
703 |
#
|
|
704 |
drop table t1; |
|
705 |
#
|
|
706 |
#-- From WL#1612, "The future", point 3.: We have to start rounding correctly.
|
|
707 |
#
|
|
708 |
select round(1.5),round(2.5); |
|
709 |
#-- should return:
|
|
710 |
#+------------+------------+
|
|
711 |
#| round(1.5) | round(2.5) |
|
|
712 |
#+------------+------------+
|
|
713 |
#| 2 | 3 |
|
|
714 |
#+------------+------------+
|
|
715 |
#
|
|
716 |
#-- From WL#1612, "The future", point 4.: "select 0.07 * 0.07;" should return 0.0049, not 0.00.
|
|
717 |
#-- If operand#1 has scale X and operand#2 has scale Y, then result should have scale (X+Y).
|
|
718 |
#
|
|
719 |
select 0.07 * 0.07; |
|
720 |
#-- should return 0.0049
|
|
721 |
#
|
|
722 |
#-- From WL#1612, "The future", point 5.: Division by zero is an error.
|
|
723 |
select 1E-500 = 0; |
|
724 |
#-- should return 1 (true).
|
|
725 |
#
|
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
726 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
727 |
select 1 / 1E-500; |
728 |
#
|
|
729 |
#-- should return SQLSTATE 22012 division by zero.
|
|
730 |
#
|
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
731 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
732 |
select 1 / 0; |
733 |
#-- should return SQLSTATE 22012 division by zero.
|
|
734 |
#
|
|
735 |
#+-------+
|
|
736 |
#| 1 / 0 |
|
|
737 |
#+-------+
|
|
738 |
#| NULL |
|
|
739 |
#+-------+
|
|
740 |
#1 row in set, 1 warning (0.00 sec)
|
|
741 |
#
|
|
742 |
#-- From WL#1612 "The future" point 6.: Overflow is an error.
|
|
743 |
#
|
|
744 |
#set sql_mode='';
|
|
745 |
#
|
|
746 |
#select 1E300 * 1E300;
|
|
747 |
#-- should return SQLSTATE 22003 numeric value out of range
|
|
748 |
#
|
|
749 |
#select 18446744073709551615 + 1;
|
|
750 |
#-- should return SQLSTATE 22003 numeric value out of range
|
|
751 |
#
|
|
752 |
#-- 14. From WL#1612 "The future" point 7.:
|
|
753 |
#-- If s1 is INTEGER and s2 is DECIMAL, then
|
|
754 |
#-- "create table tk7 as select avg(s1),avg(s2) from tk;"
|
|
755 |
#-- should not create a table with "double(17,4)" data types.
|
|
756 |
#-- The result of AVG must still be exact numeric, with a
|
|
757 |
#-- scale the same or greater than the operand's scale.
|
|
758 |
#-- The result of SUM must still be exact numeric, with
|
|
759 |
#-- a scale the same as the operand's scale.
|
|
760 |
#
|
|
761 |
#drop table if exists t1;
|
|
762 |
#drop table if exists t2;
|
|
763 |
#
|
|
764 |
#create table t1 (col1 int, col2 decimal(5));
|
|
765 |
#
|
|
766 |
#create table t2 as select avg(col1),avg(col2) from t1;
|
|
767 |
#
|
|
768 |
#
|
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
769 |
#--replace_regex /ENGINE=[a-z]*/ENGINE=X/i
|
1
by brian
clean slate |
770 |
#show create table t2;
|
771 |
#-- should return:
|
|
772 |
#+-------+---------------------------------+
|
|
773 |
#| Table | Create Table |
|
|
774 |
#+-------+---------------------------------+
|
|
775 |
#| t2 | CREATE TABLE `t2` ( |
|
|
776 |
#| `avg(col1)` decimal(17,4) default NULL, |
|
|
777 |
#| `avg(col2)` decimal(17,5) default NULL |
|
|
778 |
#| ) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
|
|
779 |
#+-------+---------------------------------+
|
|
780 |
#
|
|
781 |
#drop table t2;
|
|
782 |
#drop table t1;
|
|
783 |
#
|
|
784 |
#-- From WL#1612 "The future" point 8.: Stop storing leading "+" signs and
|
|
785 |
# leading "0"s.
|
|
786 |
#
|
|
787 |
#drop table if exists t1;
|
|
788 |
#
|
|
789 |
#create table t1 (col1 decimal(5,2),col2 decimal(5) zerofill, col3 decimal(3,1));
|
|
790 |
#
|
|
791 |
#insert into t1 values (1,1,1);
|
|
792 |
#
|
|
793 |
#select col1 from t1 union select col2 from t1 union select col3 from t1;
|
|
794 |
#
|
|
795 |
#drop table t1;
|
|
796 |
#
|
|
797 |
#-- From WL#1612, The future" point 9.:
|
|
798 |
#-- Accept the data type and precision and scale as the user
|
|
799 |
#-- asks, or return an error, but don't change to something else.
|
|
800 |
#
|
|
801 |
#drop table if exists t1;
|
|
802 |
#
|
|
803 |
#create table t1 (col1 numeric(4,2));
|
|
804 |
#
|
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
805 |
#--replace_regex /ENGINE=[a-z]*/ENGINE=X/i
|
1
by brian
clean slate |
806 |
#show create table t1;
|
807 |
#
|
|
808 |
#drop table t1;
|
|
809 |
#
|
|
810 |
#-- The scripts in the following bugs should work:
|
|
811 |
#
|
|
812 |
||
813 |
#BUG#559 Maximum precision for DECIMAL column ...
|
|
814 |
#BUG#1499 INSERT/UPDATE into decimal field rounding problem
|
|
815 |
#BUG#1845 Not correctly recognising value for decimal field
|
|
816 |
#BUG#2493 Round function doesn't work correctly
|
|
817 |
#BUG#2649 round(0.5) gives 0 (should be 1)
|
|
818 |
#BUG#3612 impicite rounding of VARCHARS during aritchmetic operations...
|
|
819 |
#BUG#3722 SELECT fails for certain values in Double(255,10) column.
|
|
820 |
#BUG#4485 Floating point conversions are inconsistent
|
|
821 |
#BUG#4891 MATH
|
|
822 |
#BUG#5931 Out-of-range values are accepted
|
|
823 |
#BUG#6048 Stored procedure causes operating system reboot
|
|
824 |
#BUG#6053 DOUBLE PRECISION literal
|
|
825 |
||
826 |
# Tests from 'traditional' mode tests
|
|
827 |
#
|
|
828 |
CREATE TABLE Sow6_2f (col1 NUMERIC(4,2)); |
|
829 |
#-- should return OK
|
|
830 |
INSERT INTO Sow6_2f VALUES (10.55); |
|
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
831 |
# This INSERT statement will give an error since truncation of a
|
832 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
833 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
834 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
835 |
INSERT INTO Sow6_2f VALUES (10.5555); |
836 |
#-- should return OK
|
|
837 |
INSERT INTO Sow6_2f VALUES (-10.55); |
|
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
838 |
# This INSERT statement will give an error since truncation of a
|
839 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
840 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
841 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
842 |
INSERT INTO Sow6_2f VALUES (-10.5555); |
843 |
#-- should return OK
|
|
844 |
INSERT INTO Sow6_2f VALUES (11); |
|
845 |
#-- should return OK
|
|
2131.5.1
by kalebral at gmail
remove error numbers in tests and use enum values only |
846 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
847 |
INSERT INTO Sow6_2f VALUES (101.55); |
848 |
#-- should return SQLSTATE 22003 numeric value out of range
|
|
2131.5.1
by kalebral at gmail
remove error numbers in tests and use enum values only |
849 |
#--error ER_WARN_DATA_OUT_OF_RANGE
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
850 |
#UPDATE Sow6_2f SET col1 = col1 * 50 WHERE col1 = 11;
|
1
by brian
clean slate |
851 |
#-- should return SQLSTATE 22003 numeric value out of range
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
852 |
#-- error 1365
|
853 |
#UPDATE Sow6_2f SET col1 = col1 / 0 WHERE col1 > 0;
|
|
1
by brian
clean slate |
854 |
#-- should return SQLSTATE 22012 division by zero
|
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
855 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
856 |
SELECT MOD(col1,0) FROM Sow6_2f; |
857 |
#-- should return SQLSTATE 22012 division by zero
|
|
2131.5.1
by kalebral at gmail
remove error numbers in tests and use enum values only |
858 |
--error ER_TRUNCATED_WRONG_VALUE_FOR_FIELD |
1
by brian
clean slate |
859 |
INSERT INTO Sow6_2f VALUES ('a59b'); |
860 |
#-- should return SQLSTATE 22018 invalid character value for cast
|
|
861 |
drop table Sow6_2f; |
|
862 |
||
863 |
#
|
|
864 |
# bug#9501
|
|
865 |
#
|
|
866 |
select 10.3330000000000/12.34500000; |
|
867 |
||
868 |
#
|
|
869 |
# Bug #10404
|
|
870 |
#
|
|
871 |
||
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
872 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
873 |
select 0/0; |
874 |
||
875 |
#
|
|
876 |
# bug #9546
|
|
877 |
#
|
|
878 |
--disable_ps_protocol |
|
879 |
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 as x; |
|
880 |
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x; |
|
881 |
--enable_ps_protocol |
|
882 |
#
|
|
883 |
# Bug #10004
|
|
884 |
#
|
|
885 |
select 0.190287977636363637 + 0.040372670 * 0 - 0; |
|
886 |
#
|
|
887 |
# Bug #9527
|
|
888 |
#
|
|
889 |
select -0.123 * 0; |
|
890 |
||
891 |
#
|
|
892 |
# Bug #10232
|
|
893 |
#
|
|
894 |
||
895 |
CREATE TABLE t1 (f1 DECIMAL (12,9), f2 DECIMAL(2,2)); |
|
896 |
INSERT INTO t1 VALUES (10.5, 0); |
|
897 |
UPDATE t1 SET f1 = 4.5; |
|
898 |
SELECT * FROM t1; |
|
899 |
DROP TABLE t1; |
|
900 |
CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2)); |
|
901 |
INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0); |
|
902 |
SELECT * FROM t1; |
|
903 |
DROP TABLE t1; |
|
904 |
||
905 |
#
|
|
906 |
# Bug #10599: problem with NULL
|
|
907 |
#
|
|
908 |
||
1812.4.2
by Brian Aker
Fix issue with divide by zero not being an error. |
909 |
--error ER_DIVISION_BY_ZERO |
1
by brian
clean slate |
910 |
select abs(10/0); |
911 |
select abs(NULL); |
|
912 |
||
913 |
#
|
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
914 |
# Bug #9894 (negative to column)
|
1
by brian
clean slate |
915 |
#
|
413.2.2
by Brian Aker
Removed UNSIGNED from parser. |
916 |
create table t1( d1 decimal(18), d2 decimal(20), d3 decimal (22)); |
1
by brian
clean slate |
917 |
insert into t1 values(1,-1,-1); |
918 |
drop table t1; |
|
919 |
create table t1 (col1 decimal(5,2), col2 numeric(5,2)); |
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
920 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
921 |
insert into t1 values (999.999,999.999); |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
922 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
923 |
insert into t1 values (-999.999,-999.999); |
924 |
select * from t1; |
|
925 |
drop table t1; |
|
926 |
||
927 |
#
|
|
928 |
# Bug #8425 (insufficient precision of the division)
|
|
929 |
#
|
|
930 |
set @sav_dpi= @@div_precision_increment; |
|
931 |
set @@div_precision_increment=15; |
|
932 |
create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); |
|
933 |
insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); |
|
934 |
select col2/9999999999 from t1 where col1=1; |
|
935 |
select 9999999999/col2 from t1 where col1=1; |
|
936 |
select 77777777/7777777; |
|
937 |
drop table t1; |
|
938 |
set div_precision_increment= @sav_dpi; |
|
939 |
||
940 |
#
|
|
941 |
# Bug #10896 (0.00 > -0.00)
|
|
942 |
#
|
|
943 |
create table t1 (a decimal(4,2)); |
|
944 |
insert into t1 values (0.00); |
|
945 |
select * from t1 where a > -0.00; |
|
946 |
select * from t1 where a = -0.00; |
|
947 |
drop table t1; |
|
948 |
||
949 |
#
|
|
950 |
# Bug #11215: a problem with LONGLONG_MIN
|
|
951 |
#
|
|
952 |
||
953 |
create table t1 (col1 bigint default -9223372036854775808); |
|
954 |
insert into t1 values (default); |
|
955 |
select * from t1; |
|
956 |
drop table t1; |
|
957 |
||
958 |
#
|
|
959 |
# Bug #10891 (converting to decimal crashes server)
|
|
960 |
#
|
|
961 |
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15)); |
|
962 |
||
963 |
#
|
|
964 |
# Bug #11708 (conversion to decimal fails in decimal part)
|
|
965 |
#
|
|
966 |
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3; |
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
967 |
--error ER_M_BIGGER_THAN_D |
1
by brian
clean slate |
968 |
select convert(ln(14000),decimal(2,3)) c1; |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
969 |
--error ER_M_BIGGER_THAN_D |
1
by brian
clean slate |
970 |
select cast(ln(14000) as decimal(2,3)) c1; |
971 |
||
972 |
#
|
|
973 |
# Bug #8449 (Silent column changes)
|
|
974 |
#
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
975 |
--error ER_TOO_BIG_PRECISION |
1
by brian
clean slate |
976 |
create table t1 (sl decimal(70,30)); |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
977 |
--error ER_TOO_BIG_SCALE |
1
by brian
clean slate |
978 |
create table t1 (sl decimal(32,31)); |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
979 |
--error ER_TOO_BIG_SCALE |
1
by brian
clean slate |
980 |
create table t1 (sl decimal(0,38)); |
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
981 |
--error ER_M_BIGGER_THAN_D |
1
by brian
clean slate |
982 |
create table t1 (sl decimal(0,30)); |
983 |
create table t1 (sl decimal(5, 5)); |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
984 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
985 |
show create table t1; |
986 |
drop table t1; |
|
987 |
# Test limits
|
|
988 |
create table t1 (sl decimal(65, 30)); |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
989 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
990 |
show create table t1; |
991 |
drop table t1; |
|
992 |
||
993 |
#
|
|
994 |
# Bug 12173 (show create table fails)
|
|
995 |
#
|
|
996 |
create table t1 ( |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
997 |
f0 decimal (30,30) not null DEFAULT 0, |
998 |
f1 decimal (0,0) not null default 0); |
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
999 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
1000 |
show create table t1; |
1001 |
drop table t1; |
|
1002 |
||
1003 |
#
|
|
1004 |
# Bug #13667 (Inconsistency for decimal(m,d) specification
|
|
1005 |
#
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1006 |
--error ER_M_BIGGER_THAN_D |
1
by brian
clean slate |
1007 |
create table t (d decimal(0,10)); |
1008 |
||
1009 |
#
|
|
1010 |
# Bug #14268 (bad FLOAT->DECIMAL conversion)
|
|
1011 |
#
|
|
1012 |
||
1013 |
CREATE TABLE t1 ( |
|
1014 |
my_float FLOAT, |
|
1015 |
my_double DOUBLE, |
|
1016 |
my_varchar VARCHAR(50), |
|
1017 |
my_decimal DECIMAL(65,30) |
|
1018 |
);
|
|
496.1.2
by Paul McCullagh
Changes to .test files to run both PBXT and InnoDB |
1019 |
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i |
1
by brian
clean slate |
1020 |
SHOW CREATE TABLE t1; |
1021 |
||
1022 |
let $max_power= 32; |
|
910.4.13
by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker. |
1023 |
begin; |
1
by brian
clean slate |
1024 |
while ($max_power) |
1025 |
{
|
|
1026 |
eval INSERT INTO t1 SET my_float = 1.175494345e-$max_power, |
|
1027 |
my_double = 1.175494345e-$max_power, |
|
1028 |
my_varchar = '1.175494345e-$max_power'; |
|
1029 |
dec $max_power; |
|
1030 |
}
|
|
910.4.13
by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker. |
1031 |
commit; |
1
by brian
clean slate |
1032 |
SELECT my_float, my_double, my_varchar FROM t1; |
1033 |
||
1034 |
# The following statement produces results with garbage past
|
|
1035 |
# the significant digits. Improving it is a part of the WL#3977.
|
|
1036 |
SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1; |
|
1037 |
SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1; |
|
1038 |
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1; |
|
1039 |
||
1040 |
# We have to disable warnings here as the test in
|
|
1041 |
# Field_new_decimal::store(double):
|
|
1042 |
# if (nr2 != nr)
|
|
1043 |
# fails randomly depending on compiler options
|
|
1044 |
||
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
1045 |
#--disable_warnings
|
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
1046 |
# This UPDATE statement will give an error since truncation of a
|
1047 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
1048 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1049 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
1050 |
UPDATE t1 SET my_decimal = my_float; |
1051 |
||
1052 |
# Expected result 0.000000000011754943372854760000
|
|
1053 |
# On windows we get 0.000000000011754943372854770000
|
|
1054 |
# use replace_result to correct it
|
|
1055 |
--replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000 |
|
1056 |
SELECT my_decimal, my_float FROM t1; |
|
1057 |
||
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
1058 |
# This UPDATE statement will give an error since truncation of a
|
1059 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
1060 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1061 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
1062 |
UPDATE t1 SET my_decimal = my_double; |
1063 |
SELECT my_decimal, my_double FROM t1; |
|
1064 |
--enable_warnings |
|
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
1065 |
# This UPDATE statement will give an error since truncation of a
|
1066 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
1067 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1068 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
1069 |
UPDATE t1 SET my_decimal = my_varchar; |
1070 |
SELECT my_decimal, my_varchar FROM t1; |
|
1071 |
||
1072 |
DROP TABLE t1; |
|
1073 |
||
1074 |
#
|
|
1075 |
# Bug #13573 (Wrong data inserted for too big values)
|
|
1076 |
#
|
|
1077 |
||
1078 |
create table t1 (c1 decimal(64)); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
1079 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
1080 |
insert into t1 values( |
1081 |
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
1082 |
--error ER_TRUNCATED_WRONG_VALUE |
1
by brian
clean slate |
1083 |
insert into t1 values( |
1084 |
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 * |
|
1085 |
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); |
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
1086 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
1087 |
insert into t1 values(1e100); |
1088 |
select * from t1; |
|
1089 |
drop table t1; |
|
1090 |
||
1091 |
#
|
|
1092 |
# Bug #18014: problem with 'alter table'
|
|
1093 |
#
|
|
1094 |
||
1095 |
create table t1(a decimal(7,2)); |
|
1096 |
insert into t1 values(123.12); |
|
1097 |
select * from t1; |
|
1098 |
alter table t1 modify a decimal(10,2); |
|
1099 |
select * from t1; |
|
1100 |
drop table t1; |
|
1101 |
||
1102 |
#
|
|
1103 |
# Bug#19667 group by a decimal expression yields wrong result
|
|
1104 |
#
|
|
1105 |
create table t1 (i int, j int); |
|
1106 |
insert into t1 values (1,1), (1,2), (2,3), (2,4); |
|
1107 |
select i, count(distinct j) from t1 group by i; |
|
1108 |
select i+0.0 as i2, count(distinct j) from t1 group by i2; |
|
1109 |
drop table t1; |
|
1110 |
||
1111 |
create table t1(f1 decimal(20,6)); |
|
1112 |
insert into t1 values (CAST('10:11:12' AS date) + interval 14 microsecond); |
|
1113 |
select * from t1; |
|
1114 |
drop table t1; |
|
1115 |
||
1116 |
#
|
|
1117 |
# Bug #24558: Increasing decimal column length causes data loss
|
|
1118 |
#
|
|
1119 |
create table t1(a decimal(18)); |
|
1120 |
insert into t1 values(123456789012345678); |
|
1121 |
alter table t1 modify column a decimal(19); |
|
1122 |
select * from t1; |
|
1123 |
drop table t1; |
|
1124 |
||
1125 |
#
|
|
1126 |
# Bug #27957 cast as decimal does not check overflow, also inconsistent with group, subselect
|
|
1127 |
#
|
|
1128 |
||
1129 |
select cast(11.1234 as DECIMAL(3,2)); |
|
1130 |
select * from (select cast(11.1234 as DECIMAL(3,2))) t; |
|
1131 |
||
1132 |
select cast(a as DECIMAL(3,2)) |
|
1133 |
from (select 11.1233 as a |
|
1134 |
UNION select 11.1234 |
|
1135 |
UNION select 12.1234 |
|
1136 |
) t; |
|
1137 |
||
1138 |
select cast(a as DECIMAL(3,2)), count(*) |
|
1139 |
from (select 11.1233 as a |
|
1140 |
UNION select 11.1234 |
|
1141 |
UNION select 12.1234 |
|
1142 |
) t group by 1; |
|
1143 |
||
1144 |
#
|
|
1145 |
# Bug #28361 Buffer overflow in DECIMAL code on Windows
|
|
1146 |
#
|
|
1147 |
||
1148 |
create table t1 (s varchar(100)); |
|
1149 |
insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875); |
|
1150 |
drop table t1; |
|
1151 |
||
1152 |
#
|
|
1153 |
# Bug #27984 Long Decimal Maths produces truncated results
|
|
1154 |
#
|
|
1155 |
||
1156 |
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b; |
|
1157 |
||
1158 |
#
|
|
1159 |
# Bug #29415: CAST AS DECIMAL(P,S) with too big precision/scale
|
|
1160 |
#
|
|
1161 |
||
1162 |
SELECT CAST(1 AS decimal(65,10)); |
|
1163 |
--error ER_TOO_BIG_PRECISION |
|
1164 |
SELECT CAST(1 AS decimal(66,10)); |
|
1165 |
||
1166 |
SELECT CAST(1 AS decimal(65,30)); |
|
1167 |
--error ER_TOO_BIG_SCALE |
|
1168 |
SELECT CAST(1 AS decimal(65,31)); |
|
1169 |
||
1170 |
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL); |
|
1171 |
INSERT INTO t1 VALUES (3,30), (1,10), (2,10); |
|
1172 |
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa; |
|
1173 |
--error ER_TOO_BIG_SCALE |
|
1174 |
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa; |
|
1175 |
||
1176 |
DROP TABLE t1; |
|
1177 |
||
1178 |
#
|
|
1179 |
# Bug #29417: assertion abort for a grouping query with decimal user variable
|
|
1180 |
#
|
|
1181 |
||
1182 |
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL); |
|
1183 |
INSERT INTO t1 VALUES (3,30), (1,10), (2,10); |
|
1184 |
||
1185 |
SET @a= CAST(1 AS decimal); |
|
1186 |
SELECT 1 FROM t1 GROUP BY @b := @a, @b; |
|
1187 |
||
1188 |
DROP TABLE t1; |
|
1189 |
||
1190 |
#
|
|
1191 |
# Bug #24907: unpredictable (display) precission, if input precission
|
|
1192 |
# increases
|
|
1193 |
#
|
|
1194 |
||
1195 |
# As per 10.1.1. Overview of Numeric Types, type (new) DECIMAL has a
|
|
1196 |
# maxmimum precision of 30 places after the decimal point. Show that
|
|
1197 |
# temp field creation beyond that works and throws a truncation warning.
|
|
1198 |
# DECIMAL(37,36) should be adjusted to DECIMAL(31,30).
|
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
1199 |
# After Bug#337038, truncation throws an error and not a warning. Thus, we
|
1200 |
# will change the behavior here to expect an error. We are leaving the
|
|
1201 |
# original test case here so people can see how behavior changed.
|
|
1202 |
#CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
|
|
1203 |
#DESC t1;
|
|
1204 |
#SELECT f1 FROM t1;
|
|
1205 |
#DROP TABLE t1;
|
|
970.2.5
by Padraig O'Sullivan
Added extra comments to parts of test cases that were modified for this bug |
1206 |
# This CREATE statement will give an error since truncation of a
|
1207 |
# decimal number in Drizzle is an error. See bug#337038 for further
|
|
1208 |
# details.
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1209 |
--error ER_WARN_DATA_TRUNCATED |
1
by brian
clean slate |
1210 |
CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1; |
1211 |
||
1212 |
# too many decimal places, AND too many digits altogether (90 = 45+45).
|
|
1213 |
# should preserve integers (65 = 45+20)
|
|
215
by Brian Aker
Fixed newdecimal test and added it to standard tests. |
1214 |
--error ER_WARN_DATA_OUT_OF_RANGE |
1
by brian
clean slate |
1215 |
CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1; |
1216 |
||
1217 |
--echo End of 5.0 tests |
|
1218 |
||
1219 |
#
|
|
1220 |
# Bug#16172 DECIMAL data type processed incorrectly
|
|
1221 |
#
|
|
1222 |
select cast(143.481 as decimal(4,1)); |
|
1223 |
select cast(143.481 as decimal(4,0)); |
|
1224 |
select cast(143.481 as decimal(2,1)); |
|
1225 |
select cast(-3.4 as decimal(2,1)); |
|
1226 |
select cast(99.6 as decimal(2,0)); |
|
1227 |
select cast(-13.4 as decimal(2,1)); |
|
1228 |
select cast(98.6 as decimal(2,0)); |
|
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
1229 |
|
1230 |
#
|
|
1231 |
## Bug337038 Decimal truncation is warning, not error
|
|
1232 |
#
|
|
1731.3.1
by Lee Bieber
change tests to use enum values instead of error numbers |
1233 |
--error ER_INVALID_DEFAULT |
970.2.1
by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but |
1234 |
create table t1 (f1 decimal not null default 17.49); |
1235 |