Commit 29dbb23f authored by Monty's avatar Monty

MDEV-16093 Memory leak with triggers

Problem was that blob memory allocated in Table_trigger_list was not
properly freed
parent 9e22cae1
......@@ -2306,4 +2306,15 @@ CREATE TABLE t1 (i INT);
insert into t2 value (2);
DROP VIEW v1;
DROP TABLE t1,t2,t3;
End of 10.1 tests.
#
# MDEV-16093
# Assertion `global_status_var.global_memory_used == 0' failed or
# bytes lost after inserting into table with non-null blob and trigger
#
CREATE TABLE t1 (b BLOB NOT NULL);
CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 VALUES ('foo');
DROP TABLE t1;
#
# End of 10.1 tests.
#
......@@ -2656,5 +2656,17 @@ insert into t2 value (2);
DROP VIEW v1;
DROP TABLE t1,t2,t3;
--echo #
--echo # MDEV-16093
--echo # Assertion `global_status_var.global_memory_used == 0' failed or
--echo # bytes lost after inserting into table with non-null blob and trigger
--echo #
CREATE TABLE t1 (b BLOB NOT NULL);
CREATE TRIGGER tr BEFORE UPDATE ON t1 FOR EACH ROW BEGIN END;
INSERT INTO t1 VALUES ('foo');
DROP TABLE t1;
--echo End of 10.1 tests.
--echo #
--echo # End of 10.1 tests.
--echo #
......@@ -614,6 +614,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
#endif /* WITH_WSREP */
}
/**
Build stmt_query to write it in the bin-log
and get the trigger definer.
......@@ -1061,6 +1062,11 @@ Table_triggers_list::~Table_triggers_list()
for (int j= 0; j < (int)TRG_ACTION_MAX; j++)
delete bodies[i][j];
/* Free blobs used in insert */
if (record0_field)
for (Field **fld_ptr= record0_field; *fld_ptr; fld_ptr++)
(*fld_ptr)->free();
if (record1_field)
for (Field **fld_ptr= record1_field; *fld_ptr; fld_ptr++)
delete *fld_ptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment