File tree Expand file tree Collapse file tree 4 files changed +96
-12
lines changed Expand file tree Collapse file tree 4 files changed +96
-12
lines changed Original file line number Diff line number Diff line change @@ -33,3 +33,35 @@ select * from fk_29;
33
33
f1
34
34
29
35
35
drop table t1;
36
+ CREATE TABLE t1 (
37
+ id int(11) NOT NULL AUTO_INCREMENT,
38
+ f1 int(11) DEFAULT NULL,
39
+ PRIMARY KEY (id),
40
+ CONSTRAINT fk1 FOREIGN KEY (f1) REFERENCES t1 (id) ON DELETE CASCADE
41
+ ) ENGINE=InnoDB;
42
+ CREATE TABLE t2 (
43
+ id int(11) NOT NULL AUTO_INCREMENT,
44
+ f2 int(11) NOT NULL,
45
+ f3 int(11) NOT NULL,
46
+ PRIMARY KEY (`id`),
47
+ CONSTRAINT fk2 FOREIGN KEY (f2) REFERENCES t1 (`id`) ON DELETE CASCADE,
48
+ CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
49
+ ) ENGINE=InnoDB;
50
+ ERROR HY000: Can't create table 'test.t2' (errno: 150)
51
+ show warnings;
52
+ Level Code Message
53
+ Error 1005 Can't create table 'test.t2' (errno: 150)
54
+ CREATE TABLE t2 (
55
+ id int(11) NOT NULL AUTO_INCREMENT,
56
+ f2 int(11) NOT NULL,
57
+ f3 int(11) NOT NULL,
58
+ PRIMARY KEY (`id`),
59
+ CONSTRAINT fk2 FOREIGN KEY (f2) REFERENCES t1 (`id`) ON DELETE CASCADE
60
+ ) ENGINE=InnoDB;
61
+ ALTER TABLE t2 ADD CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE;
62
+ ERROR HY000: Can't create table '#sql-temporary' (errno: 150)
63
+ show warnings;
64
+ Level Code Message
65
+ Error 1005 Can't create table '#sql-temporary' (errno: 150)
66
+ drop table t2;
67
+ drop table t1;
Original file line number Diff line number Diff line change @@ -84,3 +84,43 @@ while ($i)
84
84
85
85
drop table t1;
86
86
87
+ #
88
+ # MDEV-7672: Crash creating an InnoDB table with foreign keys
89
+ #
90
+
91
+ CREATE TABLE t1 (
92
+ id int(11) NOT NULL AUTO_INCREMENT,
93
+ f1 int(11) DEFAULT NULL,
94
+ PRIMARY KEY (id),
95
+ CONSTRAINT fk1 FOREIGN KEY (f1) REFERENCES t1 (id) ON DELETE CASCADE
96
+ ) ENGINE=InnoDB;
97
+
98
+ --error 1005
99
+ CREATE TABLE t2 (
100
+ id int(11) NOT NULL AUTO_INCREMENT,
101
+ f2 int(11) NOT NULL,
102
+ f3 int(11) NOT NULL,
103
+ PRIMARY KEY (`id`),
104
+ CONSTRAINT fk2 FOREIGN KEY (f2) REFERENCES t1 (`id`) ON DELETE CASCADE,
105
+ CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE
106
+ ) ENGINE=InnoDB;
107
+
108
+ show warnings;
109
+
110
+ CREATE TABLE t2 (
111
+ id int(11) NOT NULL AUTO_INCREMENT,
112
+ f2 int(11) NOT NULL,
113
+ f3 int(11) NOT NULL,
114
+ PRIMARY KEY (`id`),
115
+ CONSTRAINT fk2 FOREIGN KEY (f2) REFERENCES t1 (`id`) ON DELETE CASCADE
116
+ ) ENGINE=InnoDB;
117
+
118
+ --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
119
+ --error 1005
120
+ ALTER TABLE t2 ADD CONSTRAINT fk3 FOREIGN KEY (f3) REFERENCES t3 (id) ON DELETE CASCADE;
121
+
122
+ --replace_regex /'test\.#sql-[0-9_a-f-]*'/'#sql-temporary'/
123
+ show warnings;
124
+
125
+ drop table t2;
126
+ drop table t1;
Original file line number Diff line number Diff line change @@ -2533,10 +2533,13 @@ dict_foreign_remove_from_cache(
2533
2533
if (rbt != NULL && foreign -> id != NULL ) {
2534
2534
const ib_rbt_node_t * node
2535
2535
= rbt_lookup (rbt , foreign -> id );
2536
- dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2537
2536
2538
- if (val == foreign ) {
2539
- rbt_delete (rbt , foreign -> id );
2537
+ if (node ) {
2538
+ dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2539
+
2540
+ if (val == foreign ) {
2541
+ rbt_delete (rbt , foreign -> id );
2542
+ }
2540
2543
}
2541
2544
}
2542
2545
}
@@ -2552,10 +2555,13 @@ dict_foreign_remove_from_cache(
2552
2555
if (rbt != NULL && foreign -> id != NULL ) {
2553
2556
const ib_rbt_node_t * node
2554
2557
= rbt_lookup (rbt , foreign -> id );
2555
- dict_foreign_t * val = * ( dict_foreign_t * * ) node -> value ;
2558
+ if ( node ) {
2556
2559
2557
- if (val == foreign ) {
2558
- rbt_delete (rbt , foreign -> id );
2560
+ dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2561
+
2562
+ if (val == foreign ) {
2563
+ rbt_delete (rbt , foreign -> id );
2564
+ }
2559
2565
}
2560
2566
}
2561
2567
}
Original file line number Diff line number Diff line change @@ -2666,10 +2666,13 @@ dict_foreign_remove_from_cache(
2666
2666
if (rbt != NULL && foreign -> id != NULL ) {
2667
2667
const ib_rbt_node_t * node
2668
2668
= rbt_lookup (rbt , foreign -> id );
2669
- dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2670
2669
2671
- if (val == foreign ) {
2672
- rbt_delete (rbt , foreign -> id );
2670
+ if (node ) {
2671
+ dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2672
+
2673
+ if (val == foreign ) {
2674
+ rbt_delete (rbt , foreign -> id );
2675
+ }
2673
2676
}
2674
2677
}
2675
2678
}
@@ -2685,10 +2688,13 @@ dict_foreign_remove_from_cache(
2685
2688
if (rbt != NULL && foreign -> id != NULL ) {
2686
2689
const ib_rbt_node_t * node
2687
2690
= rbt_lookup (rbt , foreign -> id );
2688
- dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2689
2691
2690
- if (val == foreign ) {
2691
- rbt_delete (rbt , foreign -> id );
2692
+ if (node ) {
2693
+ dict_foreign_t * val = * (dict_foreign_t * * ) node -> value ;
2694
+
2695
+ if (val == foreign ) {
2696
+ rbt_delete (rbt , foreign -> id );
2697
+ }
2692
2698
}
2693
2699
}
2694
2700
}
You can’t perform that action at this time.
0 commit comments