~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1;
2
select 1.1 IN (1.0, 1.2);
3
1.1 IN (1.0, 1.2)
4
0
5
select 1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5);
6
1.1 IN (1.0, 1.2, 1.1, 1.4, 0.5)
7
1
8
select 1.1 IN (1.0, 1.2, NULL, 1.4, 0.5);
9
1.1 IN (1.0, 1.2, NULL, 1.4, 0.5)
10
NULL
11
select 0.5 IN (1.0, 1.2, NULL, 1.4, 0.5);
12
0.5 IN (1.0, 1.2, NULL, 1.4, 0.5)
13
1
14
select 1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5);
15
1 IN (1.11, 1.2, 1.1, 1.4, 1, 0.5)
16
1
17
select 1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5);
18
1 IN (1.11, 1.2, 1.1, 1.4, NULL, 0.5)
19
NULL
20
select case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END;
21
case 1.0 when 0.1 then "a" when 1.0 then "b" else "c" END
22
b
23
select case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END;
24
case 0.1 when 0.1 then "a" when 1.0 then "b" else "c" END
25
a
26
select case 1 when 0.1 then "a" when 1.0 then "b" else "c" END;
27
case 1 when 0.1 then "a" when 1.0 then "b" else "c" END
28
b
29
select case 1.0 when 0.1 then "a" when 1 then "b" else "c" END;
30
case 1.0 when 0.1 then "a" when 1 then "b" else "c" END
31
b
32
select case 1.001 when 0.1 then "a" when 1 then "b" else "c" END;
33
case 1.001 when 0.1 then "a" when 1 then "b" else "c" END
34
c
35
create table t1 (a decimal(6,3));
36
insert into t1 values (1.0), (NULL), (0.1);
37
select * from t1;
38
a
39
1.000
40
NULL
41
0.100
42
select 0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5) from t1;
43
0.1 in (1.0, 1.2, 1.1, a, 1.4, 0.5)
44
0
45
NULL
46
1
47
drop table t1;
48
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);
49
select * from t1;
50
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)
51
1.1	1.2	1.1	1.1	1.2	2.2	1.1
52
show create table t1;
53
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
54
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
55
  `if(1, 1.1, 1.2)` DECIMAL(2,1) NOT NULL,
56
  `if(0, 1.1, 1.2)` DECIMAL(2,1) NOT NULL,
57
  `if(0.1, 1.1, 1.2)` DECIMAL(2,1) NOT NULL,
58
  `if(0, 1, 1.1)` DECIMAL(2,1) NOT NULL,
59
  `if(0, NULL, 1.2)` DECIMAL(2,1) DEFAULT NULL,
60
  `if(1, 0.22e1, 1.1)` DOUBLE NOT NULL,
61
  `if(1E0, 1.1, 1.2)` DECIMAL(2,1) NOT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
62
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
63
drop table t1;
64
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);
65
select * from t1;
66
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)
67
NULL	1.1	NULL	NULL	NULL	1
68
show create table t1;
69
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
70
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
71
  `nullif(1.1, 1.1)` DECIMAL(2,1) DEFAULT NULL,
72
  `nullif(1.1, 1.2)` DECIMAL(2,1) DEFAULT NULL,
73
  `nullif(1.1, 0.11e1)` DECIMAL(2,1) DEFAULT NULL,
74
  `nullif(1.0, 1)` DECIMAL(2,1) DEFAULT NULL,
75
  `nullif(1, 1.0)` INT DEFAULT NULL,
76
  `nullif(1, 1.1)` INT DEFAULT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
77
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
78
drop table t1;
79
create table t1 (a decimal(4,2));
80
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
81
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
82
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
83
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
84
select a from t1;
85
a
86
drop table t1;
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
87
create table t1 (a decimal(4,2));
1 by brian
clean slate
88
insert into t1 value (10000), (1.1e10), ("11111"), (100000.1);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
89
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
90
insert into t1 value (-10000), (-1.1e10), ("-11111"), (-100000.1);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
91
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
92
select a from t1;
93
a
94
drop table t1;
95
create table t1 (a bigint);
96
insert into t1 values (18446744073709551615.0);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
97
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
98
insert into t1 values (9223372036854775808.0);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
99
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
100
insert into t1 values (-18446744073709551615.0);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
101
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
102
select * from t1;
103
a
104
drop table t1;
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
105
create table t1 (a bigint);
106
insert into t1 values (9223372036854775807.0);
1 by brian
clean slate
107
insert into t1 values (9999999999999999999999999.000);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
108
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
109
insert into t1 values (-1.0);
110
select * from t1;
111
a
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
112
9223372036854775807
113
-1
1 by brian
clean slate
114
drop table t1;
396 by Brian Aker
Cleanup tiny and small int.
115
create table t1 (a int);
1 by brian
clean slate
116
insert into t1 values (18446744073709551615.0);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
117
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
118
insert into t1 values (9223372036854775808.0);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
119
ERROR 22003: Out of range value for column 'a' at row 1
1 by brian
clean slate
120
select * from t1;
121
a
122
drop table t1;
123
create table t1 select round(15.4,-1), truncate(-5678.123451,-3), abs(-1.1), -(-1.1);
124
show create table t1;
125
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
126
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
127
  `round(15.4,-1)` DECIMAL(3,0) NOT NULL,
128
  `truncate(-5678.123451,-3)` DECIMAL(4,0) NOT NULL,
129
  `abs(-1.1)` DECIMAL(3,1) NOT NULL,
130
  `-(-1.1)` DECIMAL(2,1) NOT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
