-
Dmitry Shulga authored
One of possible use cases that reproduces the memory leakage listed below: set timestamp= unix_timestamp('2000-01-01 00:00:00'); create or replace table t1 (x int) with system versioning partition by system_time interval 1 hour auto partitions 3; create table t2 (x int); create trigger tr after insert on t2 for each row update t1 set x= 11; create or replace procedure sp2() insert into t2 values (5); set timestamp= unix_timestamp('2000-01-01 04:00:00'); call sp2; set timestamp= unix_timestamp('2000-01-01 13:00:00'); call sp2; # <<=== Memory leak happens there. In case MariaDB server is built with the option -DWITH_PROTECT_STATEMENT_MEMROOT, the second execution would hit assert failure. The reason of leaking a memory is that once a new partition be created the table should be closed and re-opened. It results in calling the function extend_table_list() that indirectly invokes the function sp_add_used_routine() to add routines implicitly used by the statement that makes a new memory allocation. To fix it, don't remove routines and tables the statement implicitly depends on when a table being closed for subsequent re-opening.
77c465d5