| 1 |
# |
| 2 |
# Test ALTER DROP FOREIGN KEYS |
| 3 |
# |
| 4 |
--source connect.inc |
| 5 |
|
| 6 |
if (!$algorithm) |
| 7 |
{ |
| 8 |
die Need the algortihm to use when testing the ALTER; |
| 9 |
} |
| 10 |
|
| 11 |
--echo # Setup |
| 12 |
create table parent ( |
| 13 |
pk int primary key, |
| 14 |
id1 int unique, |
| 15 |
id2 int unique, |
| 16 |
ref1 int, |
| 17 |
ref2 int, |
| 18 |
constraint fk_p1 foreign key ref1_idx(ref1) references parent (id1), |
| 19 |
foreign key ref2_idx(ref2) references parent (id2) |
| 20 |
) engine ndb; |
| 21 |
|
| 22 |
--echo # Verify the foreign keys on parent |
| 23 |
--let $ndb_table_name=parent |
| 24 |
--source verify_foreign_keys.inc |
| 25 |
|
| 26 |
create table child ( |
| 27 |
pk int primary key, |
| 28 |
ref1 int, |
| 29 |
ref2 int, |
| 30 |
constraint fk_c1 foreign key ref1_idx(ref1) references parent (id1), |
| 31 |
foreign key ref2_idx(ref2) references parent (id2) |
| 32 |
) engine ndb; |
| 33 |
|
| 34 |
--echo # Verify the foreign keys on child |
| 35 |
--let $ndb_table_name=child |
| 36 |
--source verify_foreign_keys.inc |
| 37 |
|
| 38 |
--echo # Drop foreign keys one by one and verify the other FKs integrity |
| 39 |
eval alter table parent |
| 40 |
drop foreign key fk_p1, |
| 41 |
algorithm = $algorithm; |
| 42 |
|
| 43 |
--echo # Verify the foreign keys on parent and child |
| 44 |
--let $ndb_table_name=parent |
| 45 |
--source verify_foreign_keys.inc |
| 46 |
--let $ndb_table_name=child |
| 47 |
--source verify_foreign_keys.inc |
| 48 |
|
| 49 |
eval alter table parent |
| 50 |
drop foreign key parent_fk_1, |
| 51 |
algorithm = $algorithm; |
| 52 |
|
| 53 |
--echo # Verify the foreign keys on parent and child |
| 54 |
--let $ndb_table_name=parent |
| 55 |
--source verify_foreign_keys.inc |
| 56 |
--let $ndb_table_name=child |
| 57 |
--source verify_foreign_keys.inc |
| 58 |
|
| 59 |
eval alter table child |
| 60 |
drop foreign key fk_c1, |
| 61 |
algorithm = $algorithm; |
| 62 |
|
| 63 |
--echo # Verify the foreign keys on child |
| 64 |
--let $ndb_table_name=child |
| 65 |
--source verify_foreign_keys.inc |
| 66 |
|
| 67 |
eval alter table child |
| 68 |
drop foreign key child_fk_1, |
| 69 |
algorithm = $algorithm; |
| 70 |
|
| 71 |
--echo # Verify the foreign keys on child |
| 72 |
--let $ndb_table_name=child |
| 73 |
--source verify_foreign_keys.inc |
| 74 |
|
| 75 |
--echo # Cleanup |
| 76 |
drop table child, parent; |
| 77 |
|
| 78 |
# Reset algorithm |
| 79 |
--let $algorithm= |
| 80 |
|