From 7a12894de11ab04b93c9e96359008386b3b41cbb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sat, 10 Jun 2017 16:39:39 -0700 Subject: Fixed the bug mdev12992. When the SELECT query from a trigger that used a subquery in its SELECT list was prepared the counter select_n_having_items was incremented in the constructor Item::Item(THD *thd). As a result each invocation of the trigger required more and more memory for the ref_pointer_array for this SELECT. Made sure that the counter st_select_lex::select_n_having_items would be incremented only at the first execution of such trigger. --- mysql-test/t/trigger.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'mysql-test/t/trigger.test') diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 83b6966c676..5c65e3dd13b 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -2676,3 +2676,27 @@ select trigger_name, action_order, created from information_schema.triggers where event_object_table = 't1' and trigger_schema='test'; drop table t1; set time_zone= @@global.time_zone; + +--echo # +--echo # MDEV-12992: Increasing memory consumption +--echo with each invocation of trigger +--echo # + +--let $n= 20000 + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1); +CREATE TABLE t2 (b INT); +CREATE TRIGGER tr + AFTER UPDATE ON t1 FOR EACH ROW SELECT (SELECT b FROM t2) INTO @x; + +--disable_query_log +--echo # Running $n queries +while ($n) +{ + UPDATE t1 SET a = 2; + --dec $n +} +--enable_query_log + +DROP TABLE t1,t2; -- cgit v1.2.1