~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/key_cache.test

Merged in latest plugin-slot-reorg.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
SET @save_key_buffer=@@key_buffer_size;
9
9
 
10
 
SELECT @@key_buffer_size, @@small.key_buffer_size;
 
10
SELECT @@key_buffer_size;
11
11
 
12
12
# Change default key cache size
13
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;
16
14
 
17
 
SET @@global.small.key_buffer_size=1*1024*1024;
18
 
SET @@global.medium.key_buffer_size=4*1024*1024;
19
15
# Drop buffer
20
 
SET @@global.medium.key_buffer_size=0;
 
16
SET @@global.key_buffer_size=0;
21
17
# Test double drop
22
 
SET @@global.medium.key_buffer_size=0;
 
18
SET @@global.key_buffer_size=0;
23
19
 
24
20
# Print key buffer with different syntaxes
25
21
SHOW VARIABLES like "key_buffer_size";
26
22
SELECT @@key_buffer_size;
27
23
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;
 
24
SELECT @@global.key_buffer_size;
 
25
SELECT @@global.`key_buffer_size`;
 
26
SELECT @@global.`key_buffer_size`;
 
27
SELECT @@key_buffer_size;
32
28
 
33
 
SELECT @@small.key_buffer_size;
34
 
SELECT @@medium.key_buffer_size;
 
29
SELECT @@key_buffer_size;
 
30
SELECT @@key_buffer_size;
35
31
 
36
32
SET @@global.key_buffer_size=@save_key_buffer;
37
33
 
39
35
# Errors
40
36
#
41
37
 
42
 
--error 1064
43
 
SELECT @@default.key_buffer_size;
44
 
--error 1272
 
38
SELECT @@key_buffer_size;
 
39
-- error 1272
45
40
SELECT @@skr.storage_engine="test";
46
41
 
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;
67
 
create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
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 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED 1674 KEY_BLOCKS_UNUSED 1818 KEY_BLOCKS_UNUSED 1824 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 1808 KEY_BLOCKS_UNUSED 1789 KEY_BLOCKS_UNUSED 1670 KEY_BLOCKS_UNUSED 1814 KEY_BLOCKS_UNUSED 1820 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 1812 KEY_BLOCKS_UNUSED 1793 KEY_BLOCKS_UNUSED 1674 KEY_BLOCKS_UNUSED 1818 KEY_BLOCKS_UNUSED 1824 KEY_BLOCKS_UNUSED
150
 
show status like 'key_blocks_unused';
151
 
 
 
42
-- error 1272
 
43
select @@keycache1.key_cache_block_size;
 
44
 
 
45
show status like 'key_blocks_used';
152
46
 
153
47
# Cleanup
154
48
# We don't reset keycache2 as we want to ensure that mysqld will reset it
155
 
set global keycache2.key_buffer_size=0;
 
49
set global key_buffer_size=0;
156
50
 
157
51
# 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
 
# Test case for bug 6447
162
 
 
163
 
create table t1 (mytext text, FULLTEXT (mytext));
164
 
insert t1 values ('aaabbb');
165
 
 
166
 
check table t1;
167
 
set @my_key_cache_block_size= @@global.key_cache_block_size;
168
 
set GLOBAL key_cache_block_size=2048;
169
 
check table t1;
170
 
drop table t1;
 
52
set global key_buffer_size=100;
 
53
set global key_buffer_size=0;
 
54
 
171
55
# Restore the changed variable value
 
56
-- error 1232
172
57
set global key_cache_block_size= @my_key_cache_block_size;
173
58
 
174
59
#
175
60
# Bug #19079: corrupted index when key_cache_block_size is not multiple of
176
61
#             myisam_block_size
177
62
 
178
 
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY);
 
63
CREATE temporary TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MYISAM;
179
64
SET @my_key_cache_block_size= @@global.key_cache_block_size;
180
65
SET GLOBAL key_cache_block_size=1536;
181
66
INSERT INTO t1 VALUES (1);
183
68
CHECK TABLE t1;
184
69
DROP TABLE t1;
185
70
 
186
 
CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
187
 
CREATE TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int);
 
71
CREATE TEMPORARY TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
 
72
CREATE TEMPORARY TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
188
73
SET GLOBAL key_cache_block_size=1536;
189
74
INSERT INTO t1 VALUES (1,0);
190
75
INSERT INTO t2(b) SELECT b FROM t1;
224
109
#
225
110
SET @bug28478_key_cache_block_size= @@global.key_cache_block_size;
226
111
SET GLOBAL key_cache_block_size= 1536;
227
 
CREATE TABLE t1 (
 
112
CREATE TEMPORARY TABLE t1 (
228
113
  id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
229
 
  c1 CHAR(150),
230
 
  c2 CHAR(150),
231
 
  c3 CHAR(150),
 
114
  c1 CHAR(50),
 
115
  c2 CHAR(50),
 
116
  c3 CHAR(50),
232
117
  KEY(c1, c2, c3)
233
118
  ) ENGINE= MyISAM;
234
119
INSERT INTO t1 (c1, c2, c3) VALUES
238
123
  ('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'),
239
124
  ('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'),
240
125
  ('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z');
241
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
242
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
243
 
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t1;
 
126
CREATE TABLE t2 AS SELECT * FROM t1;
 
127
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
 
128
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
 
129
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
244
130
CHECK TABLE t1;
245
131
SHOW VARIABLES LIKE 'key_cache_block_size';
246
132
SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size;
247
 
DROP TABLE t1;
 
133
DROP TABLE t1,t2;
248
134
 
249
135
# End of 4.1 tests