1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#
# 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;
|