~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/key_cache.test

  • Committer: Brian Aker
  • Date: 2010-04-05 23:46:43 UTC
  • Revision ID: brian@gaz-20100405234643-0he3xnj902rc70r8
Fixing tests to work with PBXT.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# Test of multiple key caches
 
2
# Test of the MyISAM key cache
3
3
#
4
4
--disable_warnings
5
5
drop table if exists t1, t2, t3;
6
6
--enable_warnings
7
7
 
8
 
SET @save_key_buffer=@@key_buffer_size;
 
8
SET @save_myisam_key_cache_size=@@myisam_key_cache_size;
 
9
SET @save_myisam_key_cache_block_size=@@myisam_key_cache_block_size;
 
10
SET @save_myisam_key_cache_division_limit=@@myisam_key_cache_division_limit;
 
11
SET @save_myisam_key_cache_age_threshold=@@myisam_key_cache_age_threshold;
9
12
 
10
 
SELECT @@key_buffer_size, @@small.key_buffer_size;
 
13
# Show default variables for MyISAM key cache
 
14
SELECT @@myisam_key_cache_size;
 
15
SELECT @@myisam_key_cache_block_size;
 
16
SELECT @@myisam_key_cache_division_limit;
 
17
SELECT @@myisam_key_cache_age_threshold;
11
18
 
12
19
# Change default key cache size
13
 
SET @@global.key_buffer_size=16*1024*1024;
14
 
SET @@global.default.key_buffer_size=16*1024*1024;
15
 
SET @@global.default.key_buffer_size=16*1024*1024;
 
20
SET @@global.myisam_key_cache_size=16*1024*1024;
16
21
 
17
 
SET @@global.small.key_buffer_size=1*1024*1024;
18
 
SET @@global.medium.key_buffer_size=4*1024*1024;
19
 
# Drop buffer
20
 
SET @@global.medium.key_buffer_size=0;
 
22
# Drop Key Cache (warning generated)
 
23
SET @@global.myisam_key_cache_size=0;
21
24
# Test double drop
22
 
SET @@global.medium.key_buffer_size=0;
 
25
SET @@global.myisam_key_cache_size=0;
 
26
 
 
27
# Change default key cache size
 
28
SET @@global.myisam_key_cache_size=16*1024*1024;
23
29
 
24
30
# Print key buffer with different syntaxes
25
 
SHOW VARIABLES like "key_buffer_size";
26
 
SELECT @@key_buffer_size;
27
 
SELECT @@global.key_buffer_size;
28
 
SELECT @@global.default.key_buffer_size;
29
 
SELECT @@global.default.`key_buffer_size`;
30
 
SELECT @@global.`default`.`key_buffer_size`;
31
 
SELECT @@`default`.key_buffer_size;
32
 
 
33
 
SELECT @@small.key_buffer_size;
34
 
SELECT @@medium.key_buffer_size;
35
 
 
36
 
SET @@global.key_buffer_size=@save_key_buffer;
 
31
SHOW VARIABLES like "myisam_key_cache_size";
 
32
SELECT @@myisam_key_cache_size;
 
33
SELECT @@global.myisam_key_cache_size;
 
34
SELECT @@global.myisam_key_cache_size;
 
35
SELECT @@global.`myisam_key_cache_size`;
 
36
SELECT @@global.`myisam_key_cache_size`;
 
37
SELECT @@myisam_key_cache_size;
 
38
 
 
39
SET @@global.myisam_key_cache_size=@save_myisam_key_cache_size;
37
40
 
38
41
#
39
42
# Errors
40
43
#
41
44
 
42
 
--error 1064
43
 
SELECT @@default.key_buffer_size;
44
 
--error 1272
 
45
SELECT @@myisam_key_cache_size;
 
46
-- error 1272
45
47
SELECT @@skr.storage_engine="test";
46
48
 
47
 
select @@keycache1.key_cache_block_size;
48
 
select @@keycache1.key_buffer_size;
49
 
set global keycache1.key_cache_block_size=2048;
50
 
select @@keycache1.key_buffer_size;
51
 
select @@keycache1.key_cache_block_size;
52
 
set global keycache1.key_buffer_size=1*1024*1024;
53
 
select @@keycache1.key_buffer_size;
54
 
select @@keycache1.key_cache_block_size;
55
 
set global keycache2.key_buffer_size=4*1024*1024;
56
 
select @@keycache2.key_buffer_size;
57
 
select @@keycache2.key_cache_block_size;
58
 
set global keycache1.key_buffer_size=0;
59
 
select @@keycache1.key_buffer_size;
60
 
