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;
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;
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);
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;
181
179
create table t2 (a varchar(10), filler char(200), key(a));
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;
187
185
insert into t2 values ('fon', '1'), ('fop','1'), ('barbaq','1'),
188
186
('barbas','1'), ('bazbazbay', '1'),('zz','1');
197
195
create table t2 (a decimal(10,5), filler char(200), key(a));
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;
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;
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);
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
295
291
SELECT * FROM t1 WHERE a=-1 OR a=-2 ;
296
292
SELECT * FROM t1 WHERE a IN (-1, -2);
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);
365
--error ER_DIVISION_BY_ZERO
366
361
SELECT id FROM t1 WHERE id IN(4564, (SELECT IF(1=0,1,1/0)) );
374
369
# Bug#18360: Type aggregation for IN and CASE may lead to a wrong result
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);