| Bug #19739 | stored function call in primary select causes memory leak | ||
|---|---|---|---|
| Submitted: | 11 May 2006 20:10 | Modified: | 18 May 2006 23:28 |
| Reporter: | Michael Del Monte | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) |
| Version: | 5.0.20 | OS: | Windows (Windows XP) |
| Assigned to: | CPU Architecture: | Any | |
[11 May 2006 20:10]
Michael Del Monte
[12 May 2006 0:15]
MySQL Verification Team
Thank you for the bug report. Could you please provide the complete test case not just its description, create table, create procedure and so on. Thanks in advance.
[18 May 2006 1:46]
Michael Del Monte
Problem can be demonstrated with the following test:
# create test table
create table t1 (id int unsigned not null auto_increment primary key, s smallint unsigned) engine=myisam;
# create fill and test functions
drop procedure if exists fill;
drop function if exists testfunc;
delimiter $$
create procedure fill()
begin
declare i int default 0;
while i < 1000000 do insert ignore t1 (s) values (rand()*256); set i=i+1; end while;
end;
$$
create function testfunc (s smallint unsigned) returns tinyint unsigned
begin
# function is irrelevant; the fact that it is called at all is the problem
return 10*s;
end;
$$
delimiter ;
# fill t1 with a million rows
call fill();
# run test with inline function; will take very little time
create table t2 (s smallint unsigned) engine=myisam;
insert t2 select 10*s from t1;
# run test with function call; it will take a very LONG time and eat tons of memory
create table t3 (s smallint unsigned) engine=myisam;
insert t3 as select testfunc(s) from t1;
[18 May 2006 23:28]
MySQL Verification Team
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.
If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information
about accessing the source trees is available at
http://www.mysql.com/doc/en/Installing_source_tree.html
Additional info:
Please see bug:
http://bugs.mysql.com/bug.php?id=17260
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create table t1 (id int unsigned not null auto_increment primary key, s smallint
-> unsigned) engine=myisam;
Query OK, 0 rows affected (0.09 sec)
mysql> # create fill and test functions
mysql> drop procedure if exists fill;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> drop function if exists testfunc;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> delimiter $$
mysql> create procedure fill()
-> begin
-> declare i int default 0;
-> while i < 1000000 do insert ignore t1 (s) values (rand()*256); set i=i+1;
-> end while;
-> end;
-> $$
Query OK, 0 rows affected (0.03 sec)
mysql> create function testfunc (s smallint unsigned) returns tinyint unsigned
-> begin
-> # function is irrelevant; the fact that it is called at all is the problem
-> return 10*s;
-> end;
-> $$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql> call fill();
Query OK, 1 row affected (1 min 7.34 sec)
mysql> create table t2 (s smallint unsigned) engine=myisam;
Query OK, 0 rows affected (0.05 sec)
mysql> insert t2 select 10*s from t1;
Query OK, 1000000 rows affected (0.61 sec)
Records: 1000000 Duplicates: 0 Warnings: 0
mysql> create table t3 (s smallint unsigned) engine=myisam;
Query OK, 0 rows affected (0.08 sec)
mysql> insert t3 select testfunc(s) from t1;
Query OK, 1000000 rows affected, 65535 warnings (50.22 sec)
Records: 1000000 Duplicates: 0 Warnings: 900810
mysql>
[18 May 2006 23:34]
MySQL Verification Team
I forgot to paste the version:
mysql> show variables like "%version%"\G
*************************** 1. row ***************************
Variable_name: protocol_version
Value: 10
*************************** 2. row ***************************
Variable_name: version
Value: 5.0.22
*************************** 3. row ***************************
Variable_name: version_comment
Value: Source distribution
*************************** 4. row ***************************
Variable_name: version_compile_machine
Value: ia32
*************************** 5. row ***************************
Variable_name: version_compile_os
Value: Win32
5 rows in set (0.00 sec)
mysql>