select @@keycache1.key_cache_block_size;
61
 
select @@key_buffer_size;
62
 
select @@key_cache_block_size;
63
 
 
64
 
set global keycache1.key_buffer_size=1024*1024;
65
 
 
66
 
create table t1 (p int primary key, a char(10)) delay_key_write=1 ENGINE=myisam;
67
 
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) ENGINE=myisam;
68
 
 
69
 
show status like 'key_blocks_used';
70
 
 
71
 
# Following results differs on 64 and 32 bit systems because of different
72
 
# pointer sizes, which takes up different amount of space in key cache
73
 
 
74
 
--replace_result 837 KEY_BLOCKS_UNUSED 906 KEY_BLOCKS_UNUSED 896 KEY_BLOCKS_UNUSED
75
 
show status like 'key_blocks_unused';
76
 
 
77
 
insert into t1 values (1, 'qqqq'), (11, 'yyyy');
78
 
insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
79
 
                      (3, 1, 'yyyy'), (4, 3, 'zzzz');
80
 
select * from t1;
81
 
select * from t2;
82
 
 
83
 
update t1 set p=2 where p=1;
84
 
update t2 set i=2 where i=1;
85
 
 
86
 
show status like 'key_blocks_used';
87
 
--replace_result 833 KEY_BLOCKS_UNUSED 902 KEY_BLOCKS_UNUSED 892 KEY_BLOCKS_UNUSED
88
 
show status like 'key_blocks_unused';
89
 
 
90
 
cache index t1 key (`primary`) in keycache1;
91
 
 
92
 
explain select p from t1;
93
 
select p from t1;
94
 
explain select i from t2;
95
 
select i from t2;
96
 
explain select count(*) from t1, t2 where t1.p = t2.i;
97
 
select count(*) from t1, t2 where t1.p = t2.i;
98
 
 
99
 
cache index t2 in keycache1;
100
 
update t2 set p=p+1000, i=2 where a='qqqq';
101
 
cache index t2 in keycache2;
102
 
insert into t2 values (2000, 3, 'yyyy');
103
 
cache index t2 in keycache1;
104
 
update t2 set p=3000 where a='zzzz';
105
 
select * from t2;
106
 
explain select p from t2;
107
 
select p from t2;
108
 
explain select i from t2;
109
 
select i from t2;
110
 
explain select a from t2;
111
 
select a from t2;
112
 
 
113
 
# Test some error conditions
114
 
--error 1284
115
 
cache index t1 in unknown_key_cache;
116
 
cache index t1 key (unknown_key) in keycache1;
117
 
 
118
 
select @@keycache2.key_buffer_size;
119
 
select @@keycache2.key_cache_block_size;
120
 
set global keycache2.key_buffer_size=0;
121
 
select @@keycache2.key_buffer_size;
122
 
select @@keycache2.key_cache_block_size;
123
 
set global keycache2.key_buffer_size=1024*1024;
124
 
select @@keycache2.key_buffer_size;
125
 
 
126
 
update t2 set p=4000 where a='zzzz';
127
 
update t1 set p=p+1;
128
 
 
129
 
set global keycache1.key_buffer_size=0;
130
 
select * from t2;
131
 
select p from t2;
132
 
explain select i from t2;
133
 
select i from t2;
134
 
explain select a from t2;
135
 
select a from t2;
136
 
 
137
 
select * from t1;
138
 
select p from t1;
139
 
 
140
 
# Use the 'small' key cache
141
 
create table t3 (like t1);
142
 
cache index t3 in small;
143
 
insert into t3 select * from t1;
144
 
cache index t3 in keycache2;
145
 
cache index t1,t2 in default;
146
 
drop table t1,t2,t3;
147
 
 
148
 
show status like 'key_blocks_used';
149
 
--replace_result 837 KEY_BLOCKS_UNUSED 906 KEY_BLOCKS_UNUSED 896 KEY_BLOCKS_UNUSED
150
 
show status like 'key_blocks_unused';
151
 
 
152
 
 
153
 
# Cleanup
154
 
# We don't reset keycache2 as we want to ensure that mysqld will reset it
155
 
set global keycache2.key_buffer_size=0;
 
49
-- error 1272
 
50
select @@keycache1.myisam_key_cache_block_size;
 
51
 
 
52
--replace_column 2 #
 
53
show status like 'key_blocks_used';
156
54
 
157
55
# Test to set up a too small size for a key cache (bug #2064)
158
 
set global keycache3.key_buffer_size=100;
159
 
set global keycache3.key_buffer_size=0;
160
 
 
161
 
