Bug #8540 Local variable overrides an alias
Submitted: 16 Feb 2005 11:39 Modified: 16 Feb 2005 15:34
Reporter: Alexander Keremidarski Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:Any (any)
Assigned to: Per-Erik Martin CPU Architecture:Any

[16 Feb 2005 11:39] Alexander Keremidarski
Description:
See How To repeat

How to repeat:
CREATE PROCEDURE t()
BEGIN
  DECLARE x INT DEFAULT NULL;
  SET x = 1;
  SELECT x AS y, x+0 AS z;
END

CALL t3()//
+---+------+
| x | z    |
+---+------+
| 1 |    1 |
+---+------+

Note the column names in the result set. 
They should be `y`, `z`  according to the aliases. When the declared value isused alone in SELECT it somehow overrides the alias.

If the SELECT into the procedure contains the 

CREATE PROCEDURE t2() BEGIN DECLARE x INT DEFAULT NULL; SET x = 1; SELECT x+0 AS y; END//