1
# include/index_merge_ror_cpk.inc
3
# Clustered PK ROR-index_merge tests
6
# $engine_type -- storage engine to be tested
7
# has to be set before sourcing this script.
9
# Note: The comments/expectations refer to InnoDB.
10
# They might be not valid for other storage engines.
13
# 2006-08-02 ML test refactored
14
# old name was t/index_merge_ror_cpk.test
15
# main code went into include/index_merge_ror_cpk.inc
18
--echo #---------------- Clustered PK ROR-index_merge tests -----------------------------
20
eval SET SESSION STORAGE_ENGINE = $engine_type;
23
drop table if exists t1;
34
pktail1ok int not null,
35
pktail2ok int not null,
36
pktail3bad int not null,
37
pktail4bad int not null,
38
pktail5bad int not null,
48
/* keys with tails from CPK members */
50
key (pktail2ok, pk1, pk2),
51
key (pktail3bad, pk2, pk1),
52
key (pktail4bad, pk1, pk2copy),
53
key (pktail5bad, pk1, pk2, pk2copy),
55
primary key (pk1, pk2)
63
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');
69
# Verify that range scan on CPK is ROR
70
# (use index_intersection because it is impossible to check that for index union)
71
explain select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
72
# CPK scan + 1 ROR range scan is a special case
73
select * from t1 where pk1 = 1 and pk2 < 80 and key1=0;
75
# Verify that CPK fields are considered to be covered by index scans
76
explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
77
select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
79
# Verify that CPK is always used for index intersection scans
80
# (this is because it is used as a filter, not for retrieval)
81
explain select * from t1 where badkey=1 and key1=10;
82
--replace_column 9 ROWS
83
explain select * from t1 where pk1 < 7500 and key1 = 10;
85
# Verify that keys with 'tails' of PK members are ok.
86
explain select * from t1 where pktail1ok=1 and key1=10;
87
explain select * from t1 where pktail2ok=1 and key1=10;
89
# Note: The following is actually a deficiency, it uses sort_union currently.
90
# This comment refers to InnoDB and is probably not valid for other engines.
91
explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
93
# The expected rows differs a bit from platform to platform
94
--replace_result 98 ROWS 99 ROWS
95
explain select * from t1 where pktail3bad=1 and key1=10;
96
explain select * from t1 where pktail4bad=1 and key1=10;
97
explain select * from t1 where pktail5bad=1 and key1=10;
99
# Test for problem with innodb key values prefetch buffer:
100
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
101
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
104
# Testcase for BUG#4984
118
PRIMARY KEY (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
119
KEY `TVERM~KEY` (PROGRAMM,TESTID,UCCHECK)
120
) DEFAULT CHARSET=latin1;
122
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
124
`RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
125
`TESTID`='' AND `UCCHECK`='';