1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fix for Bug#11247 Stored procedures: Function calls in long loops leak memory

and Bug#12297 SP crashes the server if data inserted inside a lon loop
Third commit attempt. With fixes to the issues, showed up after full rebuild and
tests on other hosts.


mysql-test/r/rpl_sp.result:
  New warnings appeared in result file, as now we always create spcont in a stored routine.
  This is correct behaviour. We swallowed some warnings, as we used thd->spcont to check whether
  we are in the SP though we didn't set spcont in certain cases. This is fixed now.
mysql-test/r/sp.result:
  fixed result file to reflect new tests
mysql-test/t/sp.test:
  Added tests for bugs. Though one of them is disabled, as it fails because of the other bug.
  It should be enabled, when bug 12297 is fixed.
sql/sp_head.cc:
  Per-instruction arena is implemented
sql/sp_rcontext.cc:
   Now we should deal with callers_arena->free_list when we employ reuse mechanism with callers_arena
   switched during sp_eval_func_item
sql/sp_rcontext.h:
  Add new member to sp_rcontext class, in order to handle instructions with assignment
  and/or with nested SP processing properly.
This commit is contained in:
unknown
2005-08-18 11:23:54 +02:00
parent a397a194b2
commit fa19a9f246
6 changed files with 304 additions and 143 deletions

View File

@ -109,6 +109,7 @@ call foo4();
Got one of the listed errors
show warnings;
Level Code Message
Error 1142 INSERT command denied to user 'zedjzlcsjhd'@'localhost' for table 't1'
Warning 1417 A routine failed and has neither NO SQL nor READS SQL DATA in its declaration and binary logging is enabled; if non-transactional tables were updated, the binary log will miss their changes
call foo3();
show warnings;
@ -117,6 +118,7 @@ call foo4();
Got one of the listed errors
show warnings;
Level Code Message
Error 1142 INSERT command denied to user 'zedjzlcsjhd'@'localhost' for table 't1'
Warning 1417 A routine failed and has neither NO SQL nor READS SQL DATA in its declaration and binary logging is enabled; if non-transactional tables were updated, the binary log will miss their changes
alter procedure foo4 sql security invoker;
call foo4();

View File

@ -3085,4 +3085,19 @@ column_name bug10055(t.column_name)
id id
data data
drop function bug10055|
drop function if exists f_bug11247|
drop procedure if exists p_bug11247|
create function f_bug11247(param int)
returns int
return param + 1|
create procedure p_bug11247(lim int)
begin
declare v int default 0;
while v < lim do
set v= f_bug11247(v);
end while;
end|
call p_bug11247(10)|
drop function f_bug11247|
drop procedure p_bug11247|
drop table t1,t2;

View File

@ -3870,6 +3870,65 @@ from information_schema.columns as t
where t.table_schema = 'test' and t.table_name = 't1'|
drop function bug10055|
#
# Bug #12297 "SP crashes the server if data inserted inside a lon loop"
# The test for memleak bug, so actually there is no way to test it
# from the suite. The test below could be used to check SP memory
# consumption by passing large input parameter.
#
#
# Note: the test is currenly disabled because of the
# Bug #12637: SP crashes the server if it has update query with user var
# & binlog is enabled.
#
--disable_warnings
#drop procedure if exists bug12297|
--enable_warnings
#create procedure bug12297(lim int)
#begin
# set @x = 0;
# repeat
# insert into t1(id,data)
# values('aa', @x);
# set @x = @x + 1;
# until @x >= lim
# end repeat;
#end|
#call bug12297(10)|
#drop procedure bug12297|
#
# Bug #11247 "Stored procedures: Function calls in long loops leak memory"
# One more memleak bug test. One could use this test to check that the memory
# isn't leaking by increasing the input value for p_bug11247.
#
--disable_warnings
drop function if exists f_bug11247|
drop procedure if exists p_bug11247|
--enable_warnings
create function f_bug11247(param int)
returns int
return param + 1|
create procedure p_bug11247(lim int)
begin
declare v int default 0;
while v < lim do
set v= f_bug11247(v);
end while;
end|
call p_bug11247(10)|
drop function f_bug11247|
drop procedure p_bug11247|
#
# BUG#NNNN: New bug synopsis
#