|
1 | 1 | drop table if exists t0,t1,t2,t3,t4;
|
2 | 2 | drop table if exists t0,t5,t6,t7,t8,t9,t1_1,t1_2,t9_1,t9_2;
|
3 | 3 | drop table if exists _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl, _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410, child_table, child_table_old, child_table_new;
|
| 4 | +drop table if exists _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_, _vt_hld_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_; |
4 | 5 | drop table if exists parent_table, parent_table_old, parent_table_new;
|
5 | 6 | SET FOREIGN_KEY_CHECKS=1;
|
6 | 7 | CREATE TABLE parent_table (
|
@@ -35,10 +36,28 @@ KEY parent_id_idx (parent_id),
|
35 | 36 | CONSTRAINT `hold_child_parent_fk` FOREIGN KEY (parent_id) REFERENCES parent_table(id) ON DELETE NO ACTION
|
36 | 37 | );
|
37 | 38 | insert into _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410 select * from child_table;
|
| 39 | +CREATE TABLE _vt_hld_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ ( |
| 40 | +id INT NOT NULL, |
| 41 | +parent_id INT, |
| 42 | +PRIMARY KEY (id), |
| 43 | +KEY parent_id_idx (parent_id), |
| 44 | +CONSTRAINT `hld_child_parent_fk` FOREIGN KEY (parent_id) REFERENCES parent_table(id) ON DELETE NO ACTION |
| 45 | +); |
| 46 | +insert into _vt_hld_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ select * from child_table; |
| 47 | +CREATE TABLE _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ ( |
| 48 | +id INT NOT NULL, |
| 49 | +parent_id INT, |
| 50 | +PRIMARY KEY (id), |
| 51 | +KEY parent_id_idx (parent_id), |
| 52 | +CONSTRAINT `vrp_child_parent_fk` FOREIGN KEY (parent_id) REFERENCES parent_table(id) ON DELETE NO ACTION |
| 53 | +); |
| 54 | +insert into _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ select * from child_table; |
38 | 55 | insert into child_table values (100, 100);
|
39 | 56 | ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child_table`, CONSTRAINT `child_parent_fk` FOREIGN KEY (`parent_id`) REFERENCES `parent_table` (`id`))
|
40 | 57 | insert into _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl values (101, 101);
|
41 | 58 | insert into _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410 values (102, 102);
|
| 59 | +insert into _vt_hld_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ values (103, 103); |
| 60 | +insert into _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ values (103, 103); |
42 | 61 | delete from parent_table where id=1;
|
43 | 62 | 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`))
|
44 | 63 | delete from child_table;
|
@@ -199,5 +218,6 @@ id parent_id
|
199 | 218 | 13 2
|
200 | 219 | 400 400
|
201 | 220 | drop table _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl;
|
| 221 | +drop table if exists _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_, _vt_hld_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_; |
202 | 222 | drop table if exists _84371a37_6153_11eb_9917_f875a4d24e90_20210128122816_vrepl, _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410, child_table, child_table_old, child_table_new;
|
203 | 223 | drop table if exists parent_table, parent_table_old, parent_table_new;
|
0 commit comments