| 1 |
-- source include/have_ndb.inc |
| 2 |
|
| 3 |
## The comment item values of an existing table should not be ## |
| 4 |
## affected by changing the related global/session variables. ## |
| 5 |
## Show create table will show specified items by the user ## |
| 6 |
## at create or alter table. ## |
| 7 |
## After an alter, previous history of the comment item ## |
| 8 |
## changes should be preserved and will be shown. ## |
| 9 |
## Create table uses current defaults for non-specified items.## |
| 10 |
## If the user changes the default after create for ## |
| 11 |
## non-specified items, the following alter will fail. ## |
| 12 |
|
| 13 |
set @global_fully_replicated=@@global.ndb_fully_replicated; |
| 14 |
set @global_read_backup=@@global.ndb_read_backup; |
| 15 |
|
| 16 |
--echo # Create table with fully_replicated=1 # |
| 17 |
--echo # will change read_backup to 1 implicitly, # |
| 18 |
--echo # but will not be shown in the comment. # |
| 19 |
--echo # This should not affect the following alters # |
| 20 |
|
| 21 |
set global ndb_fully_replicated=1; |
| 22 |
set global ndb_read_backup=0; |
| 23 |
CREATE TABLE t (x int primary key) |
| 24 |
ENGINE=ndbcluster; |
| 25 |
SHOW CREATE TABLE t; |
| 26 |
ALTER TABLE t ALGORITHM=copy, ADD COLUMN y int; |
| 27 |
SHOW CREATE TABLE t; |
| 28 |
DROP TABLE t; |
| 29 |
|
| 30 |
--echo |
| 31 |
--echo # Change the default of read_backup and alter another comment item. # |
| 32 |
--echo # Will fail due to the new default of the non-specified RB # |
| 33 |
set global ndb_fully_replicated=1; |
| 34 |
set global ndb_read_backup=1; |
| 35 |
CREATE TABLE t (x int primary key) |
| 36 |
ENGINE=ndbcluster comment="A comment"; |
| 37 |
set global ndb_read_backup=0; |
| 38 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 39 |
ALTER TABLE t algorithm=copy, comment="NDB_TABLE=NOLOGGING=1"; |
| 40 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 41 |
ALTER TABLE t algorithm=inplace, comment="NDB_TABLE=NOLOGGING=1"; |
| 42 |
SHOW CREATE TABLE t; |
| 43 |
|
| 44 |
--echo |
| 45 |
--echo # Change the default of FR and alter another comment item # |
| 46 |
--echo # Will fail due to the new default of the non-specified FR # |
| 47 |
set global ndb_fully_replicated=0; |
| 48 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 49 |
ALTER TABLE t ALGORITHM=copy, comment="NDB_TABLE=NOLOGGING=0"; |
| 50 |
DROP TABLE t; |
| 51 |
|
| 52 |
--echo |
| 53 |
--echo # Change the default to NL=1 and alter another comment item # |
| 54 |
--echo # Will fail due to the new default of the non-specified NL # |
| 55 |
CREATE TABLE t (x int primary key) |
| 56 |
ENGINE=ndbcluster comment="A comment"; |
| 57 |
set session ndb_table_no_logging=1; |
| 58 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 59 |
ALTER TABLE t algorithm=copy, comment="NDB_TABLE=READ_BACKUP=1"; |
| 60 |
set session ndb_table_no_logging=0; |
| 61 |
ALTER TABLE t algorithm=copy, comment="NDB_TABLE=READ_BACKUP=1"; |
| 62 |
SHOW CREATE TABLE t; |
| 63 |
DROP TABLE t; |
| 64 |
|
| 65 |
--echo |
| 66 |
--echo # Check if alters preserve the values of the other comment items # |
| 67 |
CREATE TABLE t30 (col1 int PRIMARY KEY, col2 int) |
| 68 |
ENGINE=ndb COMMENT="NDB_TABLE=NOLOGGING=1,READ_BACKUP=0"; |
| 69 |
ALTER TABLE t30 ALGORITHM=inplace, |
| 70 |
COMMENT="NDB_TABLE=FULLY_REPLICATED=0"; |
| 71 |
ALTER TABLE t30 ALGORITHM=COPY, |
| 72 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_NODE"; |
| 73 |
SHOW CREATE TABLE t30; |
| 74 |
#--exec $NDB_DESC -dtest t30; |
| 75 |
|
| 76 |
--echo |
| 77 |
--echo # Cannot alter fully replicated tables when read backup=0 # |
| 78 |
--echo # is specified by the user # |
| 79 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 80 |
ALTER TABLE t30 ALGORITHM=inplace, COMMENT="NDB_TABLE=FULLY_REPLICATED=1"; |
| 81 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 82 |
ALTER TABLE t30 ALGORITHM=copy, COMMENT="NDB_TABLE=FULLY_REPLICATED=1"; |
| 83 |
drop table t30; |
| 84 |
|
| 85 |
--echo |
| 86 |
--echo # Even though a table is created with default # |
| 87 |
--echo # ndb_read backup=0, changing FR to 1 # |
| 88 |
--echo # will change it implicitly to 1, but will not be shown # |
| 89 |
set global ndb_read_backup=0; |
| 90 |
CREATE TABLE t30 (col1 int PRIMARY KEY, col2 int) ENGINE=ndb |
| 91 |
COMMENT="NDB_TABLE=NOLOGGING=1"; |
| 92 |
#--exec $NDB_DESC -dtest t30; |
| 93 |
ALTER TABLE t30 ALGORITHM=copy, COMMENT="NDB_TABLE=FULLY_REPLICATED=1"; |
| 94 |
#--exec $NDB_DESC -dtest t30; |
| 95 |
SHOW CREATE TABLE t30; |
| 96 |
|
| 97 |
--echo # Cannot change read_backup to 0 when FR is on # |
| 98 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 99 |
ALTER TABLE t30 algorithm=copy, comment="NDB_TABLE=READ_BACKUP=0"; |
| 100 |
|
| 101 |
drop table t30; |
| 102 |
#--exec $NDB_DESC -dtest t30; |
| 103 |
|
| 104 |
set global ndb_read_backup=1; |
| 105 |
|
| 106 |
--echo |
| 107 |
--echo # Cannot change logging with inplace # |
| 108 |
CREATE TABLE t30 (col1 int PRIMARY KEY, col2 int) |
| 109 |
ENGINE=ndb; |
| 110 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 111 |
ALTER TABLE t30 ALGORITHM=inplace, COMMENT="NDB_TABLE=NOLOGGING=1"; |
| 112 |
ALTER TABLE t30 ALGORITHM=copy, COMMENT="NDB_TABLE=NOLOGGING=1"; |
| 113 |
SHOW CREATE TABLE t30; |
| 114 |
#--exec $NDB_DESC -dtest t30; |
| 115 |
|
| 116 |
--echo |
| 117 |
--echo # Execute some more alters # |
| 118 |
ALTER TABLE t30 ALGORITHM=COPY, |
| 119 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM"; |
| 120 |
#--exec $NDB_DESC -dtest t30; |
| 121 |
ALTER TABLE t30 ALGORITHM=COPY, COMMENT="NDB_TABLE=FULLY_REPLICATED=0"; |
| 122 |
SHOW CREATE TABLE t30; |
| 123 |
#--exec $NDB_DESC -dtest t30; |
| 124 |
|
| 125 |
drop table t30; |
| 126 |
|
| 127 |
--echo |
| 128 |
--echo # Check if changing the comment gives assertion error on fullyreplicated table# |
| 129 |
|
| 130 |
set global ndb_fully_replicated=1; |
| 131 |
set global ndb_read_backup=1; |
| 132 |
|
| 133 |
CREATE TABLE t (x int primary key) |
| 134 |
ENGINE=ndbcluster; |
| 135 |
SHOW CREATE TABLE t; |
| 136 |
ALTER TABLE t ALGORITHM=inplace, comment="A comment"; |
| 137 |
|
| 138 |
SHOW CREATE TABLE t; |
| 139 |
|
| 140 |
--echo |
| 141 |
--echo # Perform an alter of an already existing NDB table option |
| 142 |
ALTER TABLE t ALGORITHM=inplace, comment="NDB_TABLE=READ_BACKUP=1"; |
| 143 |
SHOW CREATE TABLE t; |
| 144 |
DROP TABLE t; |
| 145 |
|
| 146 |
--echo |
| 147 |
--echo # Change PB to the existing value |
| 148 |
CREATE TABLE t (a int primary key) |
| 149 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM" engine=ndb; |
| 150 |
ALTER TABLE t ALGORITHM=inplace, |
| 151 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM"; |
| 152 |
SHOW CREATE TABLE t; |
| 153 |
|
| 154 |
--echo |
| 155 |
--echo # Changing PB to a new value should fail for inplace alter# |
| 156 |
--echo # and pass for copy alter# |
| 157 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 158 |
ALTER TABLE t ALGORITHM=inplace, |
| 159 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM"; |
| 160 |
ALTER TABLE t ALGORITHM=copy, |
| 161 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM"; |
| 162 |
DROP TABLE t; |
| 163 |
|
| 164 |
set global ndb_fully_replicated=@global_fully_replicated; |
| 165 |
set global ndb_read_backup=@global_read_backup; |
| 166 |
|
| 167 |
--echo # |
| 168 |
--echo # BUG#31776392 ALTER TABLE COMMENT HITS ASSERT IN DEBUG BUILD |
| 169 |
--echo # Turning off NOLOGGING is not supported inplace, check that |
| 170 |
--echo # a message with reason why it's not supported is returned |
| 171 |
--echo # |
| 172 |
|
| 173 |
CREATE TABLE t1 (a int PRIMARY KEY) engine=ndbcluster |
| 174 |
COMMENT="NDB_TABLE=NOLOGGING=1,READ_BACKUP=0"; |
| 175 |
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON |
| 176 |
ALTER TABLE t1 ALGORITHM=inplace, COMMENT="NDB_TABLE=NOLOGGING=0"; |
| 177 |
ALTER TABLE t1 COMMENT="NDB_TABLE=NOLOGGING=0"; |
| 178 |
# Other unsupported inplace alter cases are tested earlier in this file |
| 179 |
DROP TABLE t1; |
| 180 |
|
| 181 |
--echo # |
| 182 |
--echo # Test CREATE and ALTER TABLE with unknown PARTITION_BALANCE value |
| 183 |
--echo # - will push warning an silently ignore the modifier |
| 184 |
--echo # |
| 185 |
CREATE TABLE t1 (a int PRIMARY KEY) engine=ndbcluster |
| 186 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=unknown_part_bal"; |
| 187 |
--echo # NOTE! Double warnings from the double parse of comment |
| 188 |
ALTER TABLE t1 ALGORITHM=inplace, |
| 189 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=unknown_part_bal"; |
| 190 |
ALTER TABLE t1 ALGORITHM=copy, |
| 191 |
COMMENT="NDB_TABLE=PARTITION_BALANCE=unknown_part_bal"; |
| 192 |
DROP TABLE t1; |