# # Tests to verify ALTER RENAME updates generated foreign key names # --source connect.inc --echo # Setup create table parent ( pk int primary key, id1 int unique, id2 int unique, ref1 int, ref2 int, constraint fk_p1 foreign key ref1_idx(ref1) references parent (id1), foreign key ref2_idx(ref2) references parent (id2) ) engine ndb; create table child ( pk int primary key, ref1 int, ref2 int, constraint fk_c1 foreign key ref1_idx(ref1) references parent (id1), foreign key ref2_idx(ref2) references parent (id2) ) engine ndb; --echo # Verify the foreign keys on parent and child --let $ndb_table_name=parent --source verify_foreign_keys.inc --let $ndb_table_name=child --source verify_foreign_keys.inc # Rename parent table to verify # a) The generated foreign key names have been updated across # all connected mysqlds (Bug#30210839) # b) The child table foreign key's referenced table have been # updated in all connected mysqld DDs (Bug#30191068) --echo # Simple rename parent rename table parent to parent1; --echo # Verify the foreign keys on parent and child --let $ndb_table_name=parent1 --source verify_foreign_keys.inc --let $ndb_table_name=child --source verify_foreign_keys.inc --echo # Rename parent using copy algorithm alter table parent1 rename to parent2, algorithm = copy; --echo # Verify the foreign keys on parent and child --let $ndb_table_name=parent2 --source verify_foreign_keys.inc --let $ndb_table_name=child --source verify_foreign_keys.inc --echo # Rename parent using inplace algorithm alter table parent2 rename to parent3, algorithm = inplace; --echo # Verify the foreign keys on parent and child --let $ndb_table_name=parent3 --source verify_foreign_keys.inc --let $ndb_table_name=child --source verify_foreign_keys.inc # Rename child table to verify that # a) The generated foreign key names have been updated across # all connected mysqlds (Bug#30210839) --echo # Simple rename child rename table child to child1; --echo # Verify the foreign keys on child --let $ndb_table_name=child1 --source verify_foreign_keys.inc --echo # Rename child using copy algorithm alter table child1 rename to child2, algorithm = copy; --echo # Verify the foreign keys on child --let $ndb_table_name=child2 --source verify_foreign_keys.inc --echo # Rename child using inplace algorithm alter table child2 rename to child3, algorithm = inplace; --echo # Verify the foreign keys on child --let $ndb_table_name=child3 --source verify_foreign_keys.inc --echo # Cleanup drop table child3, parent3;