1
# Test routine for the DECIMAL Type in BlitzDB
4
drop table if exists t1, t2;
7
# Basic operations on an indexless table
8
create table t1 (a decimal, b decimal) engine = blitzdb;
9
insert into t1 values (1,0);
10
insert into t1 values (1,1);
11
insert into t1 values (1,2);
12
insert into t1 values (1,4);
13
insert into t1 values (1,8);
15
select * from t1 where b <= 2;
18
# Test the max number of possible digits
19
create table t2 (a decimal(65,0)) engine = blitzdb;
20
insert into t2 select repeat(1, 65);
22
insert into t2 select repeat(1, 66);
26
create table t2 (a decimal(65,8)) engine = blitzdb;
27
insert into t2 select repeat(1, 57);
29
insert into t2 select repeat(1, 58);
33
--error 1264 # Out of Range
34
insert into t2 values (
35
-1111111111111111111111111111111111111111111111111111111111
38
insert into t2 values (
39
1111111111111111111111111111111111111111111111111.11111111
42
--error 1265 # Truncated
43
insert into t2 values (
44
111111111111111111111111111111111111111111111111.111111111
50
# Test case for a bug reported by Stewart Smith
52
id int NOT NULL auto_increment,
53
datatype_id int DEFAULT '0' NOT NULL,
54
minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
55
maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL,
56
valuename varchar(20),
60
index datatype_id (datatype_id)
63
insert into t1 values ('1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960');
64
insert into t1 values ('2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255');
65
insert into t1 values ('3', '1', '2.0000000000', '49.0000000000', '', '0', '16777215');
66
insert into t1 values ('60', '11', '0.0000000000', '0.0000000000', 'Rikkis', '16777215', '16711680');
67
insert into t1 values ('4', '12', '1.0000000000', '1.0000000000', 'nork sadu', '65280', '14474460');
68
insert into t1 values ('5', '12', '2.0000000000', '2.0000000000', 'keskmine sadu', '255', '14474460');
69
insert into t1 values ('6', '12', '3.0000000000', '3.0000000000', 'tugev sadu', '127', '14474460');
70
insert into t1 values ('43', '39', '6.0000000000', '6.0000000000', 'lobjakas', '13107327', '16763080');
71
insert into t1 values ('40', '39', '2.0000000000', '2.0000000000', 'vihm', '8355839', '16777215');
72
insert into t1 values ('53', '1', '-35.0000000000', '-5.0000000000', '', '0', '16777215');
73
insert into t1 values ('12', '21', '21.0000000000', '21.0000000000', 'Kuiv', '13158600', '16777215');
74
insert into t1 values ('14', '21', '22.0000000000', '22.0000000000', 'Niiske', '9869055', '16777215');
75
insert into t1 values ('16', '21', '31.0000000000', '31.0000000000', 'Kuiv', '13158600', '16777215');
76
insert into t1 values ('17', '21', '12.0000000000', '12.0000000000', 'Niiske', '9869055', '16777215');
77
insert into t1 values ('18', '21', '32.0000000000', '32.0000000000', 'Niiske', '9869055', '16777215');
78
insert into t1 values ('21', '21', '11.0000000000', '11.0000000000', 'Kuiv', '13158600', '16777215');
79
insert into t1 values ('22', '33', '21.0000000000', '21.0000000000', 'Pilves, kuiv', '8355711', '12632256');
80
insert into t1 values ('24', '33', '22.0000000000', '22.0000000000', 'Pilves, niiske', '8355711', '12632319');
81
insert into t1 values ('26', '33', '31.0000000000', '31.0000000000', 'Selge, kuiv', '16777215', '12632256');
82
insert into t1 values ('27', '33', '12.0000000000', '12.0000000000', 'Sajab, niiske', '0', '12632319');
83
insert into t1 values ('28', '33', '32.0000000000', '32.0000000000', 'Selge, niiske', '16777215', '12632319');
84
insert into t1 values ('31', '33', '11.0000000000', '11.0000000000', 'Sajab, kuiv', '0', '12632256');
85
insert into t1 values ('32', '11', '1.0000000000', '1.0000000000', 'Korras', '16777215', '49152');
86
insert into t1 values ('34', '21', '134.0000000000', '134.0000000000', 'Hoiatus, M+S!', '255', '13158600');
87
insert into t1 values ('39', '39', '1.0000000000', '1.0000000000', 'ei saja', '11206570', '16777215');
88
insert into t1 values ('44', '39', '4.0000000000', '5.0000000000', 'lumi', '16711680', '16763080');
89
insert into t1 values ('45', '12', '0.0000000000', '0.0000000000', '', '16777215', '14474460');
91
select * from t1 order by id;
92
select * from t1 where minvalue <= 1 and maxvalue >= -1 order by id;
95
# Exponent overflow bug
96
create table t1 (a decimal(10,0)) engine = blitzdb;
97
--error 1366 incorrect decimal value
98
insert into t1 values ("1e4294967295");
101
--error 1366 incorrect decimal value
102
insert into t1 values("1e4294967297");