# Restore the changed variable value
162
 
set global key_cache_block_size= @my_key_cache_block_size;
 
56
set global myisam_key_cache_size=100;
163
57
 
164
58
#
165
 
# Bug #19079: corrupted index when key_cache_block_size is not multiple of
 
59
# Bug #19079: corrupted index when myisam_key_cache_block_size is not multiple of
166
60
#             myisam_block_size
167
61
 
168
 
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MYISAM;
169
 
SET @my_key_cache_block_size= @@global.key_cache_block_size;
170
 
SET GLOBAL key_cache_block_size=1536;
 
62
CREATE temporary TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MYISAM;
 
63
SET GLOBAL myisam_key_cache_block_size=1536;
171
64
INSERT INTO t1 VALUES (1);
172
 
SELECT @@key_cache_block_size;
 
65
SELECT @@myisam_key_cache_block_size;
173
66
CHECK TABLE t1;
174
67
DROP TABLE t1;
175
68
 
176
 
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
177
 
CREATE TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
178
 
SET GLOBAL key_cache_block_size=1536;
 
69
CREATE TEMPORARY TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
 
70
CREATE TEMPORARY TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
 
71
SET GLOBAL myisam_key_cache_block_size=1536;
179
72
INSERT INTO t1 VALUES (1,0);
180
73
INSERT INTO t2(b) SELECT b FROM t1;
181
74
INSERT INTO t1(b) SELECT b FROM t2;
197
89
INSERT INTO t2(b) SELECT b FROM t1;
198
90
INSERT INTO t1(b) SELECT b FROM t2;
199
91
SELECT COUNT(*) FROM t1;
200
 
SELECT @@key_cache_block_size;
 
92
SELECT @@myisam_key_cache_block_size;
201
93
CHECK TABLE t1;
202
94
DROP TABLE t1,t2;
203
95
# Restore changed variables
204
 
set global key_cache_block_size= @my_key_cache_block_size;
205
 
 
206
 
#
207
 
# Bug#10473 - Can't set 'key_buffer_size' system variable to ZERO
208
 
# (One cannot drop the default key cache.)
209
 
#
210
 
set @@global.key_buffer_size=0;
211
 
select @@global.key_buffer_size;
212
 
 
213
 
#
214
 
# Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables
215
 
#
216
 
SET @bug28478_key_cache_block_size= @@global.key_cache_block_size;
217
 
SET GLOBAL key_cache_block_size= 1536;
218
 
CREATE TABLE t1 (
 
96
set global myisam_key_cache_block_size= @save_myisam_key_cache_block_size;
 
97
 
 
98
#
 
99
# Bug#28478 - Improper myisam_key_cache_block_size corrupts MyISAM tables
 
100
#
 
101
SET GLOBAL myisam_key_cache_block_size= 1536;
 
102
CREATE TEMPORARY TABLE t1 (
219
103
  id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
220
104
  c1 CHAR(50),
221
105
  c2 CHAR(50),
229
113
  ('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'),
230
114
  ('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'),
231
115
  ('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z');
232
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
233
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
234
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
 
116
CREATE TABLE t2 AS SELECT * FROM t1;
 
117
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
 
118
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
 
119
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
235
120
CHECK TABLE t1;
236
 
SHOW VARIABLES LIKE 'key_cache_block_size';
237
 
SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size;
238
 
DROP TABLE t1;
239
 
 
240
 
# End of 4.1 tests
 
121
SHOW VARIABLES LIKE 'myisam_key_cache_block_size';
 
122
SET GLOBAL myisam_key_cache_block_size= @save_myisam_key_cache_block_size;
 
123
DROP TABLE t1,t2;
 
124
 
 
125
# Check division limit and age threshold
 
126
 
 
127
# Division Limit: Minimum 1, maximum 100
 
128
SET GLOBAL myisam_key_cache_division_limit= 0;
 
129
 
 
130
SELECT @@myisam_key_cache_division_limit;
 
131
 
 
132
SET GLOBAL myisam_key_cache_division_limit= 101;
 
133
 
 
134
SELECT @@myisam_key_cache_division_limit;
 
135
 
 
136
# Age Threshold: Minimum 100, maximum UINT32_MAX
 
137
SET GLOBAL myisam_key_cache_age_threshold= 98;
 
138
 
 
139
SELECT @@myisam_key_cache_age_threshold;
 
140
 
 
141
SET GLOBAL myisam_key_cache_age_threshold= 5000000000;
 
142
 
 
143
SELECT @@myisam_key_cache_age_threshold;