~drizzle-trunk/drizzle/development

1 by brian
clean slate
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;
910.4.13 by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker.
60
begin;
1 by brian
clean slate
61
let $1=10000;
62
while ($1)
63
{
64
  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');
65
  dec $1;
66
}
910.4.13 by Stewart Smith
batch up more INSERTs into transactions to help tests run quicker.
67
commit;
1 by brian
clean slate
68
set autocommit=1;
69
--enable_query_log
70
71
# Verify that range scan on CPK is ROR
72
# (use index_intersection because it is impossible to check that for index union)
73
explain select * from t1 where pk1 = 1 and pk2 < 80  and key1=0;
74
# CPK scan + 1 ROR range scan is a special case
75
select * from t1 where pk1 = 1 and pk2 < 80  and key1=0;
76
77
# Verify that CPK fields are considered to be covered by index scans
78
explain select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
79
select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
80
81
# Verify that CPK is always used for index intersection scans
82
# (this is because it is used as a filter, not for retrieval)
83
explain select * from t1 where badkey=1 and key1=10;
84
--replace_column 9 ROWS
85
explain select * from t1 where pk1 < 7500 and key1 = 10;
86
87
# Verify that keys with 'tails' of PK members are ok.
88
explain select * from t1 where pktail1ok=1 and key1=10;
89
explain select * from t1 where pktail2ok=1 and key1=10;
90
91
# Note: The following is actually a deficiency, it uses sort_union currently.
92
#       This comment refers to InnoDB and is probably not valid for other engines.
93
explain select * from t1 where (pktail2ok=1 and pk1< 50000) or key1=10;
94
95
# The expected rows differs a bit from platform to platform
96
--replace_result 98 ROWS 99 ROWS
97
explain select * from t1 where pktail3bad=1 and key1=10;
98
explain select * from t1 where pktail4bad=1 and key1=10;
99
explain select * from t1 where pktail5bad=1 and key1=10;
100
101
# Test for problem with innodb key values prefetch buffer:
102
explain select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
103
select pk1,pk2,key1,key2 from t1 where key1 = 10 and key2=10 limit 10;
104
105
drop table t1;
106
# Testcase for BUG#4984
107
create table t1
108
(
109
  RUNID varchar(22),
110
  SUBMITNR varchar(5),
111
  ORDERNR char(1),
112
  PROGRAMM varchar(8),
113
  TESTID varchar(4),
114
  UCCHECK char(1),
115
  ETEXT varchar(80),
116
  ETEXT_TYPE char(1),
117
  INFO char(1),
764 by Brian Aker
Fixed index_merge_innodb test.
118
  SEVERITY int,
1 by brian
clean slate
119
  TADIRFLAG char(1),
120
  PRIMARY KEY  (RUNID,SUBMITNR,ORDERNR,PROGRAMM,TESTID,UCCHECK),
121
  KEY `TVERM~KEY`  (PROGRAMM,TESTID,UCCHECK)
764 by Brian Aker
Fixed index_merge_innodb test.
122
);
1 by brian
clean slate
123
124
update t1 set `ETEXT` = '', `ETEXT_TYPE`='', `INFO`='', `SEVERITY`='', `TADIRFLAG`=''
125
WHERE
126
 `RUNID`= '' AND `SUBMITNR`= '' AND `ORDERNR`='' AND `PROGRAMM`='' AND
127
 `TESTID`='' AND `UCCHECK`='';
128
129
drop table t1;