| 1 |
# |
| 2 |
# ALTER RENAME updates the generated foreign key names in the table. |
| 3 |
# Test that these names are properly rolled back on a failure. |
| 4 |
# |
| 5 |
--source connect.inc |
| 6 |
--source include/have_debug.inc |
| 7 |
|
| 8 |
--echo # Setup |
| 9 |
create table parent ( |
| 10 |
pk int primary key, |
| 11 |
id1 int unique, |
| 12 |
id2 int unique |
| 13 |
) engine ndb; |
| 14 |
|
| 15 |
create table child ( |
| 16 |
pk int primary key, |
| 17 |
ref1 int, |
| 18 |
ref2 int, |
| 19 |
foreign key ref1_idx(ref1) references parent (id1), |
| 20 |
foreign key ref2_idx(ref2) references parent (id2) |
| 21 |
) engine ndb; |
| 22 |
|
| 23 |
--echo # Verify the foreign keys on child |
| 24 |
--let $ndb_table_name=child |
| 25 |
--source verify_foreign_keys.inc |
| 26 |
|
| 27 |
# Set debug to simulate a rollback request |
| 28 |
set debug='+d,ndb_simulate_failure_after_table_rename'; |
| 29 |
--echo # Simple rename child should fail |
| 30 |
--echo # and the foreign key names should remain the same |
| 31 |
--error ER_INTERNAL_ERROR |
| 32 |
rename table child to child1; |
| 33 |
|
| 34 |
--echo # Verify the foreign keys on child |
| 35 |
--let $ndb_table_name=child |
| 36 |
--source verify_foreign_keys.inc |
| 37 |
|
| 38 |
# Set debug to simulate a rollback request |
| 39 |
set debug='+d,ndb_simulate_failure_after_table_rename'; |
| 40 |
--echo # Rename using inplace alter should fail |
| 41 |
--echo # and the foreign key names should remain the same |
| 42 |
--error ER_INTERNAL_ERROR |
| 43 |
alter table child rename to child1, algorithm = inplace; |
| 44 |
|
| 45 |
--echo # Verify the foreign keys on child |
| 46 |
--let $ndb_table_name=child |
| 47 |
--source verify_foreign_keys.inc |
| 48 |
|
| 49 |
# Set debug to simulate a rollback request |
| 50 |
set debug='+d,ndb_simulate_failure_after_table_rename'; |
| 51 |
--echo # Rename using copy alter should fail |
| 52 |
--echo # and the foreign key names should remain the same |
| 53 |
--error ER_INTERNAL_ERROR |
| 54 |
alter table child rename to child1, algorithm = copy; |
| 55 |
|
| 56 |
--echo # Verify the foreign keys on child |
| 57 |
--let $ndb_table_name=child |
| 58 |
--source verify_foreign_keys.inc |
| 59 |
|
| 60 |
--echo # Cleanup |
| 61 |
drop table child, parent; |