| 1 |
# |
| 2 |
# ALTER ONLINE TABLE |
| 3 |
# |
| 4 |
|
| 5 |
--source have_engine.inc |
| 6 |
|
| 7 |
--disable_warnings |
| 8 |
DROP TABLE IF EXISTS t1,t2,t3; |
| 9 |
--enable_warnings |
| 10 |
|
| 11 |
# |
| 12 |
# Test of things that can be done online |
| 13 |
# We are repeating notification here, because for some engines |
| 14 |
# only a part of these ALTER ONLINE statements might be supported. |
| 15 |
# |
| 16 |
|
| 17 |
let $create_definition = a $int_col, b $int_col, c $char_col; |
| 18 |
--source create_table.inc |
| 19 |
|
| 20 |
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c'); |
| 21 |
|
| 22 |
--let $online = 1 |
| 23 |
--let $alter_definition = MODIFY b $int_col DEFAULT 5 |
| 24 |
--source alter_table.inc |
| 25 |
if ($mysql_errname) |
| 26 |
{ |
| 27 |
--source unexpected_result.inc |
| 28 |
} |
| 29 |
|
| 30 |
--let $online = 1 |
| 31 |
--let $alter_definition = CHANGE b new_name $int_col |
| 32 |
--source alter_table.inc |
| 33 |
if ($mysql_errname) |
| 34 |
{ |
| 35 |
--source unexpected_result.inc |
| 36 |
} |
| 37 |
|
| 38 |
--let $online = 1 |
| 39 |
--let $alter_definition = COMMENT 'new comment' |
| 40 |
--source alter_table.inc |
| 41 |
if ($mysql_errname) |
| 42 |
{ |
| 43 |
--source unexpected_result.inc |
| 44 |
} |
| 45 |
|
| 46 |
# It is here because it used to be supported as ALTER ONLINE, |
| 47 |
# but not anymore after the semantics changed in 10.0 |
| 48 |
# to be the same as ALTER .. LOCK=NONE |
| 49 |
|
| 50 |
--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED |
| 51 |
--let $online = 1 |
| 52 |
--let $rename_to = t2 |
| 53 |
--source alter_table.inc |
| 54 |
if ($mysql_errname!=ER_ALTER_OPERATION_NOT_SUPPORTED) |
| 55 |
{ |
| 56 |
--source unexpected_result.inc |
| 57 |
DROP TABLE t1; |
| 58 |
} |
| 59 |
DROP TABLE IF EXISTS t2; |
| 60 |
|
| 61 |
# |
| 62 |
# temporary table does not require locking |
| 63 |
# |
| 64 |
|
| 65 |
--let $temporary = 1 |
| 66 |
--source create_table.inc |
| 67 |
|
| 68 |
INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'); |
| 69 |
|
| 70 |
--let $online = 1 |
| 71 |
--let $alter_definition = MODIFY b $int_col DEFAULT 5 |
| 72 |
--source alter_table.inc |
| 73 |
if ($mysql_errname) |
| 74 |
{ |
| 75 |
--source unexpected_result.inc |
| 76 |
} |
| 77 |
|
| 78 |
--let $online = 1 |
| 79 |
--let $alter_definition = CHANGE b new_name $int_col |
| 80 |
--source alter_table.inc |
| 81 |
|
| 82 |
--let $online = 1 |
| 83 |
--let $alter_definition = COMMENT 'new comment' |
| 84 |
--source alter_table.inc |
| 85 |
|
| 86 |
--let $online = 1 |
| 87 |
--let $rename_to = t2 |
| 88 |
--source alter_table.inc |
| 89 |
|
| 90 |
DROP TABLE IF EXISTS t1, t2; |
| 91 |
|
| 92 |
# |
| 93 |
# Test of things that is not possible to do online |
| 94 |
# |
| 95 |
|
| 96 |
--let $create_definition = a $int_col, b $int_col, c $char_col |
| 97 |
--source create_table.inc |
| 98 |
|
| 99 |
INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c'); |
| 100 |
|
| 101 |
# It is here because it used to unsupported as ALTER ONLINE, |
| 102 |
# but is supported now after the semantics changed in 10.0 |
| 103 |
# to be the same as ALTER .. LOCK=NONE |
| 104 |
|
| 105 |
--let $online = 1 |
| 106 |
--let $alter_definition = DROP COLUMN b, ADD b $int_col |
| 107 |
--source alter_table.inc |
| 108 |
if ($mysql_errname) |
| 109 |
{ |
| 110 |
--source unexpected_result.inc |
| 111 |
} |
| 112 |
|
| 113 |
--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 114 |
--let $online = 1 |
| 115 |
--let $alter_definition = MODIFY b BIGINT $default_col_opts |
| 116 |
--source alter_table.inc |
| 117 |
|
| 118 |
--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine IN ('MEMORY','MyISAM') AND engine != '$storage_engine' ORDER BY engine LIMIT 1` |
| 119 |
|
| 120 |
--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 121 |
--let $online = 1 |
| 122 |
--let $alter_definition = ENGINE=$alternative_engine |
| 123 |
--source alter_table.inc |
| 124 |
|
| 125 |
DROP TABLE t1; |
| 126 |
|
| 127 |
--let $create_definition = a $int_col, b $int_indexed_col, c $char_col |
| 128 |
--source create_table.inc |
| 129 |
if ($mysql_errname) |
| 130 |
{ |
| 131 |
--let $functionality = Column options |
| 132 |
--source unexpected_result.inc |
| 133 |
} |
| 134 |
if (!$mysql_errname) |
| 135 |
{ |
| 136 |
|
| 137 |
# It is here because it used to unsupported as ALTER ONLINE, |
| 138 |
# but is supported now after the semantics changed in 10.0 |
| 139 |
# to be the same as ALTER .. LOCK=NONE |
| 140 |
|
| 141 |
--let $online = 1 |
| 142 |
--let $alter_definition = ADD INDEX (b) |
| 143 |
--source alter_table.inc |
| 144 |
if ($mysql_errname) |
| 145 |
{ |
| 146 |
--let $functionality = Adding an index or ALTER ONLINE |
| 147 |
--source unexpected_result.inc |
| 148 |
} |
| 149 |
if (!$mysql_errname) |
| 150 |
{ |
| 151 |
--let $online = 1 |
| 152 |
--let $alter_definition = DROP INDEX b |
| 153 |
--source alter_table.inc |
| 154 |
} |
| 155 |
DROP TABLE t1; |
| 156 |
} |
| 157 |
|
| 158 |
--source cleanup_engine.inc |