131
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
132
drop table t1;
133
select 1e10/0e0;
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
134
ERROR 22012: Division by 0
1 by brian
clean slate
135
select 1/3;
136
1/3
137
0.3333
138
select 0.8=0.7+0.1;
139
0.8=0.7+0.1
140
1
141
select 0.7+0.1;
142
0.7+0.1
143
0.8
144
create table wl1612_1 (col1 int);
145
insert into wl1612_1 values(10);
146
select * from wl1612_1 where 0.8=0.7+0.1;
147
col1
148
10
149
select 0.07+0.07 from wl1612_1;
150
0.07+0.07
151
0.14
152
select 0.07-0.07 from wl1612_1;
153
0.07-0.07
154
0.00
155
select 0.07*0.07 from wl1612_1;
156
0.07*0.07
157
0.0049
158
select 0.07/0.07 from wl1612_1;
159
0.07/0.07
160
1.000000
161
drop table wl1612_1;
162
create table wl1612_2 (col1 decimal(10,2), col2 numeric(10,2));
163
insert into wl1612_2 values(1,1);
164
insert into wl1612_2 values(+1,+1);
165
insert into wl1612_2 values(+01,+01);
166
insert into wl1612_2 values(+001,+001);
167
select col1,count(*) from wl1612_2 group by col1;
168
col1	count(*)
169
1.00	4
170
select col2,count(*) from wl1612_2 group by col2;
171
col2	count(*)
172
1.00	4
173
drop table wl1612_2;
174
create table wl1612_3 (col1 decimal(10,2), col2 numeric(10,2));
175
insert into wl1612_3 values('1','1');
176
insert into wl1612_3 values('+1','+1');
177
insert into wl1612_3 values('+01','+01');
178
insert into wl1612_3 values('+001','+001');
179
select col1,count(*) from wl1612_3 group by col1;
180
col1	count(*)
181
1.00	4
182
select col2,count(*) from wl1612_3 group by col2;
183
col2	count(*)
184
1.00	4
185
drop table wl1612_3;
186
select mod(234,10) ;
187
mod(234,10)
188
4
189
select mod(234.567,10.555);
190
mod(234.567,10.555)
191
2.357
192
select mod(-234.567,10.555);
193
mod(-234.567,10.555)
194
-2.357
195
select mod(234.567,-10.555);
196
mod(234.567,-10.555)
197
2.357
198
select round(15.1);
199
round(15.1)
200
15
201
select round(15.4);
202
round(15.4)
203
15
204
select round(15.5);
205
round(15.5)
206
16
207
select round(15.6);
208
round(15.6)
209
16
210
select round(15.9);
211
round(15.9)
212
16
213
select round(-15.1);
214
round(-15.1)
215
-15
216
select round(-15.4);
217
round(-15.4)
218
-15
219
select round(-15.5);
220
round(-15.5)
221
-16
222
select round(-15.6);
223
round(-15.6)
224
-16
225
select round(-15.9);
226
round(-15.9)
227
-16
228
select round(15.1,1);
229
round(15.1,1)
230
15.1
231
select round(15.4,1);
232
round(15.4,1)
233
15.4
234
select round(15.5,1);
235
round(15.5,1)
236
15.5
237
select round(15.6,1);
238
round(15.6,1)
239
15.6
240
select round(15.9,1);
241
round(15.9,1)
242
15.9
243
select round(-15.1,1);
244
round(-15.1,1)
245
-15.1
246
select round(-15.4,1);
247
round(-15.4,1)
248
-15.4
249
select round(-15.5,1);
250
round(-15.5,1)
251
-15.5
252
select round(-15.6,1);
253
round(-15.6,1)
254
-15.6
255
select round(-15.9,1);
256
round(-15.9,1)
257
-15.9
258
select round(15.1,0);
259
round(15.1,0)
260
15
261
select round(15.4,0);
262
round(15.4,0)
263
15
264
select round(15.5,0);
265
round(15.5,0)
266
16
267
select round(15.6,0);
268
round(15.6,0)
269
16
270
select round(15.9,0);
271
round(15.9,0)
272
16
273
select round(-15.1,0);
274
round(-15.1,0)
275
-15
276
select round(-15.4,0);
277
round(-15.4,0)
278
-15
279
select round(-15.5,0);
280
round(-15.5,0)
281
-16
282
select round(-15.6,0);
283
round(-15.6,0)
284
-16
285
select round(-15.9,0);
286
round(-15.9,0)
287
-16
288
select round(15.1,-1);
289
round(15.1,-1)
290
20
291
select round(15.4,-1);
292
round(15.4,-1)
293
20
294
select round(15.5,-1);
295
round(15.5,-1)
296
20
297
select round(15.6,-1);
298
round(15.6,-1)
299
20
300
select round(15.9,-1);
301
round(15.9,-1)
302
20
303
select round(-15.1,-1);
304
round(-15.1,-1)
305
-20
306
select round(-15.4,-1);
307
round(-15.4,-1)
308
-20
309
select round(-15.5,-1);
310
round(-15.5,-1)
311
-20
312
select round(-15.6,-1);
313
round(-15.6,-1)
314
-20
315
select round(-15.91,-1);
316
round(-15.91,-1)
317
-20
318
select truncate(5678.123451,0);
319
truncate(5678.123451,0)
320
5678
321
select truncate(5678.123451,1);
322
truncate(5678.123451,1)
323
5678.1
324
select truncate(5678.123451,2);
325
truncate(5678.123451,2)
326
5678.12
327
select truncate(5678.123451,3);
328
truncate(5678.123451,3)
329
5678.123
330
select truncate(5678.123451,4);
331
truncate(5678.123451,4)
332
5678.1234
333
select truncate(5678.123451,5);
334
truncate(5678.123451,5)
335
5678.12345
336
select truncate(5678.123451,6);
337
truncate(5678.123451,6)
338
5678.123451
339
select truncate(5678.123451,-1);
340
truncate(5678.123451,-1)
341
5670
342
select truncate(5678.123451,-2);
343
truncate(5678.123451,-2)
344
5600
345
select truncate(5678.123451,-3);
346
truncate(5678.123451,-3)
347
5000
348
select truncate(5678.123451,-4);
349
truncate(5678.123451,-4)
350
0
351
select truncate(-5678.123451,0);
352
truncate(-5678.123451,0)
353
-5678
354
select truncate(-5678.123451,1);
355
truncate(-5678.123451,1)
356
-5678.1
357
select truncate(-5678.123451,2);
358
truncate(-5678.123451,2)
359
-5678.12
360
select truncate(-5678.123451,3);
361
truncate(-5678.123451,3)
362
-5678.123
363
select truncate(-5678.123451,4);
364
truncate(-5678.123451,4)
365
-5678.1234
366
select truncate(-5678.123451,5);
367
truncate(-5678.123451,5)
368
-5678.12345
369
select truncate(-5678.123451,6);
370
truncate(-5678.123451,6)
371
-5678.123451
372
select truncate(-5678.123451,-1);
373
truncate(-5678.123451,-1)
374
-5670
375
select truncate(-5678.123451,-2);
376
truncate(-5678.123451,-2)
377
-5600
378
select truncate(-5678.123451,-3);
379
truncate(-5678.123451,-3)
380
-5000
381
select truncate(-5678.123451,-4);
382
truncate(-5678.123451,-4)
383
0
384
create table wl1612_4 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
385
insert into wl1612_4 values(1,0.0123456789012345678912345,0.0123456789012345678912345);
386
select col2/9999999999 from wl1612_4 where col1=1;
387
col2/9999999999
388
0.00000000000123456789024691358
389
select col3/9999999999 from wl1612_4 where col1=1;
390
col3/9999999999
391
0.00000000000123456789024691358
392
select 9999999999/col2 from wl1612_4 where col1=1;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
393
9999999999/col2 
1 by brian
clean slate
394
810000007209.0001
395
select 9999999999/col3 from wl1612_4 where col1=1;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
396
9999999999/col3 
1 by brian
clean slate
397
810000007209.0001
398
select col2*9999999999 from wl1612_4 where col1=1;
399
col2*9999999999
400
123456789.0000000000111104321087655
401
select col3*9999999999 from wl1612_4 where col1=1;
402
col3*9999999999
403
123456789.0000000000111104321087655
404
insert into wl1612_4 values(2,55555.0123456789012345678912345,55555.0123456789012345678912345);
405
select col2/9999999999 from wl1612_4 where col1=2;
406
col2/9999999999
407
0.00000555550123512344024696913
408
select col3/9999999999 from wl1612_4 where col1=2;
409
col3/9999999999
410
0.00000555550123512344024696913
411
select 9999999999/col2 from wl1612_4 where col1=2;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
412
9999999999/col2 
1 by brian
clean slate
413
180001.7600
414
select 9999999999/col3 from wl1612_4 where col1=2;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
415
9999999999/col3 
1 by brian
clean slate
416
180001.7600
417
select col2*9999999999 from wl1612_4 where col1=2;
418
col2*9999999999
419
555550123401234.0000000000111104321087655
420
select col3*9999999999 from wl1612_4 where col1=2;
421
col3*9999999999
422
555550123401234.0000000000111104321087655
423
drop table wl1612_4;
424
select 23.4 + (-41.7), 23.4 - (41.7) = -18.3;
425
23.4 + (-41.7)	23.4 - (41.7) = -18.3
426
-18.3	1
427
select -18.3=-18.3;
428
-18.3=-18.3
429
1
430
select 18.3=18.3;
431
18.3=18.3
432
1
433
select -18.3=18.3;
434
-18.3=18.3
435
0
436
select 0.8 = 0.7 + 0.1;
437
0.8 = 0.7 + 0.1
438
1
439
drop table if exists t1;
440
Warnings:
441
Note	1051	Unknown table 't1'
442
create table t1 (col1 decimal(38));
443
insert into t1 values (12345678901234567890123456789012345678);
444
select * from t1;
445
col1
446
12345678901234567890123456789012345678
447
drop table t1;
448
create table t1 (col1 decimal(31,30));
449
insert into t1 values (0.00000000001);
450
select * from t1;
451
col1
452
0.000000000010000000000000000000
453
drop table t1;
454
select 7777777777777777777777777777777777777 * 10;
455
7777777777777777777777777777777777777 * 10
456
77777777777777777777777777777777777770
457
select .7777777777777777777777777777777777777 *
458
1000000000000000000;
459
.7777777777777777777777777777777777777 *
460
1000000000000000000
461
777777777777777777.777777777777777777700000000000
462
select .7777777777777777777777777777777777777 - 0.1;
463
.7777777777777777777777777777777777777 - 0.1
464
0.6777777777777777777777777777777777777
465
select .343434343434343434 + .343434343434343434;
466
.343434343434343434 + .343434343434343434
467
0.686868686868686868
468
select abs(9999999999999999999999);
469
abs(9999999999999999999999)
470
9999999999999999999999
471
select abs(-9999999999999999999999);
472
abs(-9999999999999999999999)
473
9999999999999999999999
474
select ceiling(999999999999999999);
475
ceiling(999999999999999999)
476
999999999999999999
477
select ceiling(99999999999999999999);
478
ceiling(99999999999999999999)
479
99999999999999999999
480
select ceiling(9.9999999999999999999);
481
ceiling(9.9999999999999999999)
482
10
483
select ceiling(-9.9999999999999999999);
484
ceiling(-9.9999999999999999999)
485
-9
486
select floor(999999999999999999);
487
floor(999999999999999999)
488
999999999999999999
489
select floor(9999999999999999999999);
490
floor(9999999999999999999999)
491
9999999999999999999999
492
select floor(9.999999999999999999999);
493
floor(9.999999999999999999999)
494
9
495
select floor(-9.999999999999999999999);
496
floor(-9.999999999999999999999)
497
-10
498
select floor(-999999999999999999999.999);
499
floor(-999999999999999999999.999)
500
-1000000000000000000000
501
select ceiling(999999999999999999999.999);
502
ceiling(999999999999999999999.999)
503
1000000000000000000000
504
select 99999999999999999999999999999999999999 mod 3;
505
99999999999999999999999999999999999999 mod 3
506
0
507
select round(99999999999999999.999);
508
round(99999999999999999.999)
509
100000000000000000
510
select round(-99999999999999999.999);
511
round(-99999999999999999.999)
512
-100000000000000000
513
select round(99999999999999999.999,3);
514
round(99999999999999999.999,3)
515
99999999999999999.999
516
select round(-99999999999999999.999,3);
517
round(-99999999999999999.999,3)
518
-99999999999999999.999
519
select truncate(99999999999999999999999999999999999999,31);
520
truncate(99999999999999999999999999999999999999,31)
521
99999999999999999999999999999999999999.000000000000000000000000000000
522
select truncate(99.999999999999999999999999999999999999,31);
523
truncate(99.999999999999999999999999999999999999,31)
524
99.999999999999999999999999999999
525
select truncate(99999999999999999999999999999999999999,-31);
526
truncate(99999999999999999999999999999999999999,-31)
527
99999990000000000000000000000000000000
528
create table t1 as select 0.5;
529
show create table t1;
530
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
531
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
532
  `0.5` DECIMAL(2,1) NOT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
