~ubuntu-branches/ubuntu/saucy/drizzle/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/t/type_newdecimal.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-03-18 12:12:31 UTC
  • Revision ID: james.westby@ubuntu.com-20100318121231-k6g1xe6cshbwa0f8
Tags: upstream-2010.03.1347
ImportĀ upstreamĀ versionĀ 2010.03.1347

Show diffs side-by-side

added added

removed removed

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