~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/embedded_innodb/test-suite-dir/embedded_innodb/tests/t/type_float.test

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Description
 
2
# -----------
 
3
# Numeric floating point.
 
4
 
 
5
--disable_warnings
 
6
drop table if exists t1,t2;
 
7
--enable_warnings
 
8
 
 
9
SELECT 10,10.0,10.,.1e+2,100.0e-1;
 
10
SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000;
 
11
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
 
12
SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01;
 
13
SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0;
 
14
SELECT 2147483647E+02,21474836.47E+06;
 
15
 
 
16
create table t1 (f1 float primary key,f2 float);
 
17
# We mask out Privileges column because it differs for embedded server
 
18
--replace_column 8 #
 
19
show columns from t1;
 
20
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
 
21
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
 
22
--sorted_result
 
23
select * from t1;
 
24
drop table t1;
 
25
 
 
26
create table t1 (datum double primary key);
 
27
insert into t1 values (0.5),(1.0),(1.5),(2.0),(2.5);
 
28
select * from t1;
 
29
select * from t1 where datum < 1.5;
 
30
select * from t1 where datum > 1.5;
 
31
select * from t1 where datum = 1.5;
 
32
drop table t1;
 
33
 
 
34
#
 
35
# BUG#3612, BUG#4393, BUG#4356, BUG#4394
 
36
#
 
37
 
 
38
create table t1 (c1 double primary key, c2 varchar(20));
 
39
insert t1 values (121,"16");
 
40
select c1 + c1 * (c2 / 100) as col from t1;
 
41
create temporary table t2 engine=myisam as select c1 + c1 * (c2 / 100) as col1, round(c1, 5) as col2, round(c1, 35) as col3, sqrt(c1*1e-15) col4 from t1;
 
42
# Floats are a bit different in PS
 
43
--disable_ps_protocol
 
44
select * from t2;
 
45
--enable_ps_protocol
 
46
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
47
show create table t2;
 
48
drop table t1,t2;
 
49
 
 
50
# Bug #1022: When a table contains a 'float' field, 
 
51
# and one of the functions MAX, MIN, or AVG is used on that field,
 
52
# the system crashes.
 
53
 
 
54
create table t1 (a float primary key);
 
55
insert into t1 values (1);
 
56
select max(a),min(a),avg(a) from t1;
 
57
drop table t1;
 
58
 
 
59
#
 
60
# float in a char(1) field
 
61
#
 
62
create table t1 (c20 char primary key);
 
63
--error ER_DATA_TOO_LONG
 
64
insert into t1 values (5000.0);
 
65
--error ER_DATA_TOO_LONG
 
66
insert into t1 values (0.5e4);
 
67
drop table t1;
 
68
 
 
69
# Don't allow 'double' to be set to a negative value (Bug #7700)
 
70
create table t1 (d1 double primary key, d2 double);
 
71
insert into t1 set d1 = -1.0;
 
72
update t1 set d2 = d1;
 
73
select * from t1;
 
74
drop table t1;
 
75
 
 
76
# Ensure that maximum values as the result of number of decimals
 
77
# being specified in table schema are enforced (Bug #7361)
 
78
create table t1 (f float(4,3) primary key);
 
79
--error ER_WARN_DATA_OUT_OF_RANGE
 
80
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
 
81
select * from t1;
 
82
drop table if exists t1;
 
83
create table t1 (f double(4,3) primary key);
 
84
--error ER_WARN_DATA_OUT_OF_RANGE
 
85
insert into t1 values (-11.0),(-11),("-11"),(11.0),(11),("11");
 
86
select * from t1;
 
87
drop table if exists t1;
 
88
 
 
89
# Check conversion of floats to character field (Bug #7774)
 
90
create table t1 (c char(20) primary key);
 
91
insert into t1 values (5e-28);
 
92
select * from t1;
 
93
drop table t1;
 
94
create table t1 (c char(6) primary key);
 
95
insert into t1 values (2e5),(2e6),(2e-4),(2e-5);
 
96
select * from t1;
 
97
drop table t1;
 
98
 
 
99
#
 
100
# Test of comparison of integer with float-in-range (Bug #7840)
 
101
# This is needed because some ODBC applications (like Foxpro) uses
 
102
# floats for everything.
 
103
#
 
104
 
 
105
CREATE TEMPORARY TABLE t1 (
 
106
  reckey int NOT NULL,
 
107
  recdesc varchar(50) NOT NULL,
 
108
  PRIMARY KEY  (reckey)
 
109
) ENGINE=MyISAM;
 
110
 
 
111
INSERT INTO t1 VALUES (108, 'Has 108 as key');
 
112
INSERT INTO t1 VALUES (109, 'Has 109 as key');
 
113
select * from t1 where reckey=108;
 
114
select * from t1 where reckey=1.08E2;
 
115
select * from t1 where reckey=109;
 
116
select * from t1 where reckey=1.09E2;
 
117
drop table t1;
 
118
 
 
119
#
 
120
# Bug #13372 (decimal union)
 
121
#
 
122
create table t1 (d double primary key);
 
123
create table t2 (d double primary key);
 
124
insert into t1 values ("100000000.0");
 
125
insert into t2 values ("1.23456780");
 
126
create table t3 (d double primary key) as select t2.d from t2 union select t1.d from t1;
 
127
select * from t3;
 
