| 1 |
# |
| 2 |
# Tests to verify ALTER RENAME updates generated foreign key names |
| 3 |
# |
| 4 |
--source connect.inc |
| 5 |
|
| 6 |
--echo # Setup |
| 7 |
create table parent ( |
| 8 |
pk int primary key, |
| 9 |
id1 int unique, |
| 10 |
id2 int unique, |
| 11 |
ref1 int, |
| 12 |
ref2 int, |
| 13 |
constraint fk_p1 foreign key ref1_idx(ref1) references parent (id1), |
| 14 |
foreign key ref2_idx(ref2) references parent (id2) |
| 15 |
) engine ndb; |
| 16 |
|
| 17 |
create table child ( |
| 18 |
pk int primary key, |
| 19 |
ref1 int, |
| 20 |
ref2 int, |
| 21 |
constraint fk_c1 foreign key ref1_idx(ref1) references parent (id1), |
| 22 |
foreign key ref2_idx(ref2) references parent (id2) |
| 23 |
) engine ndb; |
| 24 |
|
| 25 |
--echo # Verify the foreign keys on parent and child |
| 26 |
--let $ndb_table_name=parent |
| 27 |
--source verify_foreign_keys.inc |
| 28 |
--let $ndb_table_name=child |
| 29 |
--source verify_foreign_keys.inc |
| 30 |
|
| 31 |
# Rename parent table to verify |
| 32 |
# a) The generated foreign key names have been updated across |
| 33 |
# all connected mysqlds (Bug#30210839) |
| 34 |
# b) The child table foreign key's referenced table have been |
| 35 |
# updated in all connected mysqld DDs (Bug#30191068) |
| 36 |
|
| 37 |
--echo # Simple rename parent |
| 38 |
rename table parent to parent1; |
| 39 |
|
| 40 |
--echo # Verify the foreign keys on parent and child |
| 41 |
--let $ndb_table_name=parent1 |
| 42 |
--source verify_foreign_keys.inc |
| 43 |
--let $ndb_table_name=child |
| 44 |
--source verify_foreign_keys.inc |
| 45 |
|
| 46 |
--echo # Rename parent using copy algorithm |
| 47 |
alter table parent1 rename to parent2, algorithm = copy; |
| 48 |
|
| 49 |
--echo # Verify the foreign keys on parent and child |
| 50 |
--let $ndb_table_name=parent2 |
| 51 |
--source verify_foreign_keys.inc |
| 52 |
--let $ndb_table_name=child |
| 53 |
--source verify_foreign_keys.inc |
| 54 |
|
| 55 |
--echo # Rename parent using inplace algorithm |
| 56 |
alter table parent2 rename to parent3, algorithm = inplace; |
| 57 |
|
| 58 |
--echo # Verify the foreign keys on parent and child |
| 59 |
--let $ndb_table_name=parent3 |
| 60 |
--source verify_foreign_keys.inc |
| 61 |
--let $ndb_table_name=child |
| 62 |
--source verify_foreign_keys.inc |
| 63 |
|
| 64 |
# Rename child table to verify that |
| 65 |
# a) The generated foreign key names have been updated across |
| 66 |
# all connected mysqlds (Bug#30210839) |
| 67 |
|
| 68 |
--echo # Simple rename child |
| 69 |
rename table child to child1; |
| 70 |
|
| 71 |
--echo # Verify the foreign keys on child |
| 72 |
--let $ndb_table_name=child1 |
| 73 |
--source verify_foreign_keys.inc |
| 74 |
|
| 75 |
--echo # Rename child using copy algorithm |
| 76 |
alter table child1 rename to child2, algorithm = copy; |
| 77 |
|
| 78 |
--echo # Verify the foreign keys on child |
| 79 |
--let $ndb_table_name=child2 |
| 80 |
--source verify_foreign_keys.inc |
| 81 |
|
| 82 |
--echo # Rename child using inplace algorithm |
| 83 |
alter table child2 rename to child3, algorithm = inplace; |
| 84 |
|
| 85 |
--echo # Verify the foreign keys on child |
| 86 |
--let $ndb_table_name=child3 |
| 87 |
--source verify_foreign_keys.inc |
| 88 |
|
| 89 |
--echo # Cleanup |
| 90 |
drop table child3, parent3; |