| 1 |
# |
| 2 |
# ENABLE KEYS / DISABLE KEYS |
| 3 |
# |
| 4 |
|
| 5 |
--source have_engine.inc |
| 6 |
--source have_default_index.inc |
| 7 |
|
| 8 |
--disable_warnings |
| 9 |
DROP TABLE IF EXISTS t1; |
| 10 |
--enable_warnings |
| 11 |
|
| 12 |
|
| 13 |
--let $create_definition = a $int_indexed_col, $default_index(a) |
| 14 |
--source create_table.inc |
| 15 |
INSERT INTO t1 (a) VALUES (10); |
| 16 |
|
| 17 |
INSERT INTO t1 (a) VALUES |
| 18 |
(1),(2),(3),(4),(5),(6),(7),(8),(9), |
| 19 |
(21),(22),(23),(24),(25),(26),(27),(28),(29); |
| 20 |
# Plan should use the index. |
| 21 |
# Masking the `rows` column as the value might vary a bit |
| 22 |
--replace_column 9 # |
| 23 |
EXPLAIN SELECT a FROM t1 ORDER BY a; |
| 24 |
|
| 25 |
--replace_column 6 # 7 # |
| 26 |
SHOW INDEX IN t1; |
| 27 |
|
| 28 |
--let $alter_definition = DISABLE KEYS |
| 29 |
--source alter_table.inc |
| 30 |
if ($mysql_errname) |
| 31 |
{ |
| 32 |
--let $my_last_stmt = $alter_statement |
| 33 |
--let $functionality = ALTER .. DISABLE KEYS |
| 34 |
--source unexpected_result.inc |
| 35 |
} |
| 36 |
|
| 37 |
# Now comment should say 'disabled' |
| 38 |
--replace_column 6 # 7 # |
| 39 |
SHOW INDEX IN t1; |
| 40 |
|
| 41 |
# And the plan should not use the index |
| 42 |
EXPLAIN SELECT a FROM t1 ORDER BY a; |
| 43 |
INSERT INTO t1 (a) VALUES |
| 44 |
(11),(12),(13),(14),(15),(16),(17),(18),(19),(20); |
| 45 |
|
| 46 |
# The index should be back active |
| 47 |
--let $alter_definition = ENABLE KEYS |
| 48 |
--source alter_table.inc |
| 49 |
--replace_column 6 # 7 # |
| 50 |
SHOW INDEX IN t1; |
| 51 |
--replace_column 9 # |
| 52 |
EXPLAIN SELECT a FROM t1 ORDER BY a; |
| 53 |
|
| 54 |
DROP TABLE t1; |
| 55 |
|
| 56 |
--let $create_definition = a $int_indexed_col, UNIQUE INDEX(a) |
| 57 |
--source create_table.inc |
| 58 |
if ($mysql_errname) |
| 59 |
{ |
| 60 |
--let $my_last_stmt = $create_statement |
| 61 |
--let $functionality = Unique keys |
| 62 |
--source unexpected_result.inc |
| 63 |
} |
| 64 |
if (!$mysql_errname) |
| 65 |
{ |
| 66 |
INSERT INTO t1 (a) VALUES |
| 67 |
(1),(2),(3),(4),(5),(6),(7),(8),(9), |
| 68 |
(21),(22),(23),(24),(25),(26),(27),(28),(29); |
| 69 |
|
| 70 |
# For unique indexes DISABLE KEYS has no effect |
| 71 |
|
| 72 |
--let $alter_definition = DISABLE KEYS |
| 73 |
--source alter_table.inc |
| 74 |
--let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY |
| 75 |
INSERT INTO t1 (a) VALUES (29); |
| 76 |
--source check_errors.inc |
| 77 |
--replace_column 6 # 7 # |
| 78 |
SHOW INDEX IN t1; |
| 79 |
--replace_column 9 # |
| 80 |
EXPLAIN SELECT a FROM t1 ORDER BY a; |
| 81 |
|
| 82 |
DROP TABLE t1; |
| 83 |
} |
| 84 |
|
| 85 |
# Cleanup |
| 86 |
|
| 87 |
--source cleanup_engine.inc |
| 88 |
|