Bug #23515 Varibles hide columns with the same name
Submitted: 20 Oct 2006 20:01 Modified: 20 Oct 2006 22:12
Reporter: Brian Miezejewski Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.24a OS:Windows (Windows)
Assigned to: CPU Architecture:Any
Tags: columns, stored procedure, variables

[20 Oct 2006 20:01] Brian Miezejewski
Description:
Defining a variable name with the same name as a column name will hide accesses to the column in the stored procedure. This occurs for both a straight select that is returned as a result set or in a cursor that is accessed in the stored procedure one record at a time.

How to repeat:
drop table if exists bugTab1 ;

create table bugTab1 ( x int, y int, primary key(x)) ;

insert into bugTab1 values(1,1) ;
insert into bugTab1 values(2,2) ;

DELIMITER $$;

DROP PROCEDURE IF EXISTS `test`.`bug1`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `bug1`()
BEGIN
    Select x,y from bugTab1 ;
    BEGIN
        DECLARE x int ;
	DECLARE y int ;
	SET x = 99 ;
        SET Y = 88 ;
	
	SELECT x,y from bugTab1 ;	
    END ;
END$$

DELIMITER ;$$

call bug1() ;
[20 Oct 2006 22:12] Kolbe Kegel
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/

http://dev.mysql.com/doc/refman/5.0/en/routine-restrictions.html
http://dev.mysql.com/doc/refman/5.0/en/select-into-statement.html