128
--replace_regex /ENGINE=[a-zA-Z]+/ENGINE=DEFAULT/
 
129
show create table t3;
 
130
drop table t1, t2, t3;
 
131
 
 
132
 
 
133
#
 
134
# Bug #9855 (inconsistent column type for create select
 
135
#
 
136
create temporary table  t1 engine=myisam as select  105213674794682365.00 + 0.0 x;
 
137
show warnings;
 
138
desc  t1;
 
139
drop table t1;
 
140
 
 
141
create temporary table t1 engine=myisam as select 0.0 x;
 
142
desc t1;
 
143
create temporary table t2 engine=myisam as select 105213674794682365.00 y;
 
144
desc t2;
 
145
create temporary table t3 engine=myisam as select x+y a from t1,t2;
 
146
show warnings;
 
147
desc t3;
 
148
drop table t1,t2,t3;
 
149
 
 
150
#
 
151
# Bug #22129: A small double precision number becomes zero
 
152
#
 
153
# check if underflows are detected correctly
 
154
select 1e-308, 1.00000001e-300, 100000000e-300;
 
155
 
 
156
# check if overflows are detected correctly
 
157
select 10e307;
 
158
 
 
159
#
 
160
# Bug #19690: ORDER BY eliminates rows from the result
 
161
#
 
162
create table t1(a int, b double(8, 2), pk int auto_increment primary key);
 
163
insert into t1 (a,b) values
 
164
(1, 28.50), (1, 121.85), (1, 157.23), (1, 1351.00), (1, -1965.35), (1, 81.75), 
 
165
(1, 217.08), (1, 7.94), (4, 96.07), (4, 6404.65), (4, -6500.72), (2, 100.00),
 
166
(5, 5.00), (5, -2104.80), (5, 2033.80), (5, 0.07), (5, 65.93),
 
167
(3, -4986.24), (3, 5.00), (3, 4857.34), (3, 123.74), (3,  0.16),
 
168
(6, -1695.31), (6, 1003.77), (6, 499.72), (6, 191.82);
 
169
explain select sum(b) s from t1 group by a;
 
170
select sum(b) s from t1 group by a;
 
171
select sum(b) s from t1 group by a having s <> 0;
 
172
select sum(b) s from t1 group by a having s <> 0 order by s;
 
173
select sum(b) s from t1 group by a having s <=> 0;
 
174
select sum(b) s from t1 group by a having s <=> 0 order by s;
 
175
alter table t1 add key (a, b);
 
176
explain select sum(b) s from t1 group by a;
 
177
select sum(b) s from t1 group by a;
 
178
select sum(b) s from t1 group by a having s <> 0;
 
179
select sum(b) s from t1 group by a having s <> 0 order by s;
 
180
select sum(b) s from t1 group by a having s <=> 0;
 
181
select sum(b) s from t1 group by a having s <=> 0 order by s;
 
182
drop table t1;
 
183
 
 
184
--echo End of 4.1 tests
 
185
 
 
186
#
 
187
# bug #12694 (float(m,d) specifications)
 
188
#
 
189
 
 
190
--error ER_M_BIGGER_THAN_D
 
191
create table t1 (s1 float(0,2));
 
192
--error ER_M_BIGGER_THAN_D
 
193
create table t1 (s1 float(1,2));
 
194
 
 
195
# Bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits"
 
196
#
 
197
 
 
198
create table t1 (f1 double(200, 0) primary key);
 
199
insert into t1 values (1e199), (-1e199);
 
200
insert into t1 values (1e200), (-1e200);
 
201
--error ER_WARN_DATA_OUT_OF_RANGE
 
202
insert into t1 values (2e200), (-2e200);
 
203
select f1 + 0e0 from t1;
 
204
drop table t1;
 
205
 
 
206
create table t1 (f1 float(30, 0) primary key);
 
207
insert into t1 values (1e29), (-1e29);
 
208
insert into t1 values (1e30), (-1e30);
 
209
--error ER_WARN_DATA_OUT_OF_RANGE
 
210
insert into t1 values (2e30), (-2e30);
 
211
select f1 + 0e0 from t1;
 
212
drop table t1;
 
213
 
 
214
#
 
215
# Bug #12860 "Difference in zero padding of exponent between Unix and Windows"
 
216
#
 
217
 
 
218
create table t1 (c char(6) primary key);
 
219
insert into t1 values (2e6),(2e-5);
 
220
select * from t1;
 
221
drop table t1;
 
222
 
 
223
#
 
224
# Bug #21497 "DOUBLE truncated to unusable value"
 
225
#
 
226
 
 
227
CREATE TABLE d1 (d DOUBLE primary key);
 
228
INSERT INTO d1 VALUES (1.7976931348623157E+308);
 
229
SELECT * FROM d1;
 
230
--error ER_ILLEGAL_VALUE_FOR_TYPE
 
231
INSERT INTO d1 VALUES (1.79769313486232e+308);
 
232
SELECT * FROM d1;
 
233
DROP TABLE d1;
 
234
 
 
235
#
 
236
# Bug #26788 "mysqld (debug) aborts when inserting specific numbers into char 
 
237
#             fields"
 
238
#
 
239
 
 
240
create table t1 (a char(20) primary key);
 
241
insert into t1 values (1.225e-05);
 
242
select a+0 from t1;
 
243
drop table t1;
 
244
 
 
245
--echo End of 5.0 tests