Bug #25345 Cursors from Functions
Submitted: 31 Dec 2006 18:07 Modified: 9 Mar 2007 4:41
Reporter: William Chiquito
Status: Closed
Category:Server: SP Severity:S3 (Non-critical)
Version:5.0.27-community-max OS:Microsoft Windows (Windows XP SP2)
Assigned to: Marc Alff Target Version:
Tags: functions, Cursors

[31 Dec 2006 18:07] William Chiquito
Description:
When call directly to sp "proc" not have problem with the cursors.

When call to sp "proc" from the function "func" for some reason are verifying if the
tables ("d" and "l") of the cursors ("g" and "h") exist, generating an error.

How to repeat:
Procedure:

DELIMITER $$

DROP PROCEDURE IF EXISTS `proc`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `proc`()
BEGIN
	declare h cursor for select value from l;
	declare g cursor for select value from d;
	select '1' as Valor;
    END$$

DELIMITER ;

Function:

DELIMITER $$

DROP FUNCTION IF EXISTS `func`$$

CREATE DEFINER=`root`@`localhost` FUNCTION `func`() RETURNS int(11)
BEGIN
	call proc();
	return 1;
    END$$

DELIMITER ;

Test 1:

/* WORK */
call proc();

Result:

Valor 
------
1 

Test 2:

/* NOT WORK */
SELECT func();

Result:

Error Code : 1146
Table '[schema].d' doesn't exist
(0 ms taken)
[1 Jan 2007 19:16] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[3 Jan 2007 19:04] Peter Pfandler
This issue also exists on Slackware linux, MySQL v 5.0.24.
[18 Jan 2007 23:33] Konstantin Osipov
This bug is a duplicate of Bug#8407 "Stored functions/triggers ignore exception handler"
[7 Mar 2007 2:08] Marc Alff
This bug has been fixed with Bug#8407.
[7 Mar 2007 23:04] Konstantin Osipov
Pushed into 5.0.38 and 5.1.17.
[9 Mar 2007 4:41] Jon Stephens
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 bug fix. More information about accessing the source trees is available at

    http://dev.mysql.com/doc/en/installing-source.html

Documented bugfix in 5.0.38 and 5.1.17 changelogs.