| 1 |
CREATE TABLE t1 ( |
| 2 |
a char(10) NOT NULL primary key, |
| 3 |
b int not null, |
| 4 |
unique (a,b), |
| 5 |
key(b, a) |
| 6 |
) comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RP_BY_NODE' ENGINE=ndbcluster; |
| 7 |
drop table t1; |
| 8 |
CREATE TABLE t1 ( |
| 9 |
a char(10) NOT NULL primary key, |
| 10 |
b int not null, |
| 11 |
unique (a,b), |
| 12 |
key(b, a) |
| 13 |
) comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RP_BY_LDM' ENGINE=ndbcluster; |
| 14 |
drop table t1; |
| 15 |
CREATE TABLE t1 ( |
| 16 |
a char(10) NOT NULL primary key, |
| 17 |
b int not null, |
| 18 |
unique (a,b), |
| 19 |
key(b, a) |
| 20 |
) comment='NDB_TABLE=FULLY_REPLICATED=1' ENGINE=ndbcluster; |
| 21 |
show create table t1; |
| 22 |
Table Create Table |
| 23 |
t1 CREATE TABLE `t1` ( |
| 24 |
`a` char(10) NOT NULL, |
| 25 |
`b` int NOT NULL, |
| 26 |
PRIMARY KEY (`a`), |
| 27 |
UNIQUE KEY `a` (`a`,`b`), |
| 28 |
KEY `b` (`b`,`a`) |
| 29 |
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='NDB_TABLE=FULLY_REPLICATED=1' |
| 30 |
-- t1 -- |
| 31 |
Version: Any |
| 32 |
Fragment type: HashMapPartition |
| 33 |
K Value: 6 |
| 34 |
Min load factor: 78 |
| 35 |
Max load factor: 80 |
| 36 |
Temporary table: no |
| 37 |
Number of attributes: 2 |
| 38 |
Number of primary keys: 1 |
| 39 |
Length of frm data: XXX |
| 40 |
Max Rows: 0 |
| 41 |
Row Checksum: 1 |
| 42 |
Row GCI: 1 |
| 43 |
SingleUserMode: 0 |
| 44 |
ForceVarPart: 1 |
| 45 |
PartitionCount: 4 |
| 46 |
FragmentCount: 16 |
| 47 |
PartitionBalance: FOR_RP_BY_LDM |
| 48 |
ExtraRowGciBits: 0 |
| 49 |
ExtraRowAuthorBits: 0 |
| 50 |
TableStatus: Retrieved |
| 51 |
Table options: readbackup, fullyreplicated |
| 52 |
HashMap: DEFAULT-HASHMAP-3840-4 |
| 53 |
-- Attributes -- |
| 54 |
a Char(40;utf8mb4_0900_ai_ci) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY |
| 55 |
b Int NOT NULL AT=FIXED ST=MEMORY |
| 56 |
-- Indexes -- |
| 57 |
PRIMARY KEY(a) - UniqueHashIndex |
| 58 |
PRIMARY(a) - OrderedIndex |
| 59 |
a(a, b) - OrderedIndex |
| 60 |
a$unique(a, b) - UniqueHashIndex |
| 61 |
b(b, a) - OrderedIndex |
| 62 |
insert into t1 values |
| 63 |
('1',1), ('2',2), ('3',3), ('4',4), |
| 64 |
('5',5), ('6',6), ('7',7), ('8',8); |
| 65 |
select * from t1; |
| 66 |
a b |
| 67 |
1 1 |
| 68 |
2 2 |
| 69 |
3 3 |
| 70 |
4 4 |
| 71 |
5 5 |
| 72 |
6 6 |
| 73 |
7 7 |
| 74 |
8 8 |
| 75 |
create temporary table counters_at_startup |
| 76 |
select counter_name, sum(val) as val |
| 77 |
from ndbinfo.counters |
| 78 |
group by counter_name; |
| 79 |
select * from t1 where a = '1'; |
| 80 |
a b |
| 81 |
1 1 |
| 82 |
select * from t1 where a = '2'; |
| 83 |
a b |
| 84 |
2 2 |
| 85 |
select * from t1 where a = '3'; |
| 86 |
a b |
| 87 |
3 3 |
| 88 |
select s1.counter_name, s2.val - s1.val as diff |
| 89 |
from counters_at_startup s1, |
| 90 |
(select counter_name, sum(val) as val |
| 91 |
from ndbinfo.counters |
| 92 |
group by counter_name) s2 |
| 93 |
where s1.counter_name = s2.counter_name |
| 94 |
and ( s1.counter_name = 'LOCAL_READS' or s1.counter_name = 'READS' ) |
| 95 |
order by 1; |
| 96 |
counter_name diff |
| 97 |
LOCAL_READS 3 |
| 98 |
READS 3 |
| 99 |
drop table counters_at_startup; |
| 100 |
alter table t1 algorithm=inplace, reorganize partition; |
| 101 |
alter table t1 algorithm=inplace, add partition partitions 1; |
| 102 |
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Can't add partition to fully replicated table. Try ALGORITHM=COPY. |
| 103 |
alter table t1 algorithm=copy, add partition partitions 1; |
| 104 |
ERROR HY000: Can't create destination table for copying alter table (use SHOW WARNINGS for more info). |
| 105 |
alter table t1 algorithm=inplace, add column c int column_format dynamic; |
| 106 |
show create table t1; |
| 107 |
Table Create Table |
| 108 |
t1 CREATE TABLE `t1` ( |
| 109 |
`a` char(10) NOT NULL, |
| 110 |
`b` int NOT NULL, |
| 111 |
`c` int /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL, |
| 112 |
PRIMARY KEY (`a`), |
| 113 |
UNIQUE KEY `a` (`a`,`b`), |
| 114 |
KEY `b` (`b`,`a`) |
| 115 |
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='NDB_TABLE=FULLY_REPLICATED=1' |
| 116 |
-- t1 -- |
| 117 |
Version: Any |
| 118 |
Fragment type: HashMapPartition |
| 119 |
K Value: 6 |
| 120 |
Min load factor: 78 |
| 121 |
Max load factor: 80 |
| 122 |
Temporary table: no |
| 123 |
Number of attributes: 3 |
| 124 |
Number of primary keys: 1 |
| 125 |
Length of frm data: XXX |
| 126 |
Max Rows: 0 |
| 127 |
Row Checksum: 1 |
| 128 |
Row GCI: 1 |
| 129 |
SingleUserMode: 0 |
| 130 |
ForceVarPart: 1 |
| 131 |
PartitionCount: 4 |
| 132 |
FragmentCount: 16 |
| 133 |
PartitionBalance: FOR_RP_BY_LDM |
| 134 |
ExtraRowGciBits: 0 |
| 135 |
ExtraRowAuthorBits: 0 |
| 136 |
TableStatus: Retrieved |
| 137 |
Table options: readbackup, fullyreplicated |
| 138 |
HashMap: DEFAULT-HASHMAP-3840-4 |
| 139 |
-- Attributes -- |
| 140 |
a Char(40;utf8mb4_0900_ai_ci) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY |
| 141 |
b Int NOT NULL AT=FIXED ST=MEMORY |
| 142 |
c Int NULL AT=FIXED ST=MEMORY DYNAMIC |
| 143 |
-- Indexes -- |
| 144 |
PRIMARY KEY(a) - UniqueHashIndex |
| 145 |
PRIMARY(a) - OrderedIndex |
| 146 |
a(a, b) - OrderedIndex |
| 147 |
a$unique(a, b) - UniqueHashIndex |
| 148 |
b(b, a) - OrderedIndex |
| 149 |
alter table t1 algorithm=copy, comment='NDB_TABLE='; |
| 150 |
ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'Syntax error in COMMENT modifier' |
| 151 |
alter table t1 algorithm=copy, comment='NDB_TABLE=READ_BACKUP=1'; |
| 152 |
show create table t1; |
| 153 |
Table Create Table |
| 154 |
t1 CREATE TABLE `t1` ( |
| 155 |
`a` char(10) NOT NULL, |
| 156 |
`b` int NOT NULL, |
| 157 |
`c` int /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL, |
| 158 |
PRIMARY KEY (`a`), |
| 159 |
UNIQUE KEY `a` (`a`,`b`), |
| 160 |
KEY `b` (`b`,`a`) |
| 161 |
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='NDB_TABLE=READ_BACKUP=1,FULLY_REPLICATED=1' |
| 162 |
-- t1 -- |
| 163 |
Version: Any |
| 164 |
Fragment type: HashMapPartition |
| 165 |
K Value: 6 |
| 166 |
Min load factor: 78 |
| 167 |
Max load factor: 80 |
| 168 |
Temporary table: no |
| 169 |
Number of attributes: 3 |
| 170 |
Number of primary keys: 1 |
| 171 |
Length of frm data: XXX |
| 172 |
Max Rows: 0 |
| 173 |
Row Checksum: 1 |
| 174 |
Row GCI: 1 |
| 175 |
SingleUserMode: 0 |
| 176 |
ForceVarPart: 1 |
| 177 |
PartitionCount: 4 |
| 178 |
FragmentCount: 16 |
| 179 |
PartitionBalance: FOR_RP_BY_LDM |
| 180 |
ExtraRowGciBits: 0 |
| 181 |
ExtraRowAuthorBits: 0 |
| 182 |
TableStatus: Retrieved |
| 183 |
Table options: readbackup, fullyreplicated |
| 184 |
HashMap: DEFAULT-HASHMAP-3840-4 |
| 185 |
-- Attributes -- |
| 186 |
a Char(40;utf8mb4_0900_ai_ci) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY |
| 187 |
b Int NOT NULL AT=FIXED ST=MEMORY |
| 188 |
c Int NULL AT=FIXED ST=MEMORY DYNAMIC |
| 189 |
-- Indexes -- |
| 190 |
PRIMARY KEY(a) - UniqueHashIndex |
| 191 |
PRIMARY(a) - OrderedIndex |
| 192 |
a(a, b) - OrderedIndex |
| 193 |
a$unique(a, b) - UniqueHashIndex |
| 194 |
b(b, a) - OrderedIndex |
| 195 |
alter table t1 algorithm=copy, comment='NDB_TABLE=FULLY_REPLICATED=1'; |
| 196 |
show create table t1; |
| 197 |
Table Create Table |
| 198 |
t1 CREATE TABLE `t1` ( |
| 199 |
`a` char(10) NOT NULL, |
| 200 |
`b` int NOT NULL, |
| 201 |
`c` int /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL, |
| 202 |
PRIMARY KEY (`a`), |
| 203 |
UNIQUE KEY `a` (`a`,`b`), |
| 204 |
KEY `b` (`b`,`a`) |
| 205 |
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='NDB_TABLE=READ_BACKUP=1,FULLY_REPLICATED=1' |
| 206 |
-- t1 -- |
| 207 |
Version: Any |
| 208 |
Fragment type: HashMapPartition |
| 209 |
K Value: 6 |
| 210 |
Min load factor: 78 |
| 211 |
Max load factor: 80 |
| 212 |
Temporary table: no |
| 213 |
Number of attributes: 3 |
| 214 |
Number of primary keys: 1 |
| 215 |
Length of frm data: XXX |
| 216 |
Max Rows: 0 |
| 217 |
Row Checksum: 1 |
| 218 |
Row GCI: 1 |
| 219 |
SingleUserMode: 0 |
| 220 |
ForceVarPart: 1 |
| 221 |
PartitionCount: 4 |
| 222 |
FragmentCount: 16 |
| 223 |
PartitionBalance: FOR_RP_BY_LDM |
| 224 |
ExtraRowGciBits: 0 |
| 225 |
ExtraRowAuthorBits: 0 |
| 226 |
TableStatus: Retrieved |
| 227 |
Table options: readbackup, fullyreplicated |
| 228 |
HashMap: DEFAULT-HASHMAP-3840-4 |
| 229 |
-- Attributes -- |
| 230 |
a Char(40;utf8mb4_0900_ai_ci) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY |
| 231 |
b Int NOT NULL AT=FIXED ST=MEMORY |
| 232 |
c Int NULL AT=FIXED ST=MEMORY DYNAMIC |
| 233 |
-- Indexes -- |
| 234 |
PRIMARY KEY(a) - UniqueHashIndex |
| 235 |
PRIMARY(a) - OrderedIndex |
| 236 |
a(a, b) - OrderedIndex |
| 237 |
a$unique(a, b) - UniqueHashIndex |
| 238 |
b(b, a) - OrderedIndex |
| 239 |
alter table t1 algorithm=copy, comment='comment text'; |
| 240 |
-- t1 -- |
| 241 |
Version: Any |
| 242 |
Fragment type: HashMapPartition |
| 243 |
K Value: 6 |
| 244 |
Min load factor: 78 |
| 245 |
Max load factor: 80 |
| 246 |
Temporary table: no |
| 247 |
Number of attributes: 3 |
| 248 |
Number of primary keys: 1 |
| 249 |
Length of frm data: XXX |
| 250 |
Max Rows: 0 |
| 251 |
Row Checksum: 1 |
| 252 |
Row GCI: 1 |
| 253 |
SingleUserMode: 0 |
| 254 |
ForceVarPart: 1 |
| 255 |
PartitionCount: 4 |
| 256 |
FragmentCount: 16 |
| 257 |
PartitionBalance: FOR_RP_BY_LDM |
| 258 |
ExtraRowGciBits: 0 |
| 259 |
ExtraRowAuthorBits: 0 |
| 260 |
TableStatus: Retrieved |
| 261 |
Table options: readbackup, fullyreplicated |
| 262 |
HashMap: DEFAULT-HASHMAP-3840-4 |
| 263 |
-- Attributes -- |
| 264 |
a Char(40;utf8mb4_0900_ai_ci) PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY |
| 265 |
b Int NOT NULL AT=FIXED ST=MEMORY |
| 266 |
c Int NULL AT=FIXED ST=MEMORY DYNAMIC |
| 267 |
-- Indexes -- |
| 268 |
PRIMARY KEY(a) - UniqueHashIndex |
| 269 |
PRIMARY(a) - OrderedIndex |
| 270 |
a(a, b) - OrderedIndex |
| 271 |
a$unique(a, b) - UniqueHashIndex |
| 272 |
b(b, a) - OrderedIndex |
| 273 |
show create table t1; |
| 274 |
Table Create Table |
| 275 |
t1 CREATE TABLE `t1` ( |
| 276 |
`a` char(10) NOT NULL, |
| 277 |
`b` int NOT NULL, |
| 278 |
`c` int /*!50606 COLUMN_FORMAT DYNAMIC */ DEFAULT NULL, |
| 279 |
PRIMARY KEY (`a`), |
| 280 |
UNIQUE KEY `a` (`a`,`b`), |
| 281 |
KEY `b` (`b`,`a`) |
| 282 |
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='NDB_TABLE=READ_BACKUP=1,FULLY_REPLICATED=1 comment text' |
| 283 |
drop table t1; |
| 284 |
create table t1 ( |
| 285 |
x int primary key, |
| 286 |
y blob, |
| 287 |
z int, |
| 288 |
unique key (z) |
| 289 |
) engine=ndbcluster; |
| 290 |
alter table t1 algorithm=inplace, comment="NDB_TABLE=FULLY_REPLICATED=1"; |
| 291 |
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Turning FULLY_REPLICATED on after create. Try ALGORITHM=COPY. |
| 292 |
alter table t1 algorithm=copy, comment="NDB_TABLE=FULLY_REPLICATED=1"; |
| 293 |
alter table t1 algorithm=inplace, comment="NDB_TABLE=PARTITION_BALANCE=FOR_RA_BY_LDM"; |
| 294 |
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Changing PARTITION_BALANCE with FULLY_REPLICATED on. Try ALGORITHM=COPY. |
| 295 |
alter table t1 algorithm=inplace, comment="NDB_TABLE=READ_BACKUP=0"; |
| 296 |
ERROR 0A000: Alter table is not supported. Reason: cannot change READ_BACKUP to 0 for fully replicated tables. Try fully_replicated=0 if that is the intention. |
| 297 |
drop table t1; |
| 298 |
CREATE TABLE t2 ( |
| 299 |
a char(10) NOT NULL primary key, |
| 300 |
b int not null, |
| 301 |
unique (a,b), |
| 302 |
key(b, a) |
| 303 |
) comment='NDB_TABLE=FULLY_REPLICATED=1' |
| 304 |
ENGINE=ndbcluster |
| 305 |
partition by key() partitions 2; |
| 306 |
ERROR HY000: Can't create table 't2' (use SHOW WARNINGS for more info). |
| 307 |
show warnings; |
| 308 |
Level Code Message |
| 309 |
Warning 1296 Got error 797 'Wrong fragment count for fully replicated table' from NDB |
| 310 |
Error 1005 Can't create table 't2' (use SHOW WARNINGS for more info). |
| 311 |
CREATE TABLE t2 ( |
| 312 |
a char(10) NOT NULL primary key, |
| 313 |
b int not null, |
| 314 |
unique (a,b), |
| 315 |
key(b, a) |
| 316 |
) comment='NDB_TABLE=FULLY_REPLICATED=1,READ_BACKUP=0' ENGINE=ndbcluster; |
| 317 |
ERROR HY000: Table storage engine 'ndbcluster' does not support the create option 'READ_BACKUP=0 cannot be used for fully replicated tables' |
| 318 |
set session new = 1; |
| 319 |
Warnings: |
| 320 |
Warning 1287 '@@new' is deprecated and will be removed in a future release. |
| 321 |
create table t2 ( |
| 322 |
a char(10) NOT NULL, |
| 323 |
b int not null primary key, |
| 324 |
unique (a,b), |
| 325 |
key(b, a) |
| 326 |
) |
| 327 |
ENGINE=ndbcluster |
| 328 |
comment='NDB_TABLE=FULLY_REPLICATED=1' |
| 329 |
PARTITION BY HASH(b); |
| 330 |
ERROR HY000: Can't create table 't2' (use SHOW WARNINGS for more info). |
| 331 |
create table t1 ( |
| 332 |
a char(10) NOT NULL primary key, |
| 333 |
b int not null) |
| 334 |
ENGINE=ndbcluster; |
| 335 |
alter table t1 algorithm=copy, comment='NDB_TABLE=FULLY_REPLICATED=1,PARTITION_BALANCE=FOR_RA_BY_LDM'; |
| 336 |
drop table t1; |