You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
insert into _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl select * from child_table;
29
29
SET FOREIGN_KEY_CHECKS=1;
30
-
SET rename_table_preserve_foreign_key=1;
31
30
rename table child_table to _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410, _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl to child_table, _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410 to _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl;
rename table parent_table to _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl, parent_table_new to parent_table;
31
69
show create table child_table;
32
70
Table Create Table
33
71
child_table CREATE TABLE `child_table` (
@@ -44,15 +82,15 @@ id hint
44
82
55 7
45
83
delete from parent_table where id=1;
46
84
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child_table`, CONSTRAINT `child_parent_fk` FOREIGN KEY (`parent_id`) REFERENCES `parent_table` (`id`))
47
-
delete from parent_table_old where id=1;
85
+
delete from _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl where id=1;
48
86
insert into child_table values (14, 55);
49
87
alter table child_table force;
50
88
select id, hint from parent_table;
51
89
id hint
52
90
1 7
53
91
2 7
54
92
55 7
55
-
delete from parent_table_old;
93
+
delete from _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl;
56
94
delete from parent_table where id=2;
57
95
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child_table`, CONSTRAINT `child_parent_fk` FOREIGN KEY (`parent_id`) REFERENCES `parent_table` (`id`))
58
96
drop table if exists _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl, _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410, child_table, child_table_old, child_table_new;
insert into _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl select * from child_table;
41
41
# rename, preserving foreign key
42
42
SET FOREIGN_KEY_CHECKS=1;
43
-
SET rename_table_preserve_foreign_key=1;
44
43
rename table child_table to _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410, _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl to child_table, _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410 to _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl;
45
-
SET rename_table_preserve_foreign_key=0;
46
44
# child_table's foreign key definition should point to parent_table
0 commit comments