Bug #25345 Cursors from Functions
Submitted: 31 Dec 2006 17:07 Modified: 9 Mar 2007 3:41
Reporter: William Chiquito Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0.27-community-max OS:Windows (Windows XP SP2)
Assigned to: Marc ALFF CPU Architecture:Any
Tags: Cursors, functions

[31 Dec 2006 17: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 18:16] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[3 Jan 2007 18:04] Peter Pfandler
This issue also exists on Slackware linux, MySQL v 5.0.24.
[18 Jan 2007 22:33] Konstantin Osipov
This bug is a duplicate of Bug#8407 "Stored functions/triggers ignore exception handler"
[7 Mar 2007 1:08] Marc ALFF
This bug has been fixed with Bug#8407.
[7 Mar 2007 22:04] Konstantin Osipov
Pushed into 5.0.38 and 5.1.17.
[9 Mar 2007 3: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.