~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Test of multiple key caches
#
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings

SET @save_key_buffer=@@key_buffer_size;

SELECT @@key_buffer_size;

# Change default key cache size
SET @@global.key_buffer_size=16*1024*1024;

# Drop buffer
SET @@global.key_buffer_size=0;
# Test double drop
SET @@global.key_buffer_size=0;

# Print key buffer with different syntaxes
SHOW VARIABLES like "key_buffer_size";
SELECT @@key_buffer_size;
SELECT @@global.key_buffer_size;
SELECT @@global.key_buffer_size;
SELECT @@global.`key_buffer_size`;
SELECT @@global.`key_buffer_size`;
SELECT @@key_buffer_size;

SELECT @@key_buffer_size;
SELECT @@key_buffer_size;

SET @@global.key_buffer_size=@save_key_buffer;

#
# Errors
#

SELECT @@key_buffer_size;
-- error 1272
SELECT @@skr.storage_engine="test";

-- error 1272
select @@keycache1.key_cache_block_size;

show status like 'key_blocks_used';

# Cleanup
# We don't reset keycache2 as we want to ensure that mysqld will reset it
set global key_buffer_size=0;

# Test to set up a too small size for a key cache (bug #2064)
set global key_buffer_size=100;
set global key_buffer_size=0;

# Restore the changed variable value
-- error 1232
set global key_cache_block_size= @my_key_cache_block_size;

#
# Bug #19079: corrupted index when key_cache_block_size is not multiple of
#             myisam_block_size

CREATE temporary TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MYISAM;
SET @my_key_cache_block_size= @@global.key_cache_block_size;
SET GLOBAL key_cache_block_size=1536;
INSERT INTO t1 VALUES (1);
SELECT @@key_cache_block_size;
CHECK TABLE t1;
DROP TABLE t1;

CREATE TEMPORARY TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
CREATE TEMPORARY TABLE t2(a int NOT NULL AUTO_INCREMENT PRIMARY KEY, b int) ENGINE=MYISAM;
SET GLOBAL key_cache_block_size=1536;
INSERT INTO t1 VALUES (1,0);
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
INSERT INTO t2(b) SELECT b FROM t1;
INSERT INTO t1(b) SELECT b FROM t2;
SELECT COUNT(*) FROM t1;
SELECT @@key_cache_block_size;
CHECK TABLE t1;
DROP TABLE t1,t2;
# Restore changed variables
set global key_cache_block_size= @my_key_cache_block_size;

#
# Bug#10473 - Can't set 'key_buffer_size' system variable to ZERO
# (One cannot drop the default key cache.)
#
set @@global.key_buffer_size=0;
select @@global.key_buffer_size;

#
# Bug#28478 - Improper key_cache_block_size corrupts MyISAM tables
#
SET @bug28478_key_cache_block_size= @@global.key_cache_block_size;
SET GLOBAL key_cache_block_size= 1536;
CREATE TEMPORARY TABLE t1 (
  id BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  c1 CHAR(50),
  c2 CHAR(50),
  c3 CHAR(50),
  KEY(c1, c2, c3)
  ) ENGINE= MyISAM;
INSERT INTO t1 (c1, c2, c3) VALUES
  ('a', 'b', 'c'), ('b', 'c', 'd'), ('c', 'd', 'e'), ('d', 'e', 'f'),
  ('e', 'f', 'g'), ('f', 'g', 'h'), ('g', 'h', 'i'), ('h', 'i', 'j'),
  ('i', 'j', 'k'), ('j', 'k', 'l'), ('k', 'l', 'm'), ('l', 'm', 'n'),
  ('m', 'n', 'o'), ('n', 'o', 'p'), ('o', 'p', 'q'), ('p', 'q', 'r'),
  ('q', 'r', 's'), ('r', 's', 't'), ('s', 't', 'u'), ('t', 'u', 'v'),
  ('u', 'v', 'w'), ('v', 'w', 'x'), ('w', 'x', 'y'), ('x', 'y', 'z');
CREATE TABLE t2 AS SELECT * FROM t1;
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
INSERT INTO t1 (c1, c2, c3) SELECT c1, c2, c3 from t2;
CHECK TABLE t1;
SHOW VARIABLES LIKE 'key_cache_block_size';
SET GLOBAL key_cache_block_size= @bug28478_key_cache_block_size;
DROP TABLE t1,t2;

# End of 4.1 tests