| 1 |
-- source include/have_ndb.inc |
| 2 |
|
| 3 |
create table t1(id1 int NOT NULL PRIMARY KEY, data char(8), id3 int not null, unique(id3)) engine=ndb |
| 4 |
comment="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM"; |
| 5 |
create table t2(id2 int NOT NULL PRIMARY KEY, id1 int, data char(8), id3 int) engine=ndb |
| 6 |
comment="NDB_TABLE=PARTITION_BALANCE=FOR_RP_BY_LDM"; |
| 7 |
alter table t2 algorithm=inplace, add constraint id1 foreign key (id1) references t1(id1); |
| 8 |
alter table t2 algorithm=inplace, add constraint id3 foreign key (id3) references t1(id3); |
| 9 |
|
| 10 |
load data local infile 'suite/ndb/data/table_data10000.dat' into table t1 fields terminated by ' ' lines terminated by '\n' ignore 900 lines (@id, data) set id1 = @id, id3 = -@id; |
| 11 |
load data local infile 'suite/ndb/data/table_data10000.dat' into table t2 fields terminated by ' ' lines terminated by '\n' ignore 900 lines (@id, data) set id1 = @id, id2 = -@id, id3=-@id; |
| 12 |
|
| 13 |
## Check details of partitioning |
| 14 |
SELECT partitions, fragments, hash_map from ndbinfo.dictionary_tables |
| 15 |
WHERE table_name in ("t1", "t2"); |
| 16 |
|
| 17 |
|
| 18 |
## Create nodegroup for "new" nodes |
| 19 |
--replace_regex /Connected to Management Server at: .*// |
| 20 |
--exec $NDB_MGM -e "create nodegroup 3,4" |
| 21 |
|
| 22 |
## Drop |
| 23 |
--replace_regex /Connected to Management Server at: .*// |
| 24 |
--exec $NDB_MGM -e "drop nodegroup 1" |
| 25 |
## and create |
| 26 |
--replace_regex /Connected to Management Server at: .*// |
| 27 |
--exec $NDB_MGM -e "create nodegroup 3,4" |
| 28 |
|
| 29 |
alter table t2 algorithm=inplace, reorganize partition; |
| 30 |
alter table t1 algorithm=inplace, reorganize partition; |
| 31 |
|
| 32 |
## Check details of partitioning |
| 33 |
SELECT partitions, fragments, hash_map from ndbinfo.dictionary_tables |
| 34 |
WHERE table_name in ("t1", "t2"); |
| 35 |
|
| 36 |
--echo Check node restart after reorg with foreign keys |
| 37 |
--exec $NDB_MGM -e "1 RESTART -n" >> $NDB_TOOLS_OUTPUT |
| 38 |
|
| 39 |
--echo --- Wait for node to stop |
| 40 |
--exec $NDB_WAITER --not-started -w1 >> $NDB_TOOLS_OUTPUT |
| 41 |
|
| 42 |
--echo --- Startup node again |
| 43 |
--exec $NDB_MGM -e "1 START" >> $NDB_TOOLS_OUTPUT |
| 44 |
|
| 45 |
--echo --- Wait for node to recover |
| 46 |
--exec $NDB_WAITER >> $NDB_TOOLS_OUTPUT |
| 47 |
|
| 48 |
## Drop nodegroup with "new" nodes is not allowed with data one those nodes |
| 49 |
# NOTE: --error=0 is due to return codes doesnt work on windoze |
| 50 |
--replace_regex /Connected to Management Server at: .*// |
| 51 |
--error 0,255 |
| 52 |
--exec $NDB_MGM -e "drop nodegroup 1" |
| 53 |
|
| 54 |
drop table t2,t1; |
| 55 |
|
| 56 |
## Drop nodegroup with "new" nodes |
| 57 |
--replace_regex /Connected to Management Server at: .*// |
| 58 |
--exec $NDB_MGM -e "drop nodegroup 1" |
| 59 |
|
| 60 |
# Cleanup |
| 61 |
--remove_file $NDB_TOOLS_OUTPUT |