| 1 |
# Create t3 with MAX_ROWS set |
| 2 |
let $t3_table_options = MAX_ROWS=333333; |
| 3 |
# and t2 with partition balance FOR_RP_BY_NODE |
| 4 |
let $t2_table_options = COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_NODE"; |
| 5 |
--source setup.inc |
| 6 |
|
| 7 |
# |
| 8 |
# Test ALTER TABLE .. MAX_ROWS in combination with tables with |
| 9 |
# or without MAX_ROWS |
| 10 |
# |
| 11 |
|
| 12 |
|
| 13 |
# |
| 14 |
# Check that inplace ALTER TABLE ... MAX_ROWS on a table which does |
| 15 |
# not already have MAX_ROWS set is not allowed. |
| 16 |
# |
| 17 |
|
| 18 |
if (`select LOCATE("max_rows=", CREATE_OPTIONS) |
| 19 |
from information_schema.tables where |
| 20 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't1'`) |
| 21 |
{ |
| 22 |
die t1 has MAX_ROWS set; |
| 23 |
} |
| 24 |
|
| 25 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 26 |
ALTER TABLE t1 |
| 27 |
algorithm=inplace, |
| 28 |
max_rows=1111111; |
| 29 |
|
| 30 |
# |
| 31 |
# Check that copying ALTER TABLE ... MAX_ROWS on a table which does |
| 32 |
# not already have MAX_ROWS set is allowed. |
| 33 |
# |
| 34 |
ALTER TABLE t1 |
| 35 |
algorithm=copy, |
| 36 |
max_rows=1111111; |
| 37 |
|
| 38 |
if (!`select LOCATE("max_rows=", CREATE_OPTIONS) |
| 39 |
from information_schema.tables where |
| 40 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't1'`) |
| 41 |
{ |
| 42 |
die t1 does not have MAX_ROWS set; |
| 43 |
} |
| 44 |
|
| 45 |
# |
| 46 |
# Check that inplace ALTER TABLE ... MAX_ROWS on a table which |
| 47 |
# already have MAX_ROWS set is allowed. |
| 48 |
# |
| 49 |
|
| 50 |
if (!`select LOCATE("max_rows=", CREATE_OPTIONS) |
| 51 |
from information_schema.tables where |
| 52 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`) |
| 53 |
{ |
| 54 |
die t3 does not have MAX_ROWS set; |
| 55 |
} |
| 56 |
|
| 57 |
ALTER TABLE t3 |
| 58 |
algorithm=inplace, |
| 59 |
max_rows=4444444; |
| 60 |
|
| 61 |
if (!`select LOCATE("max_rows=4444444", CREATE_OPTIONS) |
| 62 |
from information_schema.tables where |
| 63 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`) |
| 64 |
{ |
| 65 |
die The value of MAX_ROWS for t3 did not change; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
# |
| 70 |
# Check that copying ALTER TABLE ... MAX_ROWS on a table which |
| 71 |
# already have MAX_ROWS set is allowed. |
| 72 |
# |
| 73 |
|
| 74 |
if (!`select LOCATE("max_rows=", CREATE_OPTIONS) |
| 75 |
from information_schema.tables where |
| 76 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`) |
| 77 |
{ |
| 78 |
die t3 does not have MAX_ROWS set; |
| 79 |
} |
| 80 |
|
| 81 |
ALTER TABLE t3 |
| 82 |
algorithm=copy, |
| 83 |
max_rows=5555555; |
| 84 |
|
| 85 |
if (!`select LOCATE("max_rows=5555555", CREATE_OPTIONS) |
| 86 |
from information_schema.tables where |
| 87 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`) |
| 88 |
{ |
| 89 |
die The value of MAX_ROWS for t3 did not change; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
# |
| 94 |
# Check that inplace ALTER TABLE to reduce MAX_ROWS which does |
| 95 |
# not cause reduction in number of fragments is allowed |
| 96 |
# |
| 97 |
ALTER TABLE t3 |
| 98 |
algorithm=copy, |
| 99 |
max_rows=33333 /* Small enough to get default number of frags */; |
| 100 |
ALTER TABLE t3 |
| 101 |
algorithm=inplace, |
| 102 |
max_rows=33332 /* Small enough to still be at default number of frags */; |
| 103 |
|
| 104 |
--echo Note! The value of MAX_ROWS in NDB is still 33333 |
| 105 |
--let $ndb_describe_db= ndb_ddl_test |
| 106 |
--let $ndb_describe_table= t3 |
| 107 |
--source suite/ndb/include/ndb_describe_table.inc |
| 108 |
|
| 109 |
# |
| 110 |
# Check that inplace ALTER TABLE ... REORGANIZE PARTITION is |
| 111 |
# not allowed when MAX_ROWS is set |
| 112 |
# |
| 113 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 114 |
ALTER TABLE t3 |
| 115 |
algorithm=inplace, |
| 116 |
reorganize partition; |
| 117 |
|
| 118 |
# Check that the inplace ALTER TABLE to set MAX_ROWS to 0 is not allowed |
| 119 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 120 |
ALTER TABLE t3 |
| 121 |
algorithm=inplace, |
| 122 |
max_rows=0; |
| 123 |
|
| 124 |
# Check that copy ALTER TABLE to reset MAX_ROWS to 0 is allowed |
| 125 |
ALTER TABLE t3 |
| 126 |
algorithm=copy, |
| 127 |
max_rows=0; |
| 128 |
|
| 129 |
# Check that MySQL says MAX_ROWS=0 |
| 130 |
if (`select LOCATE("MAX_ROWS=", CREATE_OPTIONS) |
| 131 |
from information_schema.tables where |
| 132 |
TABLE_SCHEMA='ndb_ddl_test' and TABLE_NAME = 't3'`) |
| 133 |
{ |
| 134 |
die MySQL Still reported a MAX_ROWS value for t3; |
| 135 |
} |
| 136 |
|
| 137 |
# Check that online ALTER TABLE .. REORGANIZE is now allowed |
| 138 |
ALTER TABLE t3 |
| 139 |
algorithm=inplace, |
| 140 |
reorganize partition; |
| 141 |
INSERT INTO t3 VALUES(37, "MySQL Cluster", '2015-12-15'); |
| 142 |
SELECT b FROM t3 WHERE a > 10; |
| 143 |
DELETE FROM t3 WHERE a = 37; |
| 144 |
|
| 145 |
# |
| 146 |
# Check that copying ALTER TABLE ... MAX_ROWS=0 yields a table |
| 147 |
# which can be reorganized |
| 148 |
# |
| 149 |
ALTER TABLE t3 |
| 150 |
algorithm=copy, |
| 151 |
max_rows=444444444 /* Large with many frags */; |
| 152 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 153 |
ALTER TABLE t3 |
| 154 |
algorithm=inplace, |
| 155 |
max_rows=0 /* Not allowed since number of frags reduced */; |
| 156 |
ALTER TABLE t3 |
| 157 |
algorithm=copy, |
| 158 |
max_rows=0 /* Back to zero by using copying */; |
| 159 |
|
| 160 |
# |
| 161 |
# Check that inplace ALTER TABLE ... REORGANIZE PARTITION is ok |
| 162 |
# now when the table is back to MAX_ROWS=0 |
| 163 |
# |
| 164 |
ALTER TABLE t3 |
| 165 |
algorithm=inplace, |
| 166 |
reorganize partition; |
| 167 |
INSERT INTO t3 VALUES(37, "MySQL Cluster", '2015-12-15'); |
| 168 |
SELECT b FROM t3 WHERE a > 10; |
| 169 |
DELETE FROM t3 WHERE a = 37; |
| 170 |
|
| 171 |
# |
| 172 |
# Check that inplace ALTER TABLE setting MAX_ROWS to 0 |
| 173 |
# is not allowed in table with user specified partition balance |
| 174 |
# |
| 175 |
ALTER TABLE t2 |
| 176 |
algorithm=copy, |
| 177 |
max_rows=33333; |
| 178 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 179 |
ALTER TABLE t2 |
| 180 |
algorithm=inplace, |
| 181 |
max_rows=0; |
| 182 |
|
| 183 |
# Check that copy ALTER variant is allowed |
| 184 |
ALTER TABLE t2 |
| 185 |
algorithm=copy, |
| 186 |
max_rows=0; |
| 187 |
|
| 188 |
--source verify_mysql_dd.inc |
| 189 |
|
| 190 |
--source cleanup.inc |
| 191 |
|