~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/include/index_merge_ror_cpk.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
# include/index_merge_ror_cpk.inc
 
2
#
 
3
# Clustered PK ROR-index_merge tests
 
4
#
 
5
# The variable
 
6
#     $engine_type       -- storage engine to be tested
 
7
# has to be set before sourcing this script.
 
8
#
 
9
# Note: The comments/expectations refer to InnoDB.
 
10
#       They might be not valid for other storage engines.
 
11
#
 
12
# Last update:
 
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
 
16
#
 
17
 
 
18
--echo #---------------- Clustered PK ROR-index_merge tests -----------------------------
 
19
 
 
20
eval SET SESSION STORAGE_ENGINE = $engine_type;
 
21
 
 
22
--disable_warnings
 
23
drop table if exists  t1;
 
24
--enable_warnings
 
25
 
 
26
create table t1
 
27
(
 
28
  pk1 int not null,
 
29
  pk2 int not null,
 
30
 
 
31
  key1 int not null,
 
32
  key2 int not null,
 
33
 
 
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,
 
39
 
 
40
  pk2copy int not null,
 
41
  badkey  int not null,
 
42
 
 
43
  filler1 char (200),
 
44
  filler2 char (200),
 
45
  key (key1),
 
46
  key (key2),
 
47
 
 
48
  /* keys with tails from CPK members */
 
49
  key (pktail1ok, pk1),
 
50
  key (pktail2ok, pk1, pk2),
 
51
  key (pktail3bad, pk2, pk1),
 
52
  key (pktail4bad, pk1, pk2copy),
 
53
  key (pktail5bad, pk1, pk2, pk2copy),
 
54
 
 
55
  primary key (pk1, pk2)
 
56
);
 
57
 
 
58
--disable_query_log
 
59
set autocommit=0;
 
60
let $1=10000;
 
61
while ($1)
 
62
{
 
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');
 
64
  dec $1;
 
65
}
 
66
set autocommit=1;
 
67
--enable_query_log
 
68
 
 
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;
 
74
 
 
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;
 
78
 
 
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;
 
84
 
 
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;
 
88
 
 
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;
 
92
 
 
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;
 
98
 
 
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;
 
102
 
 
103
drop table t1;
 
104
# Testcase for BUG#4984
 
105
create table t1
 
106
(
 
107
  RUNID varchar(22),
 
108
  SUBMITNR varchar(5),
 
109
  ORDERNR char(1),
 
110
  PROGRAMM varchar(8),
 
111
  TESTID varchar(4),
 
112
  UCCHECK char(1),
 
113
  ETEXT varchar(80),
 
114
  ETEXT_TYPE char(1),
 
115
  INFO char(1),
 
116
  SEVERITY tinyint(3),
 
117
  TADIRFLAG char(1),
 
118
  PRIMARY KEY  (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
 
119
  KEY `TVERM~KEY`  (PROGRAMM,TESTID,UCCHECK)
 
120
) DEFAULT CHARSET=latin1;
 
121
 
 
122
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
 
123
WHERE
 
124
 `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
 
125
 `TESTID`='' AND `UCCHECK`='';
 
126
 
 
127
drop table t1;
 
128