File: ndb_subquery.test

package info (click to toggle)
mysql-5.1 5.1.73-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 197,132 kB
  • ctags: 93,377
  • sloc: cpp: 579,952; ansic: 429,462; perl: 49,053; sh: 21,692; pascal: 21,272; yacc: 12,801; makefile: 4,545; xml: 4,114; sql: 3,297; lex: 1,265; asm: 1,023
file content (79 lines) | stat: -rw-r--r-- 2,386 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
-- source include/have_ndb.inc
-- source include/not_embedded.inc

--disable_warnings
drop table if exists t1, t2, t3, t4;
--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;

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;

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);
insert into t3 values (1,10), (2,10), (3,30), (4, 30);
insert into t4 values (1,10), (2,10), (3,30), (4, 30);

# Use pk
--replace_column 9 #
explain select * from t2 where p NOT IN (select p from t1);
select * from t2 where p NOT IN (select p from t1) order by p;

# Use unique index
--replace_column 9 #
explain select * from t2 where p NOT IN (select u from t1);
select * from t2 where p NOT IN (select u from t1) order by p;

# Use ordered index
--replace_column 9 #
explain select * from t2 where p NOT IN (select o from t1);
select * from t2 where p NOT IN (select o from t1) order by p;

# Use scan
--replace_column 9 #
explain select * from t2 where p NOT IN (select p+0 from t1);
select * from t2 where p NOT IN (select p+0 from t1) order by p;

drop table t1;
drop table t2;
# bug#5367
##########

# End of 4.1 tests

#
# bug#11205
#
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;

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;

drop table if exists t1, t2, t3, t4;

--echo End of 5.1 tests