~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/func_math.test

  • Committer: Brian Aker
  • Date: 2008-07-07 16:07:49 UTC
  • mfrom: (80.1.1 food)
  • Revision ID: brian@tangent.org-20080707160749-qj89fnnwufz4xgop
Clean up install, we no longer have system tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
drop table t1;
104
104
 
105
105
#
106
 
# Bug #11402: abs() forces rest of calculation to
 
106
# Bug #11402: abs() forces rest of calculation to unsigned
107
107
#
108
108
select abs(-2) * -2;
109
109
 
113
113
CREATE TABLE t1 (a INT);
114
114
 
115
115
INSERT INTO t1 VALUES (1),(1),(1),(2);
116
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
117
 
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;
118
120
INSERT INTO t1 VALUES (3);
119
 
SELECT RAND(2) * 1000, RAND(a) * 1000 FROM t1;
120
 
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;
121
125
 
122
126
DROP TABLE t1;  
123
127
 
127
131
# InnoDB is required to reproduce the fault, but it is okay if we default to
128
132
# MyISAM when testing.
129
133
--disable_warnings
130
 
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb;
 
134
create table t1 (a varchar(90), ts datetime not null, index (a)) engine=innodb default charset=utf8;
131
135
--enable_warnings
132
136
insert into t1 values ('http://www.foo.com/', now());
133
137
select a from t1 where a='http://www.foo.com/' order by abs(timediff(ts, 0));
142
146
select round(111,-10);
143
147
# round on bigint 
144
148
select round(-5000111000111000155,-1);
145
 
# round on bigint
 
149
# round on unsigned bigint
146
150
select round(15000111000111000155,-1);
147
151
# truncate on bigint 
148
152
select truncate(-5000111000111000155,-1);
149
 
# truncate on bigint
 
153
# truncate on unsigned bigint
150
154
select truncate(15000111000111000155,-1);
151
155
 
152
156
#
153
157
# Bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8
154
158
#
 
159
set names utf8;
155
160
create table t1
156
161
(f1 varchar(32) not null,
157
 
 f2 int not null,
158
 
 f3 int not null default '0')
159
 
engine=myisam;
 
162
 f2 smallint(5) unsigned not null,
 
163
 f3 int(10) unsigned not null default '0')
 
164
engine=myisam default charset=utf8;
160
165
insert into t1 values ('zombie',0,0),('gold',1,10000),('silver',2,10000);
161
166
 
162
167
create table t2
163
 
(f1 int not null,
164
 
 f2 int not null,
165
 
 f3 int not null)
166
 
engine=myisam;
 
168
(f1 int(10) unsigned not null,
 
169
 f2 int(10) unsigned not null,
 
170
 f3 smallint(5) unsigned not null)
 
171
engine=myisam default charset=utf8;
167
172
insert into t2 values (16777216,16787215,1),(33554432,33564431,2);
168
173
 
169
174
select format(t2.f2-t2.f1+1,0) from t1,t2
170
175
where t1.f2 = t2.f3 order by t1.f1;
171
176
drop table t1, t2;
172
 
 
173
 
# Bug 24912 -- misc functions have trouble with
174
 
 
175
 
select -2, 18446744073709551614, -2;
176
 
select abs(-2), abs(18446744073709551614), abs(-2);
177
 
select ceiling(-2), ceiling(18446744073709551614), ceiling(-2);
178
 
select floor(-2), floor(18446744073709551614), floor(-2);
179
 
select format(-2, 2), format(18446744073709551614, 2), format(-2, 2);
180
 
select sqrt(-2), sqrt(18446744073709551614), sqrt(-2);
181
 
select round(-2, 1), round(18446744073709551614, 1), round(-2, 1);
182
 
select round(4, -2), round(4, 18446744073709551614), round(4, -2);
183
 
select truncate(-2, 1), truncate(18446744073709551614, 1), truncate(-2, 1);
184
 
select truncate(4, -2), truncate(4, 18446744073709551614), truncate(4, -2);
 
177
set names default;
 
178
 
 
179
# Bug 24912 -- misc functions have trouble with unsigned
 
180
 
 
181
select cast(-2 as unsigned), 18446744073709551614, -2;
 
182
select abs(cast(-2 as unsigned)), abs(18446744073709551614), abs(-2);
 
183
select ceiling(cast(-2 as unsigned)), ceiling(18446744073709551614), ceiling(-2);
 
184
select floor(cast(-2 as unsigned)), floor(18446744073709551614), floor(-2);
 
185
select format(cast(-2 as unsigned), 2), format(18446744073709551614, 2), format(-2, 2);
 
186
select sqrt(cast(-2 as unsigned)), sqrt(18446744073709551614), sqrt(-2);
 
187
select round(cast(-2 as unsigned), 1), round(18446744073709551614, 1), round(-2, 1);
 
188
select round(4, cast(-2 as unsigned)), round(4, 18446744073709551614), round(4, -2);
 
189
select truncate(cast(-2 as unsigned), 1), truncate(18446744073709551614, 1), truncate(-2, 1);
 
190
select truncate(4, cast(-2 as unsigned)), truncate(4, 18446744073709551614), truncate(4, -2);
185
191
select round(10000000000000000000, -19), truncate(10000000000000000000, -19);
186
192
select round(1e0, -309), truncate(1e0, -309);
187
193
select round(1e1,308), truncate(1e1, 308);
198
204
select round(1.5, 18446744073709551615), truncate(1.5, 18446744073709551615);
199
205
select round(18446744073709551614, -1), truncate(18446744073709551614, -1);
200
206
select round(4, -4294967200), truncate(4, -4294967200);
201
 
select mod(-2, 3), mod(18446744073709551614, 3), mod(-2, 3);
202
 
select mod(5, -2), mod(5, 18446744073709551614), mod(5, -2);
203
 
select pow(-2, 5), pow(18446744073709551614, 5), pow(-2, 5);
 
207
select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3);
 
208
select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2);
 
209
select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5);
204
210
 
205
211
#
206
212
# Bug #30587: mysql crashes when trying to group by TIME div NUMBER
207
213
#
208
214
 
209
 
CREATE TABLE t1 (a timestamp, b varchar(20), c int);
 
215
CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1));
210
216
INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0);
211
217
SELECT a DIV 900 y FROM t1 GROUP BY y;
212
218
SELECT DISTINCT a DIV 900 y FROM t1;
221
227
  SELECT (a DIV 254576881) FROM t1;
222
228
DROP TABLE t1;
223
229
 
 
230
CREATE TABLE t1(a SET('a','b','c'));
 
231
INSERT INTO t1 VALUES ('a');
 
232
SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1;
 
233
DROP TABLE t1;
 
234
 
224
235
--echo End of 5.0 tests
225
236
 
226
237
#