mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / mysql-test / suite / ndb / t / ndb_subquery.test
blob6282c31c922d01775eacc7a6d546b441822aa1db
1 -- source include/have_ndb.inc
2 -- source include/not_embedded.inc
4 --disable_warnings
5 drop table if exists t1, t2, t3, t4;
6 --enable_warnings
8 ##########
9 # bug#5367
10 create table t1 (p int not null primary key, u int not null, o int not null,
11 unique (u), key(o)) engine=ndb;
13 create table t2 (p int not null primary key, u int not null, o int not null,
14 unique (u), key(o)) engine=ndb;
16 create table t3 (a int not null primary key, b int not null) engine=ndb;
17 create table t4 (c int not null primary key, d int not null) engine=ndb;
19 insert into t1 values (1,1,1),(2,2,2),(3,3,3);
20 insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
21 insert into t3 values (1,10), (2,10), (3,30), (4, 30);
22 insert into t4 values (1,10), (2,10), (3,30), (4, 30);
24 # Use pk
25 --replace_column 9 #
26 explain select * from t2 where p NOT IN (select p from t1);
27 select * from t2 where p NOT IN (select p from t1) order by p;
29 # Use unique index
30 --replace_column 9 #
31 explain select * from t2 where p NOT IN (select u from t1);
32 select * from t2 where p NOT IN (select u from t1) order by p;
34 # Use ordered index
35 --replace_column 9 #
36 explain select * from t2 where p NOT IN (select o from t1);
37 select * from t2 where p NOT IN (select o from t1) order by p;
39 # Use scan
40 --replace_column 9 #
41 explain select * from t2 where p NOT IN (select p+0 from t1);
42 select * from t2 where p NOT IN (select p+0 from t1) order by p;
44 drop table t1;
45 drop table t2;
46 # bug#5367
47 ##########
49 # End of 4.1 tests
52 # bug#11205
54 create table t1 (p int not null primary key, u int not null) engine=ndb;
55 insert into t1 values (1,1),(2,2),(3,3);
57 create table t2 as 
58 select t1.*
59 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
60 where t1.u = t2.u
61   and t2.u = t3.u
62   and t3.u = t4.u
63   and t4.u = t5.u
64   and t5.u = t6.u
65   and t6.u = t7.u
66   and t7.u = t8.u;
68 select * from t2 order by 1;
70 select * from t3 where a = any (select c from t4 where c = 1) order by a;
71 select * from t3 where a in (select c from t4 where c = 1) order by a;
72 select * from t3 where a <> some (select c from t4 where c = 1) order by a;
73 select * from t3 where a > all (select c from t4 where c = 1) order by a;
74 select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
75 select * from t3 where exists (select * from t4 where c = 1) order by a;
77 drop table if exists t1, t2, t3, t4;
79 --echo End of 5.1 tests