~vkolesnikov/pbxt/pbxt-1.5-23.06.2011

« back to all changes in this revision

Viewing changes to test/mysql-test/test_data/505/r/ndb_subquery.result

  • Committer: vladimir at primebase
  • Date: 2011-06-23 15:11:13 UTC
  • mfrom: (824.1.48 pbxt11)
  • Revision ID: vladimir@primebase.org-20110623151113-ie7mezix8dv68jts
merged changes from PBXT 1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1, t2, t3, t4;
 
2
create table t1 (p int not null primary key, u int not null, o int not null,
 
3
unique (u), key(o)) engine=ndb;
 
4
create table t2 (p int not null primary key, u int not null, o int not null,
 
5
unique (u), key(o)) engine=ndb;
 
6
create table t3 (a int not null primary key, b int not null) engine=ndb;
 
7
create table t4 (c int not null primary key, d int not null) engine=ndb;
 
8
insert into t1 values (1,1,1),(2,2,2),(3,3,3);
 
9
insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
 
10
insert into t3 values (1,10), (2,10), (3,30), (4, 30);
 
11
insert into t4 values (1,10), (2,10), (3,30), (4, 30);
 
12
explain select * from t2 where p NOT IN (select p from t1);
 
13
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
14
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    #       Using where
 
15
2       DEPENDENT SUBQUERY      t1      unique_subquery PRIMARY PRIMARY 4       func    #       Using index
 
16
select * from t2 where p NOT IN (select p from t1) order by p;
 
17
p       u       o
 
18
4       4       4
 
19
5       5       5
 
20
explain select * from t2 where p NOT IN (select u from t1);
 
21
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
22
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    #       Using where
 
23
2       DEPENDENT SUBQUERY      t1      unique_subquery u       u       4       func    #       Using index
 
24
select * from t2 where p NOT IN (select u from t1) order by p;
 
25
p       u       o
 
26
4       4       4
 
27
5       5       5
 
28
explain select * from t2 where p NOT IN (select o from t1);
 
29
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
30
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    #       Using where
 
31
2       DEPENDENT SUBQUERY      t1      index_subquery  o       o       4       func    #       Using index
 
32
select * from t2 where p NOT IN (select o from t1) order by p;
 
33
p       u       o
 
34
4       4       4
 
35
5       5       5
 
36
explain select * from t2 where p NOT IN (select p+0 from t1);
 
37
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
38
1       PRIMARY t2      ALL     NULL    NULL    NULL    NULL    #       Using where
 
39
2       DEPENDENT SUBQUERY      t1      ALL     NULL    NULL    NULL    NULL    #       Using where
 
40
select * from t2 where p NOT IN (select p+0 from t1) order by p;
 
41
p       u       o
 
42
4       4       4
 
43
5       5       5
 
44
drop table t1;
 
45
drop table t2;
 
46
create table t1 (p int not null primary key, u int not null) engine=ndb;
 
47
insert into t1 values (1,1),(2,2),(3,3);
 
48
create table t2 as 
 
49
select t1.*
 
50
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
 
51
where t1.u = t2.u
 
52
and t2.u = t3.u
 
53
and t3.u = t4.u
 
54
and t4.u = t5.u
 
55
and t5.u = t6.u
 
56
and t6.u = t7.u
 
57
and t7.u = t8.u;
 
58
select * from t2 order by 1;
 
59
p       u
 
60
1       1
 
61
2       2
 
62
3       3
 
63
select * from t3 where a = any (select c from t4 where c = 1) order by a;
 
64
a       b
 
65
1       10
 
66
select * from t3 where a in (select c from t4 where c = 1) order by a;
 
67
a       b
 
68
1       10
 
69
select * from t3 where a <> some (select c from t4 where c = 1) order by a;
 
70
a       b
 
71
2       10
 
72
3       30
 
73
4       30
 
74
select * from t3 where a > all (select c from t4 where c = 1) order by a;
 
75
a       b
 
76
2       10
 
77
3       30
 
78
4       30
 
79
select * from t3 where row(1,10) = (select c,d from t4 where c = 1) order by a;
 
80
a       b
 
81
1       10
 
82
2       10
 
83
3       30
 
84
4       30
 
85
select * from t3 where exists (select * from t4 where c = 1) order by a;
 
86
a       b
 
87
1       10
 
88
2       10
 
89
3       30
 
90
4       30
 
91
drop table if exists t1, t2, t3, t4;
 
92
End of 5.1 tests