~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to mysql-test/t/index_merge_ror_cpk.test

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Clustered PK ROR-index_merge tests
 
3
#
 
4
-- source include/have_innodb.inc
 
5
 
 
6
--disable_warnings
 
7
drop table if exists  t1;
 
8
--enable_warnings
 
9
 
 
10
create table t1
 
11
(
 
12
  pk1 int not null, 
 
13
  pk2 int not null,
 
14
 
 
15
  key1 int not null,
 
16
  key2 int not null,
 
17
 
 
18
  pktail1ok  int not null, 
 
19
  pktail2ok  int not null, 
 
20
  pktail3bad int not null,
 
21
  pktail4bad int not null,
 
22
  pktail5bad int not null,
 
23
 
 
24
  pk2copy int not null,
 
25
  badkey  int not null,
 
26
 
 
27
  filler1 char (200),
 
28
  filler2 char (200),
 
29
  key (key1),
 
30
  key (key2),
 
31
 
 
32
  /* keys with tails from CPK members */
 
33
  key (pktail1ok, pk1),
 
34
  key (pktail2ok, pk1, pk2),
 
35
  key (pktail3bad, pk2, pk1),
 
36
  key (pktail4bad, pk1, pk2copy),
 
37
  key (pktail5bad, pk1, pk2, pk2copy),
 
38
 
 
39
  primary key (pk1, pk2)
 
40
) engine=innodb;
 
41
 
 
42
--disable_query_log
 
43
set autocommit=0;
 
44
let $1=10000;
 
45
while ($1)
 
46
{
 
47
  eval insert into t1 values ($1 div 10,$1 mod 100,   $1/100,$1/100,   $1/100,$1/100,$1/100,$1/100,$1/100, $1 mod 100, $1/1000,'filler-data-$1','filler2');
 
48
  dec $1;
 
49
}
 
50
set autocommit=1;
 
51
--enable_query_log
 
52
 
 
53
# Verify that range scan on CPK is ROR 
 
54
# (use index_intersection because it is impossible to check that for index union) 
 
55
explain select * from t1 where pk1 = 1 and pk2 < 80  and key1=0;
 
56
# CPK scan + 1 ROR range scan is a special case
 
57
select * from t1 where pk1 = 1 and pk2 < 80  and key1=0;
 
58
 
 
59
# Verify that CPK fields are considered to be covered by index scans 
 
60
explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
 
61
select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
 
62
 
 
63
# Verify that CPK is always used for index intersection scans
 
64
# (this is because it is used as a filter, not for retrieval)
 
65
explain select * from t1 where badkey=1 and key1=10;
 
66
--replace_result 38 ROWS 37 ROWS
 
67
explain select * from t1 where pk1 < 7500 and key1 = 10;
 
68
  
 
69
# Verify that keys with 'tails' of PK members are ok.
 
70
explain select * from t1 where pktail1ok=1 and key1=10;
 
71
explain select * from t1 where pktail2ok=1 and key1=10;
 
72
 
 
73
select '  The following is actually a deficiency, it uses sort_union currently:' as 'note:';
 
74
explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
 
75
 
 
76
# The expected rows differs a bit from platform to platform
 
77
--replace_result 98 ROWS 99 ROWS
 
78
explain select * from t1 where pktail3bad=1 and key1=10;
 
79
explain select * from t1 where pktail4bad=1 and key1=10;
 
80
explain select * from t1 where pktail5bad=1 and key1=10;
 
81
 
 
82
# Test for problem with innodb key values prefetch buffer: 
 
83
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
 
84
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
 
85
 
 
86
drop table t1;
 
87
# Testcase for BUG#4984
 
88
create table t1
 
89
 
90
  RUNID varchar(22), 
 
91
  SUBMITNR varchar(5), 
 
92
  ORDERNR char(1) , 
 
93
  PROGRAMM varchar(8), 
 
94
  TESTID varchar(4), 
 
95
  UCCHECK char(1), 
 
96
  ETEXT varchar(80), 
 
97
  ETEXT_TYPE char(1),
 
98
  INFO char(1), 
 
99
  SEVERITY tinyint(3), 
 
100
  TADIRFLAG char(1), 
 
101
  PRIMARY KEY  (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK), 
 
102
  KEY `TVERM~KEY`  (PROGRAMM,TESTID,UCCHECK)
 
103
) ENGINE=InnoDB DEFAULT CHARSET=latin1; 
 
104
 
 
105
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`='' 
 
106
WHERE 
 
107
 `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND 
 
108
 `TESTID`='' AND `UCCHECK`=''; 
 
109
 
 
110
drop table t1;
 
111