~stewart/drizzle/embedded-innodb-create-select-transaction-arrgh

« back to all changes in this revision

Viewing changes to mysql-test/include/mrr_tests.inc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
create table t1(a int);
 
3
show create table t1;
 
4
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
 
5
create table t2(a int);
 
6
insert into t2 select A.a + 10*(B.a + 10*C.a) from t1 A, t1 B, t1 C;
 
7
 
 
8
 
 
9
create table t3 (
 
10
  a char(8) not null, b char(8) not null, filler char(200),
 
11
  key(a)
 
12
);
 
13
insert into t3 select @a:=concat('c-', 1000+ A.a, '=w'), @a, 'filler' from t2 A;
 
14
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 2000+A.a, '=w'), 
 
15
                      'filler-1' from t2 A;
 
16
insert into t3 select concat('c-', 1000+A.a, '=w'), concat('c-', 3000+A.a, '=w'), 
 
17
                      'filler-2' from t2 A;
 
18
 
 
19
# Test empty result set
 
20
select a,filler from t3 where a >= 'c-9011=w';
 
21
 
 
22
# Ok, t3.ref_length=6, limit is 64 => 10 elements fit into the buffer
 
23
# Test the cases when buffer gets exhausted at different points in source
 
24
# intervals:
 
25
 
 
26
# 1. Split is in the middle of the range
 
27
select a,filler from t3 where a >= 'c-1011=w' and a <= 'c-1015=w'; 
 
28
 
 
29
# 2. Split is at range edge 
 
30
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
 
31
                              (a>='c-1014=w' and a <= 'c-1015=w');
 
32
 
 
33
# 3. Split is at range edge, with some rows between ranges.
 
34
insert into t3 values ('c-1013=z', 'c-1013=z', 'err');
 
35
insert into t3 values ('a-1014=w', 'a-1014=w', 'err');
 
36
 
 
37
select a,filler from t3 where (a>='c-1011=w' and a <= 'c-1013=w') or
 
38
                              (a>='c-1014=w' and a <= 'c-1015=w');
 
39
delete from t3 where b in ('c-1013=z', 'a-1014=w');
 
40
 
 
41
# 4. Split is within the equality range.
 
42
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
 
43
                              a='c-1014=w' or a='c-1015=w';
 
44
 
 
45
# 5. Split is at the edge of equality range.
 
46
insert into t3 values ('c-1013=w', 'del-me', 'inserted');
 
47
select a,filler from t3 where a='c-1011=w' or a='c-1012=w' or a='c-1013=w' or
 
48
                              a='c-1014=w' or a='c-1015=w';
 
49
delete from t3 where b='del-me';
 
50
 
 
51
# PK tests are not included here.
 
52
 
 
53
alter table t3 add primary key(b);
 
54
 
 
55
##  PK scan tests
 
56
# 6. Split is between 'unique' PK ranges
 
57
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or 
 
58
                              b IN ('c-1019=w', 'c-1020=w', 'c-1021=w', 
 
59
                                    'c-1022=w', 'c-1023=w', 'c-1024=w');
 
60
 
 
61
# 7. Between non-uniq and uniq range
 
62
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1020=w') or 
 
63
                              b IN ('c-1021=w', 'c-1022=w', 'c-1023=w');
 
64
 
 
65
# 8. Between uniq and non-uniq range
 
66
select b,filler from t3 where (b>='c-1011=w' and b<= 'c-1018=w') or 
 
67
                              b IN ('c-1019=w', 'c-1020=w') or 
 
68
                              (b>='c-1021=w' and b<= 'c-1023=w');
 
69
## End of PK scan tests
 
70
 
 
71
#
 
72
# Now try different keypart types and special values
 
73
#
 
74
create table t4 (a varchar(10), b int, c char(10), filler char(200),
 
75
                 key idx1 (a, b, c));
 
76
 
 
77
# insert buffer_size * 1.5 all-NULL tuples
 
78
insert into t4 (filler) select concat('NULL-', 15-a) from t2 order by a limit 15;
 
79
 
 
80
insert into t4 (a,b,c,filler) 
 
81
  select 'b-1',NULL,'c-1', concat('NULL-', 15-a) from t2 order by a limit 15;
 
82
insert into t4 (a,b,c,filler) 
 
83
  select 'b-1',NULL,'c-222', concat('NULL-', 15-a) from t2 order by a limit 15;
 
84
insert into t4 (a,b,c,filler) 
 
85
  select 'bb-1',NULL,'cc-2', concat('NULL-', 15-a) from t2 order by a limit 15;
 
86
insert into t4 (a,b,c,filler) 
 
87
  select 'zz-1',NULL,'cc-2', 'filler-data' from t2 order by a limit 500;
 
88
 
 
89
explain 
 
90
  select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
 
91
                                                      or c='no-such-row2');
 
92
select * from t4 where a IS NULL and b IS NULL and (c IS NULL or c='no-such-row1'
 
93
                                                    or c='no-such-row2');
 
94
 
 
95
explain 
 
96
  select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
 
97
select * from t4 where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
 
98
 
 
99
select * from t4 ignore index(idx1) where (a ='b-1' or a='bb-1') and b IS NULL and (c='c-1' or c='cc-2');
 
100