533
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
534
drop table t1;
535
select round(1.5),round(2.5);
536
round(1.5)	round(2.5)
537
2	3
538
select 0.07 * 0.07;
539
0.07 * 0.07
540
0.0049
541
select 1E-500 = 0;
542
1E-500 = 0
543
1
544
select 1 / 1E-500;
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
545
ERROR 22012: Division by 0
1 by brian
clean slate
546
select 1 / 0;
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
547
ERROR 22012: Division by 0
1 by brian
clean slate
548
CREATE TABLE Sow6_2f (col1 NUMERIC(4,2));
549
INSERT INTO Sow6_2f VALUES (10.55);
550
INSERT INTO Sow6_2f VALUES (10.5555);
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
551
ERROR 01000: Data truncated for column 'col1' at row 1
1 by brian
clean slate
552
INSERT INTO Sow6_2f VALUES (-10.55);
553
INSERT INTO Sow6_2f VALUES (-10.5555);
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
554
ERROR 01000: Data truncated for column 'col1' at row 1
1 by brian
clean slate
555
INSERT INTO Sow6_2f VALUES (11);
556
INSERT INTO Sow6_2f VALUES (101.55);
557
ERROR 22003: Out of range value for column 'col1' at row 1
558
SELECT MOD(col1,0) FROM Sow6_2f;
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
559
ERROR 22012: Division by 0
1 by brian
clean slate
560
INSERT INTO Sow6_2f VALUES ('a59b');
561
ERROR HY000: Incorrect decimal value: 'a59b' for column 'col1' at row 1
562
drop table Sow6_2f;
563
select 10.3330000000000/12.34500000;
564
10.3330000000000/12.34500000
565
0.83701903604698258
566
select 0/0;
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
567
ERROR 22012: Division by 0
1 by brian
clean slate
568
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 as x;
569
x
570
99999999999999999999999999999999999999999999999999999999999999999
571
Warnings:
572
Error	1292	Truncated incorrect DECIMAL value: ''
573
select 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 + 1 as x;
574
x
575
100000000000000000000000000000000000000000000000000000000000000000
576
Warnings:
577
Error	1292	Truncated incorrect DECIMAL value: ''
578
select 0.190287977636363637 + 0.040372670 * 0 -  0;
579
0.190287977636363637 + 0.040372670 * 0 -  0
580
0.190287977636363637
581
select -0.123 * 0;
582
-0.123 * 0
583
0.000
584
CREATE TABLE t1 (f1 DECIMAL (12,9), f2 DECIMAL(2,2));
585
INSERT INTO t1 VALUES (10.5, 0);
586
UPDATE t1 SET f1 = 4.5;
587
SELECT * FROM t1;
588
f1	f2
589
4.500000000	0.00
590
DROP TABLE t1;
591
CREATE TABLE t1 (f1 DECIMAL (64,20), f2 DECIMAL(2,2));
592
INSERT INTO t1 VALUES (9999999999999999999999999999999999, 0);
593
SELECT * FROM t1;
594
f1	f2
595
9999999999999999999999999999999999.00000000000000000000	0.00
596
DROP TABLE t1;
597
select abs(10/0);
1812.4.2 by Brian Aker
Fix issue with divide by zero not being an error.
598
ERROR 22012: Division by 0
1 by brian
clean slate
599
select abs(NULL);
600
abs(NULL)
601
NULL
413.2.2 by Brian Aker
Removed UNSIGNED from parser.
602
create table t1( d1 decimal(18), d2 decimal(20), d3 decimal (22));
1 by brian
clean slate
603
insert into t1 values(1,-1,-1);
604
drop table t1;
605
create table t1 (col1 decimal(5,2), col2 numeric(5,2));
606
insert into t1 values (999.999,999.999);
607
ERROR 22003: Out of range value for column 'col1' at row 1
608
insert into t1 values (-999.999,-999.999);
609
ERROR 22003: Out of range value for column 'col1' at row 1
610
select * from t1;
611
col1	col2
612
drop table t1;
613
set @sav_dpi= @@div_precision_increment;
614
set @@div_precision_increment=15;
615
create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25));
616
insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345);
617
select col2/9999999999 from t1 where col1=1;
618
col2/9999999999
619
0.000000000001234567890246913578
620
select 9999999999/col2 from t1 where col1=1;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
621
9999999999/col2 
1 by brian
clean slate
622
810000007209.000065537105051
623
select 77777777/7777777;
624
77777777/7777777
625
10.000000900000090
626
drop table t1;
627
set div_precision_increment= @sav_dpi;
628
create table t1 (a decimal(4,2));
629
insert into t1 values (0.00);
630
select * from t1 where a > -0.00;
631
a
632
select * from t1 where a = -0.00;
633
a
634
0.00
635
drop table t1;
636
create table t1 (col1 bigint default -9223372036854775808);
637
insert into t1 values (default);
638
select * from t1;
639
col1
640
-9223372036854775808
641
drop table t1;
642
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
643
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
644
0.000000000100000
645
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
646
c1	c2	c3
1108.5.2 by rm
fix test results so they expect valid precision, rather than more than can be relied upon
647
9.5468126085974	9.547	9.547
1 by brian
clean slate
648
select convert(ln(14000),decimal(2,3)) c1;
649
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
650
select cast(ln(14000) as decimal(2,3)) c1;
651
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
652
create table t1 (sl decimal(70,30));
653
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
654
create table t1 (sl decimal(32,31));
655
ERROR 42000: Too big scale 31 specified for column 'sl'. Maximum is 30.
656
create table t1 (sl decimal(0,38));
657
ERROR 42000: Too big scale 38 specified for column 'sl'. Maximum is 30.
658
create table t1 (sl decimal(0,30));
659
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'sl').
660
create table t1 (sl decimal(5, 5));
661
show create table t1;
662
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
663
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
664
  `sl` DECIMAL(5,5) DEFAULT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
