Skip to content

Commit f79f537

Browse files
committed
MDEV-21690 LeakSanitizer: detected memory leaks in mem_heap_create_block_func
1 parent 77c6382 commit f79f537

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

mysql-test/suite/innodb/r/foreign_key.result

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,4 +565,11 @@ t2 CREATE TABLE `t2` (
565565
) ENGINE=InnoDB DEFAULT CHARSET=latin1
566566
drop tables t2, t1;
567567
set default_storage_engine= default;
568+
#
569+
# MDEV-21690 LeakSanitizer: detected memory leaks in mem_heap_create_block_func
570+
#
571+
CREATE TABLE t1 (a TEXT, b TEXT) ENGINE=InnoDB;
572+
ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (b);
573+
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
574+
DROP TABLE t1;
568575
# End of 10.5 tests

mysql-test/suite/innodb/t/foreign_key.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,16 @@ drop tables t2, t1;
519519

520520
set default_storage_engine= default;
521521

522+
--echo #
523+
--echo # MDEV-21690 LeakSanitizer: detected memory leaks in mem_heap_create_block_func
524+
--echo #
525+
CREATE TABLE t1 (a TEXT, b TEXT) ENGINE=InnoDB;
526+
--error ER_CANT_CREATE_TABLE
527+
ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (b);
528+
529+
# Cleanup
530+
DROP TABLE t1;
531+
522532
--echo # End of 10.5 tests
523533

524534
--source include/wait_until_count_sessions.inc

storage/innobase/handler/ha_innodb.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12339,7 +12339,7 @@ create_table_info_t::create_foreign_keys()
1233912339
" failed. Column %s was not found.",
1234012340
operation, create_name, k.str(),
1234112341
column_names[i]);
12342-
12342+
dict_foreign_free(foreign);
1234312343
return (DB_CANNOT_ADD_CONSTRAINT);
1234412344
}
1234512345
++i;
@@ -12353,6 +12353,7 @@ create_table_info_t::create_foreign_keys()
1235312353
"allowed).",
1235412354
operation, create_name, k.str(), i,
1235512355
MAX_COLS_PER_FK);
12356+
dict_foreign_free(foreign);
1235612357
return (DB_CANNOT_ADD_CONSTRAINT);
1235712358
}
1235812359
}
@@ -12367,6 +12368,7 @@ create_table_info_t::create_foreign_keys()
1236712368
k.str(), column_names,
1236812369
index_error, err_col,
1236912370
err_index, table);
12371+
dict_foreign_free(foreign);
1237012372
return (DB_CANNOT_ADD_CONSTRAINT);
1237112373
}
1237212374

0 commit comments

Comments
 (0)