2004-10-06 13:18:55 +00:00
|
|
|
-- source include/have_ndb.inc
|
2005-04-19 17:23:49 +02:00
|
|
|
-- source include/not_embedded.inc
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
--disable_warnings
|
2006-12-17 23:08:04 +03:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2004-10-06 13:18:55 +00:00
|
|
|
--enable_warnings
|
|
|
|
|
|
|
|
##########
|
|
|
|
# bug#5367
|
|
|
|
create table t1 (p int not null primary key, u int not null, o int not null,
|
|
|
|
unique (u), key(o)) engine=ndb;
|
|
|
|
|
|
|
|
create table t2 (p int not null primary key, u int not null, o int not null,
|
|
|
|
unique (u), key(o)) engine=ndb;
|
|
|
|
|
2006-12-17 23:08:04 +03:00
|
|
|
create table t3 (a int not null primary key, b int not null) engine=ndb;
|
|
|
|
create table t4 (c int not null primary key, d int not null) engine=ndb;
|
|
|
|
|
2004-10-06 13:18:55 +00:00
|
|
|
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
|
|
|
|
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
|
2006-12-17 23:08:04 +03:00
|
|
|
insert into t3 values (1,10), (2,10), (3,30), (4, 30);
|
|
|
|
insert into t4 values (1,10), (2,10), (3,30), (4, 30);
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
# Use pk
|
2006-10-16 16:13:03 +02:00
|
|
|
--replace_column 9 #
|
2004-10-06 13:18:55 +00:00
|
|
|
explain select * from t2 where p NOT IN (select p from t1);
|
2004-10-07 08:42:11 +00:00
|
|
|
select * from t2 where p NOT IN (select p from t1) order by p;
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
# Use unique index
|
2006-10-16 16:13:03 +02:00
|
|
|
--replace_column 9 #
|
2004-10-06 13:18:55 +00:00
|
|
|
explain select * from t2 where p NOT IN (select u from t1);
|
2004-10-07 08:42:11 +00:00
|
|
|
select * from t2 where p NOT IN (select u from t1) order by p;
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
# Use ordered index
|
2006-10-16 16:13:03 +02:00
|
|
|
--replace_column 9 #
|
2004-10-06 13:18:55 +00:00
|
|
|
explain select * from t2 where p NOT IN (select o from t1);
|
2004-10-07 08:42:11 +00:00
|
|
|
select * from t2 where p NOT IN (select o from t1) order by p;
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
# Use scan
|
2006-10-16 16:13:03 +02:00
|
|
|
--replace_column 9 #
|
2004-10-06 13:18:55 +00:00
|
|
|
explain select * from t2 where p NOT IN (select p+0 from t1);
|
2004-10-07 08:42:11 +00:00
|
|
|
select * from t2 where p NOT IN (select p+0 from t1) order by p;
|
2004-10-06 13:18:55 +00:00
|
|
|
|
|
|
|
drop table t1;
|
|
|
|
drop table t2;
|
|
|
|
# bug#5367
|
|
|
|
##########
|
2005-06-09 15:39:14 +02:00
|
|
|
|
2005-07-28 03:22:47 +03:00
|
|
|
# End of 4.1 tests
|
2005-07-28 17:09:54 +03:00
|
|
|
|
|
|
|
#
|
2005-06-09 15:39:14 +02:00
|
|
|
# bug#11205
|
2005-07-28 17:09:54 +03:00
|
|
|
#
|
2005-06-09 15:39:14 +02:00
|
|
|
create table t1 (p int not null primary key, u int not null) engine=ndb;
|
|
|
|
insert into t1 values (1,1),(2,2),(3,3);
|
|
|
|
|
|
|
|
create table t2 as
|
|
|
|
select t1.*
|
|
|
|
from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8
|
|
|
|
where t1.u = t2.u
|
|
|
|
and t2.u = t3.u
|
|
|
|
and t3.u = t4.u
|
|
|
|
and t4.u = t5.u
|
|
|
|
and t5.u = t6.u
|
|
|
|
and t6.u = t7.u
|
|
|
|
and t7.u = t8.u;
|
|
|
|
|
|
|
|
select * from t2 order by 1;
|
|
|
|
|
2006-12-17 23:08:04 +03:00
|
|
|
select * from t3 where a = any (select c from t4 where c = 1) order by a;
|
|
|
|
select * from t3 where a in (select c from t4 where c = 1) order by a;
|
|
|
|
select * from t3 where a <> some (select c from t4 where c = 1) order by a;
|
|
|
|
select * from t3 where a > all (select c from t4 where c = 1) order by a;
|
|
|
|
select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
|
|
|
|
select * from t3 where exists (select * from t4 where c = 1) order by a;
|
2005-06-09 15:39:14 +02:00
|
|
|
|
2006-12-17 23:08:04 +03:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2005-06-09 15:39:14 +02:00
|
|
|
|
2006-12-17 23:08:04 +03:00
|
|
|
--echo End of 5.1 tests
|