| 1 |
# |
| 2 |
# wl#7277: InnoDB: Bulk Load for Create Index |
| 3 |
# |
| 4 |
|
| 5 |
|
| 6 |
# This test case needs to crash the server. Needs a debug server. |
| 7 |
-- source include/have_debug.inc |
| 8 |
|
| 9 |
# Don't test this under valgrind, memory leaks will occur. |
| 10 |
-- source include/not_valgrind.inc |
| 11 |
|
| 12 |
# Avoid CrashReporter popup on Mac |
| 13 |
-- source include/not_crashrep.inc |
| 14 |
|
| 15 |
|
| 16 |
# Create Insert Procedure |
| 17 |
DELIMITER |; |
| 18 |
CREATE PROCEDURE populate_t1() |
| 19 |
BEGIN |
| 20 |
DECLARE i int DEFAULT 1; |
| 21 |
|
| 22 |
START TRANSACTION; |
| 23 |
WHILE (i <= 10000) DO |
| 24 |
INSERT INTO t1 VALUES (i, i, CONCAT('a', i)); |
| 25 |
SET i = i + 1; |
| 26 |
END WHILE; |
| 27 |
COMMIT; |
| 28 |
END| |
| 29 |
DELIMITER ;| |
| 30 |
|
| 31 |
# Test scenarios: |
| 32 |
# 1. Test restart; |
| 33 |
# 2. Test crash recovery. |
| 34 |
|
| 35 |
# Test Restart |
| 36 |
if ($row_format != 'COMPRESSED') |
| 37 |
{ |
| 38 |
eval CREATE TABLE t1( |
| 39 |
class INT, |
| 40 |
id INT, |
| 41 |
title VARCHAR(100) |
| 42 |
) ENGINE=InnoDB ROW_FORMAT=$row_format; |
| 43 |
} |
| 44 |
|
| 45 |
if ($row_format == 'COMPRESSED') |
| 46 |
{ |
| 47 |
SET GLOBAL innodb_file_per_table=1; |
| 48 |
|
| 49 |
eval CREATE TABLE t1( |
| 50 |
class INT, |
| 51 |
id INT, |
| 52 |
title VARCHAR(100) |
| 53 |
) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4; |
| 54 |
} |
| 55 |
|
| 56 |
-- disable_query_log |
| 57 |
CALL populate_t1(); |
| 58 |
-- enable_query_log |
| 59 |
|
| 60 |
SELECT COUNT(*) FROM t1; |
| 61 |
|
| 62 |
CREATE INDEX idx_title ON t1(title); |
| 63 |
|
| 64 |
--source include/restart_mysqld.inc |
| 65 |
|
| 66 |
CHECK TABLE t1; |
| 67 |
|
| 68 |
SELECT * FROM t1 WHERE title = 'a10'; |
| 69 |
|
| 70 |
SELECT * FROM t1 WHERE title = 'a5000'; |
| 71 |
|
| 72 |
SELECT * FROM t1 WHERE title = 'a10000'; |
| 73 |
|
| 74 |
SELECT * FROM t1 WHERE title = 'a10010'; |
| 75 |
|
| 76 |
DROP TABLE t1; |
| 77 |
|
| 78 |
-- echo # Test Blob |
| 79 |
|
| 80 |
if ($row_format != 'COMPRESSED') { |
| 81 |
eval CREATE TABLE t1( |
| 82 |
a INT PRIMARY KEY, |
| 83 |
b TEXT, |
| 84 |
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format; |
| 85 |
} |
| 86 |
|
| 87 |
if ($row_format == 'COMPRESSED') { |
| 88 |
SET GLOBAL innodb_file_per_table=1; |
| 89 |
|
| 90 |
eval CREATE TABLE t1( |
| 91 |
a INT PRIMARY KEY, |
| 92 |
b TEXT, |
| 93 |
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4; |
| 94 |
} |
| 95 |
|
| 96 |
INSERT INTO t1 VALUES |
| 97 |
(1, REPEAT('a',10000), 'a'), |
| 98 |
(2, REPEAT('b',20000), 'b'), |
| 99 |
(3, REPEAT('c',40000), 'c'), |
| 100 |
(4, REPEAT('d',60000), 'd'); |
| 101 |
|
| 102 |
SELECT CHAR_LENGTH(b) FROM t1; |
| 103 |
|
| 104 |
ALTER TABLE t1 DROP COLUMN c; |
| 105 |
|
| 106 |
--source include/restart_mysqld.inc |
| 107 |
|
| 108 |
CHECK TABLE t1; |
| 109 |
|
| 110 |
SELECT CHAR_LENGTH(b) FROM t1; |
| 111 |
|
| 112 |
DROP TABLE t1; |
| 113 |
|
| 114 |
# Test Crash Recovery |
| 115 |
|
| 116 |
# |
| 117 |
# The below part of test was disabled until InnoDB truly supports DDL |
| 118 |
# atomicity/WL#9536 is implemented. Otherwise the test creates discrepancy |
| 119 |
# between SQL-layer DD and InnoDB DD. |
| 120 |
# |
| 121 |
|
| 122 |
--disable_testcase BUG#0000 |
| 123 |
|
| 124 |
if ($row_format != 'COMPRESSED') |
| 125 |
{ |
| 126 |
eval CREATE TABLE t1( |
| 127 |
class INT, |
| 128 |
id INT, |
| 129 |
title VARCHAR(100) |
| 130 |
) ENGINE=InnoDB ROW_FORMAT=$row_format; |
| 131 |
} |
| 132 |
|
| 133 |
if ($row_format == 'COMPRESSED') |
| 134 |
{ |
| 135 |
SET GLOBAL innodb_file_per_table=1; |
| 136 |
|
| 137 |
eval CREATE TABLE t1( |
| 138 |
class INT, |
| 139 |
id INT, |
| 140 |
title VARCHAR(100) |
| 141 |
) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4; |
| 142 |
} |
| 143 |
|
| 144 |
-- disable_query_log |
| 145 |
CALL populate_t1(); |
| 146 |
-- enable_query_log |
| 147 |
|
| 148 |
SET SESSION debug="+d,crash_after_index_create"; |
| 149 |
|
| 150 |
# Write file to make mysql-test-run.pl start up the server again |
| 151 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 152 |
|
| 153 |
--error 2013 |
| 154 |
CREATE INDEX idx_title ON t1(title); |
| 155 |
|
| 156 |
--enable_reconnect |
| 157 |
--source include/wait_until_connected_again.inc |
| 158 |
--disable_reconnect |
| 159 |
|
| 160 |
SELECT COUNT(*) FROM t1; |
| 161 |
|
| 162 |
CHECK TABLE t1; |
| 163 |
|
| 164 |
EXPLAIN SELECT * FROM t1 WHERE title = 'a10'; |
| 165 |
|
| 166 |
SELECT * FROM t1 WHERE title = 'a10'; |
| 167 |
|
| 168 |
SELECT * FROM t1 WHERE title = 'a5000'; |
| 169 |
|
| 170 |
SELECT * FROM t1 WHERE title = 'a10000'; |
| 171 |
|
| 172 |
SELECT * FROM t1 WHERE title = 'a10010'; |
| 173 |
|
| 174 |
DROP TABLE t1; |
| 175 |
|
| 176 |
-- echo # Test Blob |
| 177 |
|
| 178 |
if ($row_format != 'COMPRESSED') { |
| 179 |
eval CREATE TABLE t1( |
| 180 |
a INT PRIMARY KEY, |
| 181 |
b TEXT, |
| 182 |
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format; |
| 183 |
} |
| 184 |
|
| 185 |
if ($row_format == 'COMPRESSED') { |
| 186 |
SET GLOBAL innodb_file_per_table=1; |
| 187 |
|
| 188 |
eval CREATE TABLE t1( |
| 189 |
a INT PRIMARY KEY, |
| 190 |
b TEXT, |
| 191 |
c TEXT) ENGINE=InnoDB ROW_FORMAT=$row_format KEY_BLOCK_SIZE=4; |
| 192 |
} |
| 193 |
|
| 194 |
INSERT INTO t1 VALUES |
| 195 |
(1, REPEAT('a',10000), 'a'), |
| 196 |
(2, REPEAT('b',20000), 'b'), |
| 197 |
(3, REPEAT('c',40000), 'c'), |
| 198 |
(4, REPEAT('d',60000), 'd'); |
| 199 |
|
| 200 |
SELECT CHAR_LENGTH(b) FROM t1; |
| 201 |
|
| 202 |
SET SESSION debug="+d,crash_after_index_create"; |
| 203 |
|
| 204 |
# Write file to make mysql-test-run.pl start up the server again |
| 205 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 206 |
|
| 207 |
--error 2013 |
| 208 |
ALTER TABLE t1 DROP COLUMN c; |
| 209 |
|
| 210 |
--enable_reconnect |
| 211 |
--source include/wait_until_connected_again.inc |
| 212 |
--disable_reconnect |
| 213 |
|
| 214 |
CHECK TABLE t1; |
| 215 |
|
| 216 |
SELECT CHAR_LENGTH(b) FROM t1; |
| 217 |
|
| 218 |
DROP TABLE t1; |
| 219 |
|
| 220 |
--enable_testcase |
| 221 |
|
| 222 |
# Restore global variables |
| 223 |
if ($row_format == 'COMPRESSED') |
| 224 |
{ |
| 225 |
SET GLOBAL innodb_file_per_table=default; |
| 226 |
} |
| 227 |
|
| 228 |
DROP PROCEDURE populate_t1; |