~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_math.test

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
#
99
99
 
100
100
create table t1 select round(1, 6);
101
 
--replace_regex /ENGINE=[a-z]*/ENGINE=X/i
102
101
show create table t1;
103
102
select * from t1;
104
103
drop table t1;
105
104
 
106
105
#
107
 
# Bug #11402: abs() forces rest of calculation to
 
106
# Bug #11402: abs() forces rest of calculation to unsigned
108
107
#
109
108
select abs(-2) * -2;
110
109
 
114
113
CREATE TABLE t1 (a INT);
115
114
 
116
115
INSERT INTO t1 VALUES (1),(1),(1),(2);
117
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
118
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1 WHERE a = 1;
 
116
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
117
  FROM t1;
 
118
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
119
  FROM t1 WHERE a = 1;
119
120
INSERT INTO t1 VALUES (3);
120
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
121
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1 WHERE a = 1;
 
121
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
122
  FROM t1;
 
123
SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) 
 
124
  FROM t1 WHERE a = 1;
122
125
 
123
126
DROP TABLE t1;  
124
127
 
143
146
select round(111,-10);
144
147
# round on bigint 
145
148
select round(-5000111000111000155,-1);
146
 
# round on bigint
 
149
# round on unsigned bigint
147
150
select round(15000111000111000155,-1);
148
151
# truncate on bigint 
149
152
select truncate(-5000111000111000155,-1);
150
 
# truncate on bigint
 
153
# truncate on unsigned bigint
151
154
select truncate(15000111000111000155,-1);
152
155
 
153
156
#
155
158
#
156
159
create table t1
157
160
(f1 varchar(32) not null,
158
 
 f2 int not null,
159
 
 f3 int not null default '0')
 
161
 f2 smallint unsigned not null,
 
162
 f3 int unsigned not null default '0')
160
163
engine=myisam;
161
164
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
162
165
 
163
166
create table t2
164
 
(f1 int not null,
165
 
 f2 int not null,
166
 
 f3 int not null)
 
167
(f1 int unsigned not null,
 
168
 f2 int unsigned not null,
 
169
 f3 smallint unsigned not null)
167
170
engine=myisam;
168
171
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
169
172
 
171
174
where t1.f2 = t2.f3 order by t1.f1;
172
175
drop table t1, t2;
173
176
 
174
 
# Bug 24912 -- misc functions have trouble with
 
177
# Bug 24912 -- misc functions have trouble with unsigned
175
178
 
176
 
select -2, 18446744073709551614, -2;
177
 
select abs(-2), abs(18446744073709551614), abs(-2);
178
 
select ceiling(-2), ceiling(18446744073709551614), ceiling(-2);
179
 
select floor(-2), floor(18446744073709551614), floor(-2);
180
 
select format(-2, 2), format(18446744073709551614, 2), format(-2, 2);
181
 
select sqrt(-2), sqrt(18446744073709551614), sqrt(-2);
182
 
select round(-2, 1), round(18446744073709551614, 1), round(-2, 1);
183
 
select round(4, -2), round(4, 18446744073709551614), round(4, -2);
184
 
select truncate(-2, 1), truncate(18446744073709551614, 1), truncate(-2, 1);
185
 
select truncate(4, -2), truncate(4, 18446744073709551614), truncate(4, -2);
 
179
select cast(-2 as unsigned), 18446744073709551614, -2;
 
180
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
 
181
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
 
182
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
 
183
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
 
184
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
 
185
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
 
186
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
 
187
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
 
188
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
186
189
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
187
190
select round(1e0, -309), truncate(1e0, -309);
188
191
select round(1e1,308), truncate(1e1, 308);
199
202
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
200
203
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
201
204
select round(4, -4294967200), truncate(4, -4294967200);
202
 
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3);
203
 
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2);
204
 
select pow(-2, 5), pow(18446744073709551614, 5), pow(-2, 5);
 
205
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
 
206
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
 
207
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
205
208
 
206
209
#
207
210
# Bug #30587: mysql crashes when trying to group by TIME div NUMBER
208
211
#
209
212
 
210
 
CREATE TABLE t1 (a timestamp, b varchar(20), c int);
 
213
CREATE TABLE t1 (a timestamp, b varchar(20), c bit);
211
214
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
212
215
SELECT a DIV 900 y FROM t1 GROUP BY y;
213
216
SELECT DISTINCT a DIV 900 y FROM t1;