Loading mysql-test/r/innodb.result +17 −0 Original line number Diff line number Diff line Loading @@ -3456,3 +3456,20 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON DELETE CASCADE ON UPDATE CASCADE; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL, `f` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `f` (`f`), CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2, t1; mysql-test/t/innodb.test +16 −0 Original line number Diff line number Diff line Loading @@ -2504,6 +2504,22 @@ INSERT INTO t1 VALUES (1); OPTIMIZE TABLE t1; DROP TABLE t1; # # Bug #24741 (existing cascade clauses disappear when adding foreign keys) # CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON DELETE CASCADE ON UPDATE CASCADE; SHOW CREATE TABLE t2; DROP TABLE t2, t1; ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # Loading storage/innobase/buf/buf0flu.c +1 −2 Original line number Diff line number Diff line Loading @@ -977,7 +977,6 @@ buf_flush_batch( } #endif /* UNIV_DEBUG */ if (page_count != ULINT_UNDEFINED) srv_buf_pool_flushed += page_count; return(page_count); Loading storage/innobase/dict/dict0load.c +5 −4 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,7 @@ dict_load_foreign( rec_t* rec; byte* field; ulint len; ulint n_fields_and_type; mtr_t mtr; #ifdef UNIV_SYNC_DEBUG Loading Loading @@ -1172,15 +1173,15 @@ dict_load_foreign( foreign = dict_mem_foreign_create(); foreign->n_fields = mach_read_from_4( n_fields_and_type = mach_read_from_4( rec_get_nth_field_old(rec, 5, &len)); ut_a(len == 4); /* We store the type to the bits 24-31 of n_fields */ /* We store the type in the bits 24..29 of n_fields_and_type. */ foreign->type = foreign->n_fields >> 24; foreign->n_fields = foreign->n_fields & 0xFFFFFFUL; foreign->type = n_fields_and_type >> 24; foreign->n_fields = n_fields_and_type & 0x3FFUL; foreign->id = mem_heap_strdup(foreign->heap, id); Loading storage/innobase/include/ut0ut.h +2 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,8 @@ ulint ut_2_power_up( /*==========*/ /* out: first power of 2 which is >= n */ ulint n); /* in: number != 0 */ ulint n) /* in: number != 0 */ __attribute__((const)); /**************************************************************** Sort function for ulint arrays. */ Loading Loading
mysql-test/r/innodb.result +17 −0 Original line number Diff line number Diff line Loading @@ -3456,3 +3456,20 @@ OPTIMIZE TABLE t1; Table Op Msg_type Msg_text test.t1 optimize status OK DROP TABLE t1; CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON DELETE CASCADE ON UPDATE CASCADE; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( `id` int(11) NOT NULL, `f` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `f` (`f`), CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f`) REFERENCES `t1` (`f`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `t2_t1` FOREIGN KEY (`id`) REFERENCES `t1` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1 DROP TABLE t2, t1;
mysql-test/t/innodb.test +16 −0 Original line number Diff line number Diff line Loading @@ -2504,6 +2504,22 @@ INSERT INTO t1 VALUES (1); OPTIMIZE TABLE t1; DROP TABLE t1; # # Bug #24741 (existing cascade clauses disappear when adding foreign keys) # CREATE TABLE t1 (id int PRIMARY KEY, f int NOT NULL, INDEX(f)) ENGINE=InnoDB; CREATE TABLE t2 (id int PRIMARY KEY, f INT NOT NULL, CONSTRAINT t2_t1 FOREIGN KEY (id) REFERENCES t1 (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB; ALTER TABLE t2 ADD FOREIGN KEY (f) REFERENCES t1 (f) ON DELETE CASCADE ON UPDATE CASCADE; SHOW CREATE TABLE t2; DROP TABLE t2, t1; ####################################################################### # # # Please, DO NOT TOUCH this file as well as the innodb.result file. # Loading
storage/innobase/buf/buf0flu.c +1 −2 Original line number Diff line number Diff line Loading @@ -977,7 +977,6 @@ buf_flush_batch( } #endif /* UNIV_DEBUG */ if (page_count != ULINT_UNDEFINED) srv_buf_pool_flushed += page_count; return(page_count); Loading
storage/innobase/dict/dict0load.c +5 −4 Original line number Diff line number Diff line Loading @@ -1110,6 +1110,7 @@ dict_load_foreign( rec_t* rec; byte* field; ulint len; ulint n_fields_and_type; mtr_t mtr; #ifdef UNIV_SYNC_DEBUG Loading Loading @@ -1172,15 +1173,15 @@ dict_load_foreign( foreign = dict_mem_foreign_create(); foreign->n_fields = mach_read_from_4( n_fields_and_type = mach_read_from_4( rec_get_nth_field_old(rec, 5, &len)); ut_a(len == 4); /* We store the type to the bits 24-31 of n_fields */ /* We store the type in the bits 24..29 of n_fields_and_type. */ foreign->type = foreign->n_fields >> 24; foreign->n_fields = foreign->n_fields & 0xFFFFFFUL; foreign->type = n_fields_and_type >> 24; foreign->n_fields = n_fields_and_type & 0x3FFUL; foreign->id = mem_heap_strdup(foreign->heap, id); Loading
storage/innobase/include/ut0ut.h +2 −1 Original line number Diff line number Diff line Loading @@ -119,7 +119,8 @@ ulint ut_2_power_up( /*==========*/ /* out: first power of 2 which is >= n */ ulint n); /* in: number != 0 */ ulint n) /* in: number != 0 */ __attribute__((const)); /**************************************************************** Sort function for ulint arrays. */ Loading