8
8
SET @save_key_buffer=@@key_buffer_size;
10
SELECT @@key_buffer_size, @@small.key_buffer_size;
10
SELECT @@key_buffer_size;
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;
17
SET @@global.small.key_buffer_size=1*1024*1024;
18
SET @@global.medium.key_buffer_size=4*1024*1024;
20
SET @@global.medium.key_buffer_size=0;
16
SET @@global.key_buffer_size=0;
22
SET @@global.medium.key_buffer_size=0;
18
SET @@global.key_buffer_size=0;
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;
33
SELECT @@small.key_buffer_size;
34
SELECT @@medium.key_buffer_size;
29
SELECT @@key_buffer_size;
30
SELECT @@key_buffer_size;
36
32
SET @@global.key_buffer_size=@save_key_buffer;
43
SELECT @@default.key_buffer_size;
38
SELECT @@key_buffer_size;
45
40
SELECT @@skr.storage_engine="test";
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;
64
set global keycache1.key_buffer_size=1024*1024;
66
create temporary table t1 (p int primary key, a char(10)) delay_key_write=1 ENGINE=myisam;
67
create temporary table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a)) ENGINE=myisam;
69
show status like 'key_blocks_used';
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
74
--replace_result 837 KEY_BLOCKS_UNUSED 906 KEY_BLOCKS_UNUSED 896 KEY_BLOCKS_UNUSED
75
show status like 'key_blocks_unused';
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');
83
update t1 set p=2 where p=1;
84
update t2 set i=2 where i=1;
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';
90
cache index t1 key (`primary`) in keycache1;
92
explain select p from t1;
94
explain 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;
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';
106
explain select p from t2;
108
explain select i from t2;
110
explain select a from t2;
113
# Test some error conditions
115
cache index t1 in unknown_key_cache;
116
cache index t1 key (unknown_key) in keycache1;
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;
126
update t2 set p=4000 where a='zzzz';
129
set global keycache1.key_buffer_size=0;
132
explain select i from t2;
134
explain select a from t2;
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;
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';
43
select @@keycache1.key_cache_block_size;
45
show status like 'key_blocks_used';
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;
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;
52
set global key_buffer_size=100;
53
set global key_buffer_size=0;
161
55
# Restore the changed variable value