/**
 * Run this script and monitor server memory to make sure
 * there are no memory leaks.
 */

DELIMITER $$
CREATE PROCEDURE udf_test(vLoops BIGINT)
BEGIN
	DECLARE vI BIGINT DEFAULT 0;
    DECLARE vRes VARCHAR(255);

    WHILE vI < vLoops DO
		SELECT minacum(2, -10, 1) INTO vRes;
        SET vI = vI + 1;
    END WHILE;
END$$
DELIMITER ;

CALL udf_test(POW(10, 6));

DROP PROCEDURE udf_test;