~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_in.test

  • Committer: Stewart Smith
  • Date: 2009-05-15 06:57:12 UTC
  • mto: (991.1.5 for-brian)
  • mto: This revision was merged to the branch mainline in revision 1022.
  • Revision ID: stewart@flamingspork.com-20090515065712-bmionylacjmexmmm
Make sql_mode=NO_AUTO_VALUE_ON_ZERO default for Drizzle.

Also fix DEFAULT keyword handling for auto-increment so that it defaults to
NULL and not 0 so that the following is valid and generates two auto-inc
values:

create table t1 (a int auto_increment primary key)
insert into t1 (a) values (default);
insert into t1 (a) values (default);

Important to note that 0 is no longer magic. So this gives you duplicate
primary key error:

insert into t1 (a) values(0);
insert into t1 (a) values(0);

as you've inserted the explicit value of 0 twice.

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
DROP TABLE t1;
138
138
 
139
139
# BUG#15872: Excessive memory consumption of range analysis of NOT IN
140
 
# I have disabled the EXPLAIN because we must use Innodb with this test.
141
 
create table t1 (a int);
 
140
create table t1 (a int) ENGINE=MYISAM;
142
141
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); 
143
 
create temporary table t2 (a int, filler char(200), key(a)) engine=myisam;
 
142
create table t2 (a int, filler char(200), key(a)) ENGINE=MYISAM;
144
143
 
145
 
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C where A.a < 10;
 
144
insert into t2 select C.a*2,   'no'  from t1 A, t1 B, t1 C;
146
145
insert into t2 select C.a*2+1, 'yes' from t1 C;
147
146
 
148
147
explain 
149
148
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
150
149
select * from t2 where a NOT IN (0, 2,4,6,8,10,12,14,16,18);
151
150
 
152
 
153
151
explain select * from t2 force index(a) where a NOT IN (2,2,2,2,2,2);
154
152
explain select * from t2 force index(a) where a <> 2;
155
153
 
180
178
#
181
179
create table t2 (a varchar(10), filler char(200), key(a));
182
180
 
183
 
insert into t2 select 'foo', 'no' from t1 A, t1 B where A.a < 10;
184
 
insert into t2 select 'barbar', 'no' from t1 A, t1 B where A.a < 10;
185
 
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B where A.a < 10;
 
181
insert into t2 select 'foo', 'no' from t1 A, t1 B;
 
182
insert into t2 select 'barbar', 'no' from t1 A, t1 B;
 
183
insert into t2 select 'bazbazbaz', 'no' from t1 A, t1 B;
186
184
 
187
185
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'), 
188
186
  ('barbas','1'), ('bazbazbay', '1'),('zz','1');
196
194
#
197
195
create table t2 (a decimal(10,5), filler char(200), key(a));
198
196
 
199
 
insert into t2 select 345.67890, 'no' from t1 A, t1 B where A.a < 10;
200
 
insert into t2 select 43245.34, 'no' from t1 A, t1 B where A.a < 10;
201
 
insert into t2 select 64224.56344, 'no' from t1 A, t1 B where A.a < 10;
 
197
insert into t2 select 345.67890, 'no' from t1 A, t1 B;
 
198
insert into t2 select 43245.34, 'no' from t1 A, t1 B;
 
199
insert into t2 select 64224.56344, 'no' from t1 A, t1 B;
202
200
 
203
201
insert into t2 values (0, '1'), (22334.123,'1'), (33333,'1'), 
204
202
  (55555,'1'), (77777, '1');
217
215
set @str="update t2 set b=1 where a not in (";
218
216
select count(*) from (
219
217
  select @str:=concat(@str, @cnt:=@cnt+1, ",") 
220
 
  from t1 A, t1 B, t1 C, t1 D  where A.a < 10) Z;
 
218
  from t1 A, t1 B, t1 C, t1 D) Z;
221
219
 
222
220
set @str:=concat(@str, "10000)");
223
221
select substr(@str, 1, 50);
262
260
INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002),
263
261
       (1003,1003),(1004,1004);
264
262
 
265
 
--sorted_result
266
263
EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 
267
264
  JOIN t1 ON t3.a=t1.a 
268
265
  JOIN t2 ON t3.a=t2.a
273
270
  JOIN t2 ON t3.a=t2.a
274
271
  JOIN t4 WHERE t4.a IN (t1.b, t2.b);
275
272
 
276
 
--sorted_result
277
273
EXPLAIN SELECT STRAIGHT_JOIN 
278
274
   (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) 
279
275
  FROM t3, t1, t2
295
291
SELECT * FROM t1 WHERE a=-1 OR a=-2 ;
296
292
SELECT * FROM t1 WHERE a IN (-1, -2);
297
293
 
298
 
CREATE TABLE t2 (a BIGINT UNSIGNED);
 
294
CREATE TABLE t2 (a BIGINT);
299
295
insert into t2 values(13491727406643098568),
300
296
       (0x0fffffefffffffff),
301
297
       (0x0ffffffeffffffff),
362
358
CREATE TABLE t1 (id int not null);
363
359
INSERT INTO t1 VALUES (1),(2);
364
360
 
365
 
--error ER_DIVISION_BY_ZERO
366
361
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
367
362
 
368
363
DROP TABLE t1;
373
368
#
374
369
# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result 
375
370
#
376
 
create TEMPORARY table t1(f1 char(1)) ENGINE=MYISAM;
 
371
create table t1(f1 char(1)) ENGINE=MYISAM;
377
372
insert into t1 values ('a'),('b'),('1');
378
373
select f1 from t1 where f1 in ('a',1);
379
374
select f1, case f1 when 'a' then '+' when 1 then '-' end from t1;
384
379
explain select f1 from t1 where f1 in ('a','b');
385
380
select f1 from t1 where f1 in (2,1);
386
381
explain select f1 from t1 where f1 in (2,1);
387
 
create TEMPORARY table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
 
382
create table t2(f2 int, index t2f2(f2)) ENGINE=MYISAM;
388
383
insert into t2 values(0),(1),(2);
389
384
select f2 from t2 where f2 in ('a',2);
390
385
explain select f2 from t2 where f2 in ('a',2);