665
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
666
drop table t1;
667
create table t1 (sl decimal(65, 30));
668
show create table t1;
669
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
670
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
671
  `sl` DECIMAL(65,30) DEFAULT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
672
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
673
drop table t1;
674
create table t1 (
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
675
f0 decimal (30,30) not null DEFAULT 0,
676
f1 decimal (0,0) not null default 0);
1 by brian
clean slate
677
show create table t1;
678
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
679
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
680
  `f0` DECIMAL(30,30) NOT NULL DEFAULT '0',
681
  `f1` DECIMAL(10,0) NOT NULL DEFAULT '0'
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
682
) ENGINE=X COLLATE = utf8_general_ci
1 by brian
clean slate
683
drop table t1;
684
create table t (d decimal(0,10));
685
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'd').
686
CREATE TABLE t1 (
687
my_float   FLOAT,
688
my_double  DOUBLE,
689
my_varchar VARCHAR(50),
690
my_decimal DECIMAL(65,30)
691
);
692
SHOW CREATE TABLE t1;
693
Table	Create Table
352.2.1 by Harrison Fisk
Fix for bugs 259843 and 256482
694
t1	CREATE TABLE `t1` (
1743.5.2 by LinuxJedi
Alter many test cases for the new SHOW CREATE TABLE output
695
  `my_float` DOUBLE DEFAULT NULL,
696
  `my_double` DOUBLE DEFAULT NULL,
697
  `my_varchar` VARCHAR(50) COLLATE utf8_general_ci DEFAULT NULL,
698
  `my_decimal` DECIMAL(65,30) DEFAULT NULL
1638.10.86 by Stewart Smith
fix some more tests for explicit COLLATE in CREATE TABLE, including transaction_log whitespace changes
699
) ENGINE=X COLLATE = utf8_general_ci
910.4.13 by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker.
700
begin;
1 by brian
clean slate
701
INSERT INTO t1 SET my_float = 1.175494345e-32,
702
my_double = 1.175494345e-32,
703
my_varchar = '1.175494345e-32';
704
INSERT INTO t1 SET my_float = 1.175494345e-31,
705
my_double = 1.175494345e-31,
706
my_varchar = '1.175494345e-31';
707
INSERT INTO t1 SET my_float = 1.175494345e-30,
708
my_double = 1.175494345e-30,
709
my_varchar = '1.175494345e-30';
710
INSERT INTO t1 SET my_float = 1.175494345e-29,
711
my_double = 1.175494345e-29,
712
my_varchar = '1.175494345e-29';
713
INSERT INTO t1 SET my_float = 1.175494345e-28,
714
my_double = 1.175494345e-28,
715
my_varchar = '1.175494345e-28';
716
INSERT INTO t1 SET my_float = 1.175494345e-27,
717
my_double = 1.175494345e-27,
718
my_varchar = '1.175494345e-27';
719
INSERT INTO t1 SET my_float = 1.175494345e-26,
720
my_double = 1.175494345e-26,
721
my_varchar = '1.175494345e-26';
722
INSERT INTO t1 SET my_float = 1.175494345e-25,
723
my_double = 1.175494345e-25,
724
my_varchar = '1.175494345e-25';
725
INSERT INTO t1 SET my_float = 1.175494345e-24,
726
my_double = 1.175494345e-24,
727
my_varchar = '1.175494345e-24';
728
INSERT INTO t1 SET my_float = 1.175494345e-23,
729
my_double = 1.175494345e-23,
730
my_varchar = '1.175494345e-23';
731
INSERT INTO t1 SET my_float = 1.175494345e-22,
732
my_double = 1.175494345e-22,
733
my_varchar = '1.175494345e-22';
734
INSERT INTO t1 SET my_float = 1.175494345e-21,
735
my_double = 1.175494345e-21,
736
my_varchar = '1.175494345e-21';
737
INSERT INTO t1 SET my_float = 1.175494345e-20,
738
my_double = 1.175494345e-20,
739
my_varchar = '1.175494345e-20';
740
INSERT INTO t1 SET my_float = 1.175494345e-19,
741
my_double = 1.175494345e-19,
742
my_varchar = '1.175494345e-19';
743
INSERT INTO t1 SET my_float = 1.175494345e-18,
744
my_double = 1.175494345e-18,
745
my_varchar = '1.175494345e-18';
746
INSERT INTO t1 SET my_float = 1.175494345e-17,
747
my_double = 1.175494345e-17,
748
my_varchar = '1.175494345e-17';
749
INSERT INTO t1 SET my_float = 1.175494345e-16,
750
my_double = 1.175494345e-16,
751
my_varchar = '1.175494345e-16';
752
INSERT INTO t1 SET my_float = 1.175494345e-15,
753
my_double = 1.175494345e-15,
754
my_varchar = '1.175494345e-15';
755
INSERT INTO t1 SET my_float = 1.175494345e-14,
756
my_double = 1.175494345e-14,
757
my_varchar = '1.175494345e-14';
758
INSERT INTO t1 SET my_float = 1.175494345e-13,
759
my_double = 1.175494345e-13,
760
my_varchar = '1.175494345e-13';
761
INSERT INTO t1 SET my_float = 1.175494345e-12,
762
my_double = 1.175494345e-12,
763
my_varchar = '1.175494345e-12';
764
INSERT INTO t1 SET my_float = 1.175494345e-11,
765
my_double = 1.175494345e-11,
766
my_varchar = '1.175494345e-11';
767
INSERT INTO t1 SET my_float = 1.175494345e-10,
768
my_double = 1.175494345e-10,
769
my_varchar = '1.175494345e-10';
770
INSERT INTO t1 SET my_float = 1.175494345e-9,
771
my_double = 1.175494345e-9,
772
my_varchar = '1.175494345e-9';
773
INSERT INTO t1 SET my_float = 1.175494345e-8,
774
my_double = 1.175494345e-8,
775
my_varchar = '1.175494345e-8';
776
INSERT INTO t1 SET my_float = 1.175494345e-7,
777
my_double = 1.175494345e-7,
778
my_varchar = '1.175494345e-7';
779
INSERT INTO t1 SET my_float = 1.175494345e-6,
780
my_double = 1.175494345e-6,
781
my_varchar = '1.175494345e-6';
782
INSERT INTO t1 SET my_float = 1.175494345e-5,
783
my_double = 1.175494345e-5,
784
my_varchar = '1.175494345e-5';
785
INSERT INTO t1 SET my_float = 1.175494345e-4,
786
my_double = 1.175494345e-4,
787
my_varchar = '1.175494345e-4';
788
INSERT INTO t1 SET my_float = 1.175494345e-3,
789
my_double = 1.175494345e-3,
790
my_varchar = '1.175494345e-3';
791
INSERT INTO t1 SET my_float = 1.175494345e-2,
792
my_double = 1.175494345e-2,
793
my_varchar = '1.175494345e-2';
794
INSERT INTO t1 SET my_float = 1.175494345e-1,
795
my_double = 1.175494345e-1,
796
my_varchar = '1.175494345e-1';
910.4.13 by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker.
797
commit;
1 by brian
clean slate
798
SELECT my_float, my_double, my_varchar FROM t1;
799
my_float	my_double	my_varchar
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
800
1.175494345e-32	1.175494345e-32	1.175494345e-32
801
1.175494345e-31	1.175494345e-31	1.175494345e-31
802
1.175494345e-30	1.175494345e-30	1.175494345e-30
803
1.175494345e-29	1.175494345e-29	1.175494345e-29
804
1.175494345e-28	1.175494345e-28	1.175494345e-28
805
1.175494345e-27	1.175494345e-27	1.175494345e-27
806
1.175494345e-26	1.175494345e-26	1.175494345e-26
807
1.175494345e-25	1.175494345e-25	1.175494345e-25
808
1.175494345e-24	1.175494345e-24	1.175494345e-24
809
1.175494345e-23	1.175494345e-23	1.175494345e-23
810
1.175494345e-22	1.175494345e-22	1.175494345e-22
811
1.175494345e-21	1.175494345e-21	1.175494345e-21
812
1.175494345e-20	1.175494345e-20	1.175494345e-20
813
1.175494345e-19	1.175494345e-19	1.175494345e-19
814
1.175494345e-18	1.175494345e-18	1.175494345e-18
815
1.175494345e-17	1.175494345e-17	1.175494345e-17
816
1.175494345e-16	1.175494345e-16	1.175494345e-16
817
0.000000000000001175494345	0.000000000000001175494345	1.175494345e-15
818
0.00000000000001175494345	0.00000000000001175494345	1.175494345e-14
819
0.0000000000001175494345	0.0000000000001175494345	1.175494345e-13
820
0.000000000001175494345	0.000000000001175494345	1.175494345e-12
821
0.00000000001175494345	0.00000000001175494345	1.175494345e-11
822
0.0000000001175494345	0.0000000001175494345	1.175494345e-10
823
0.000000001175494345	0.000000001175494345	1.175494345e-9
824
0.00000001175494345	0.00000001175494345	1.175494345e-8
825
0.0000001175494345	0.0000001175494345	1.175494345e-7
826
0.000001175494345	0.000001175494345	1.175494345e-6
827
0.00001175494345	0.00001175494345	1.175494345e-5
828
0.0001175494345	0.0001175494345	1.175494345e-4
829
0.001175494345	0.001175494345	1.175494345e-3
830
0.01175494345	0.01175494345	1.175494345e-2
831
0.1175494345	0.1175494345	1.175494345e-1
1 by brian
clean slate
832
SELECT CAST(my_float   AS DECIMAL(65,30)), my_float FROM t1;
833
CAST(my_float   AS DECIMAL(65,30))	my_float
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
834
0.000000000000000000000000000000	1.175494345e-32
835
0.000000000000000000000000000000	1.175494345e-31
836
0.000000000000000000000000000001	1.175494345e-30
837
0.000000000000000000000000000012	1.175494345e-29
838
0.000000000000000000000000000118	1.175494345e-28
839
0.000000000000000000000000001175	1.175494345e-27
840
0.000000000000000000000000011755	1.175494345e-26
841
0.000000000000000000000000117549	1.175494345e-25
842
0.000000000000000000000001175494	1.175494345e-24
843
0.000000000000000000000011754943	1.175494345e-23
844
0.000000000000000000000117549435	1.175494345e-22
845
0.000000000000000000001175494345	1.175494345e-21
846
0.000000000000000000011754943450	1.175494345e-20
847
0.000000000000000000117549434500	1.175494345e-19
848
0.000000000000000001175494345000	1.175494345e-18
849
0.000000000000000011754943450000	1.175494345e-17
850
0.000000000000000117549434500000	1.175494345e-16
851
0.000000000000001175494345000000	0.000000000000001175494345
852
0.000000000000011754943450000000	0.00000000000001175494345
853
0.000000000000117549434500000000	0.0000000000001175494345
854
0.000000000001175494345000000000	0.000000000001175494345
855
0.000000000011754943450000000000	0.00000000001175494345
856
0.000000000117549434500000000000	0.0000000001175494345
857
0.000000001175494345000000000000	0.000000001175494345
858
0.000000011754943450000000000000	0.00000001175494345
859
0.000000117549434500000000000000	0.0000001175494345
860
0.000001175494345000000000000000	0.000001175494345
861
0.000011754943450000000000000000	0.00001175494345
862
0.000117549434500000000000000000	0.0001175494345
863
0.001175494345000000000000000000	0.001175494345
864
0.011754943450000000000000000000	0.01175494345
865
0.117549434500000000000000000000	0.1175494345
1 by brian
clean slate
866
SELECT CAST(my_double  AS DECIMAL(65,30)), my_double FROM t1;
867
CAST(my_double  AS DECIMAL(65,30))	my_double
868
0.000000000000000000000000000000	1.175494345e-32
869
0.000000000000000000000000000000	1.175494345e-31
870
0.000000000000000000000000000001	1.175494345e-30
871
0.000000000000000000000000000012	1.175494345e-29
872
0.000000000000000000000000000118	1.175494345e-28
873
0.000000000000000000000000001175	1.175494345e-27
874
0.000000000000000000000000011755	1.175494345e-26
875
0.000000000000000000000000117549	1.175494345e-25
876
0.000000000000000000000001175494	1.175494345e-24
877
0.000000000000000000000011754943	1.175494345e-23
878
0.000000000000000000000117549435	1.175494345e-22
879
0.000000000000000000001175494345	1.175494345e-21
880
0.000000000000000000011754943450	1.175494345e-20
881
0.000000000000000000117549434500	1.175494345e-19
882
0.000000000000000001175494345000	1.175494345e-18
883
0.000000000000000011754943450000	1.175494345e-17
884
0.000000000000000117549434500000	1.175494345e-16
885
0.000000000000001175494345000000	0.000000000000001175494345
886
0.000000000000011754943450000000	0.00000000000001175494345
887
0.000000000000117549434500000000	0.0000000000001175494345
888
0.000000000001175494345000000000	0.000000000001175494345
889
0.000000000011754943450000000000	0.00000000001175494345
890
0.000000000117549434500000000000	0.0000000001175494345
891
0.000000001175494345000000000000	0.000000001175494345
892
0.000000011754943450000000000000	0.00000001175494345
893
0.000000117549434500000000000000	0.0000001175494345
894
0.000001175494345000000000000000	0.000001175494345
895
0.000011754943450000000000000000	0.00001175494345
896
0.000117549434500000000000000000	0.0001175494345
897
0.001175494345000000000000000000	0.001175494345
898
0.011754943450000000000000000000	0.01175494345
899
0.117549434500000000000000000000	0.1175494345
900
SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1;
901
CAST(my_varchar AS DECIMAL(65,30))	my_varchar
902
0.000000000000000000000000000000	1.175494345e-32
903
0.000000000000000000000000000000	1.175494345e-31
904
0.000000000000000000000000000001	1.175494345e-30
905
0.000000000000000000000000000012	1.175494345e-29
906
0.000000000000000000000000000118	1.175494345e-28
907
0.000000000000000000000000001175	1.175494345e-27
908
0.000000000000000000000000011755	1.175494345e-26
909
0.000000000000000000000000117549	1.175494345e-25
910
0.000000000000000000000001175494	1.175494345e-24
911
0.000000000000000000000011754943	1.175494345e-23
912
0.000000000000000000000117549435	1.175494345e-22
913
0.000000000000000000001175494345	1.175494345e-21
914
0.000000000000000000011754943450	1.175494345e-20
915
0.000000000000000000117549434500	1.175494345e-19
916
0.000000000000000001175494345000	1.175494345e-18
917
0.000000000000000011754943450000	1.175494345e-17
918
0.000000000000000117549434500000	1.175494345e-16
919
0.000000000000001175494345000000	1.175494345e-15
920
0.000000000000011754943450000000	1.175494345e-14
921
0.000000000000117549434500000000	1.175494345e-13
922
0.000000000001175494345000000000	1.175494345e-12
923
0.000000000011754943450000000000	1.175494345e-11
924
0.000000000117549434500000000000	1.175494345e-10
925
0.000000001175494345000000000000	1.175494345e-9
926
0.000000011754943450000000000000	1.175494345e-8
927
0.000000117549434500000000000000	1.175494345e-7
928
0.000001175494345000000000000000	1.175494345e-6
929
0.000011754943450000000000000000	1.175494345e-5
930
0.000117549434500000000000000000	1.175494345e-4
931
0.001175494345000000000000000000	1.175494345e-3
932
0.011754943450000000000000000000	1.175494345e-2
933
0.117549434500000000000000000000	1.175494345e-1
934
UPDATE t1 SET my_decimal = my_float;
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
935
ERROR 01000: Data truncated for column 'my_decimal' at row 1
1 by brian
clean slate
936
SELECT my_decimal, my_float   FROM t1;
937
my_decimal	my_float
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
938
NULL	1.175494345e-32
939
NULL	1.175494345e-31
940
NULL	1.175494345e-30
941
NULL	1.175494345e-29
942
NULL	1.175494345e-28
943
NULL	1.175494345e-27
944
NULL	1.175494345e-26
945
NULL	1.175494345e-25
946
NULL	1.175494345e-24
947
NULL	1.175494345e-23
948
NULL	1.175494345e-22
949
NULL	1.175494345e-21
950
NULL	1.175494345e-20
951
NULL	1.175494345e-19
952
NULL	1.175494345e-18
953
NULL	1.175494345e-17
954
NULL	1.175494345e-16
955
NULL	0.000000000000001175494345
956
NULL	0.00000000000001175494345
957
NULL	0.0000000000001175494345
958
NULL	0.000000000001175494345
959
NULL	0.00000000001175494345
960
NULL	0.0000000001175494345
961
NULL	0.000000001175494345
962
NULL	0.00000001175494345
963
NULL	0.0000001175494345
964
NULL	0.000001175494345
965
NULL	0.00001175494345
966
NULL	0.0001175494345
967
NULL	0.001175494345
968
NULL	0.01175494345
969
NULL	0.1175494345
1 by brian
clean slate
970
UPDATE t1 SET my_decimal = my_double;
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
971
ERROR 01000: Data truncated for column 'my_decimal' at row 1
1 by brian
clean slate
972
SELECT my_decimal, my_double  FROM t1;
973
my_decimal	my_double
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
974
NULL	1.175494345e-32
975
NULL	1.175494345e-31
976
NULL	1.175494345e-30
977
NULL	1.175494345e-29
978
NULL	1.175494345e-28
979
NULL	1.175494345e-27
980
NULL	1.175494345e-26
981
NULL	1.175494345e-25
982
NULL	1.175494345e-24
983
NULL	1.175494345e-23
984
NULL	1.175494345e-22
985
NULL	1.175494345e-21
986
NULL	1.175494345e-20
987
NULL	1.175494345e-19
988
NULL	1.175494345e-18
989
NULL	1.175494345e-17
990
NULL	1.175494345e-16
991
NULL	0.000000000000001175494345
992
NULL	0.00000000000001175494345
993
NULL	0.0000000000001175494345
994
NULL	0.000000000001175494345
995
NULL	0.00000000001175494345
996
NULL	0.0000000001175494345
997
NULL	0.000000001175494345
998
NULL	0.00000001175494345
999
NULL	0.0000001175494345
1000
NULL	0.000001175494345
1001
NULL	0.00001175494345
1002
NULL	0.0001175494345
1003
NULL	0.001175494345
1004
NULL	0.01175494345
1005
NULL	0.1175494345
1 by brian
clean slate
1006
UPDATE t1 SET my_decimal = my_varchar;
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
1007
ERROR 01000: Data truncated for column 'my_decimal' at row 1
1 by brian
clean slate
1008
SELECT my_decimal, my_varchar FROM t1;
1009
my_decimal	my_varchar
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
1010
NULL	1.175494345e-32
1011
NULL	1.175494345e-31
1012
NULL	1.175494345e-30
1013
NULL	1.175494345e-29
1014
NULL	1.175494345e-28
1015
NULL	1.175494345e-27
1016
NULL	1.175494345e-26
1017
NULL	1.175494345e-25
1018
NULL	1.175494345e-24
1019
NULL	1.175494345e-23
1020
NULL	1.175494345e-22
1021
NULL	1.175494345e-21
1022
NULL	1.175494345e-20
1023
NULL	1.175494345e-19
1024
NULL	1.175494345e-18
1025
NULL	1.175494345e-17
1026
NULL	1.175494345e-16
1027
NULL	1.175494345e-15
1028
NULL	1.175494345e-14
1029
NULL	1.175494345e-13
1030
NULL	1.175494345e-12
1031
NULL	1.175494345e-11
1032
NULL	1.175494345e-10
1033
NULL	1.175494345e-9
1034
NULL	1.175494345e-8
1035
NULL	1.175494345e-7
1036
NULL	1.175494345e-6
1037
NULL	1.175494345e-5
1038
NULL	1.175494345e-4
1039
NULL	1.175494345e-3
1040
NULL	1.175494345e-2
1041
NULL	1.175494345e-1
1 by brian
clean slate
1042
DROP TABLE t1;
1043
create table t1 (c1 decimal(64));
1044
insert into t1 values(
1045
89000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
1046
ERROR 22003: Out of range value for column 'c1' at row 1
1 by brian
clean slate
1047
insert into t1 values(
1048
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 *
1049
99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
1050
ERROR 22007: Truncated incorrect DECIMAL value: ''
1 by brian
clean slate
1051
insert into t1 values(1e100);
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
1052
ERROR 22003: Out of range value for column 'c1' at row 1
1 by brian
clean slate
1053
select * from t1;
1054
c1
1055
drop table t1;
1056
create table t1(a decimal(7,2));
1057
insert into t1 values(123.12);
1058
select * from t1;
1059
a
1060
123.12
1061
alter table t1 modify a decimal(10,2);
1062
select * from t1;
1063
a
1064
123.12
1065
drop table t1;
1066
create table t1 (i int, j int);
1067
insert into t1 values (1,1), (1,2), (2,3), (2,4);
1068
select i, count(distinct j) from t1 group by i;
1069
i	count(distinct j)
1070
1	2
1071
2	2
1072
select i+0.0 as i2, count(distinct j) from t1 group by i2;
1073
i2	count(distinct j)
1074
1.0	2
1075
2.0	2
1076
drop table t1;
1077
create table t1(f1 decimal(20,6));
1078
insert into t1 values (CAST('10:11:12' AS date) + interval 14 microsecond);
1079
select * from t1;
1080
f1
1081
20101112000000.000014
1082
drop table t1;
1083
create table t1(a decimal(18));
1084
insert into t1 values(123456789012345678);
1085
alter table t1 modify column a decimal(19);
1086
select * from t1;
1087
a
1088
123456789012345678
1089
drop table t1;
1090
select cast(11.1234 as DECIMAL(3,2));
1091
cast(11.1234 as DECIMAL(3,2))
1092
9.99
1093
Warnings:
1094
Error	1264	Out of range value for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
1095
select * from (select cast(11.1234 as DECIMAL(3,2))) t;
1096
cast(11.1234 as DECIMAL(3,2))
1097
9.99
1098
Warnings:
1099
Error	1264	Out of range value for column 'cast(11.1234 as DECIMAL(3,2))' at row 1
1100
select cast(a as DECIMAL(3,2))
1101
from (select 11.1233 as a
1102
UNION select 11.1234
1103
UNION select 12.1234
1104
) t;
1105
cast(a as DECIMAL(3,2))
1106
9.99
1107
9.99
1108
9.99
1109
Warnings:
1110
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1111
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1112
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1113
select cast(a as DECIMAL(3,2)), count(*)
1114
from (select 11.1233 as a
1115
UNION select 11.1234
1116
UNION select 12.1234
1117
) t group by 1;
1118
cast(a as DECIMAL(3,2))	count(*)
1119
9.99	3
1120
Warnings:
1121
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1122
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1123
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1124
Error	1264	Out of range value for column 'cast(a as DECIMAL(3,2))' at row 1
1125
create table t1 (s varchar(100));
1126
insert into t1 values (0.00000000010000000000000000364321973154977415791655470655996396089904010295867919921875);
1127
drop table t1;
1128
SELECT 1.000000000000 * 99.999999999998 / 100 a,1.000000000000 * (99.999999999998 / 100) b;
1129
a	b
1130
0.9999999999999800000000000000	0.9999999999999800000000000000
1131
SELECT CAST(1 AS decimal(65,10));
1132
CAST(1 AS decimal(65,10))
1133
1.0000000000
1134
SELECT CAST(1 AS decimal(66,10));
1135
ERROR 42000: Too big precision 66 specified for column '1'. Maximum is 65.
1136
SELECT CAST(1 AS decimal(65,30));
1137
CAST(1 AS decimal(65,30))
1138
1.000000000000000000000000000000
1139
SELECT CAST(1 AS decimal(65,31));
1140
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
1141
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
1142
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
1143
SELECT a+CAST(1 AS decimal(65,30)) AS aa, SUM(b) FROM t1 GROUP BY aa;
1144
aa	SUM(b)
1145
2.000000000000000000000000000000	10
1146
3.000000000000000000000000000000	10
1147
4.000000000000000000000000000000	30
1148
SELECT a+CAST(1 AS decimal(65,31)) AS aa, SUM(b) FROM t1 GROUP BY aa;
1149
ERROR 42000: Too big scale 31 specified for column '1'. Maximum is 30.
1150
DROP TABLE t1;
1151
CREATE TABLE t1 (a int DEFAULT NULL, b int DEFAULT NULL);
1152
INSERT INTO t1 VALUES (3,30), (1,10), (2,10);
1153
SET @a= CAST(1 AS decimal);
1154
SELECT 1 FROM t1 GROUP BY @b := @a, @b;
1155
1
1156
1
1157
1
1158
DROP TABLE t1;
1159
CREATE TABLE t1 SELECT 0.123456789012345678901234567890123456 AS f1;
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
1160
ERROR 01000: Data truncated for column 'f1' at row 1
1 by brian
clean slate
1161
CREATE TABLE t1 SELECT 123451234512345123451234512345123451234512345.678906789067890678906789067890678906789067890 AS f1;
215 by Brian Aker
Fixed newdecimal test and added it to standard tests.
1162
ERROR 22003: Out of range value for column 'f1' at row 1
1 by brian
clean slate
1163
End of 5.0 tests
1164
select cast(143.481 as decimal(4,1));
1165
cast(143.481 as decimal(4,1))
1166
143.5
1167
select cast(143.481 as decimal(4,0));
1168
cast(143.481 as decimal(4,0))
1169
143
1170
select cast(143.481 as decimal(2,1));
1171
cast(143.481 as decimal(2,1))
1172
9.9
1173
Warnings:
1174
Error	1264	Out of range value for column 'cast(143.481 as decimal(2,1))' at row 1
1175
select cast(-3.4 as decimal(2,1));
1176
cast(-3.4 as decimal(2,1))
1177
-3.4
1178
select cast(99.6 as decimal(2,0));
1179
cast(99.6 as decimal(2,0))
1180
99
1181
Warnings:
1182
Error	1264	Out of range value for column 'cast(99.6 as decimal(2,0))' at row 1
1183
select cast(-13.4 as decimal(2,1));
1184
cast(-13.4 as decimal(2,1))
1185
-9.9
1186
Warnings:
1187
Error	1264	Out of range value for column 'cast(-13.4 as decimal(2,1))' at row 1
1188
select cast(98.6 as decimal(2,0));
1189
cast(98.6 as decimal(2,0))
1190
99
970.2.1 by Padraig O'Sullivan
Fix for bug337038. Now we error on data truncation with decimal values but
1191
create table t1 (f1 decimal not null default 17.49);
1192
ERROR 42000: Invalid default value for 'f1'