Bug #13716 Stored Proc: INT variables DECLAREd and then SELECTed out always return as int64
Submitted: 3 Oct 2005 15:01 Modified: 5 Oct 2007 12:30
Reporter: Reggie Burnett Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0.16-BK OS:Linux (Linux)
Assigned to: Assigned Account CPU Architecture:Any

[3 Oct 2005 15:01] Reggie Burnett
Description:
variables declared as INT inside a stored procedure and then returned through a select statement get returned as int64

How to repeat:
This sproc will show it.

CREATE PROCEDURE `mydb`.`myProc`
(
)
BEGIN
	DECLARE myVar INT;
	
	SET MyVar := 1;	
		
	SELECT myVar;
END

the column returned should be int32 but is always returned as int64.
[4 Oct 2005 12:53] Reggie Burnett
Platform was ia32 running windows server 2003 (I don't believe flavor of Windows will matter).  I did not check on Linux but I would suspect that the problem appears there too.
[5 Nov 2005 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[7 Nov 2005 13:58] Valeriy Kravchuk
I was able to provide a similar self-containing test case that demonstrates this bug:

mysql> delimiter //
mysql> create function myF() returns int begin   declare myVar int;   set myVar
:= 1;   return myVar; end//
Query OK, 0 rows affected (0,01 sec)

mysql> create view vvv as select myF()//
Query OK, 0 rows affected (0,02 sec)

mysql> desc vvv//
+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| myF() | bigint(11) | YES  |     | NULL    |       |
+-------+------------+------+-----+---------+-------+
1 row in set (0,00 sec)

mysql> select version()//
+-----------+
| version() |
+-----------+
| 5.0.16    |
+-----------+
1 row in set (0,01 sec)

So, obviously, int bevomes bigint somehow. Verified on taday's 5.0-BK build (ChangeSet@1.1972, 2005-11-05 22:45:54-08:00, igor@rurik.mysql.com) on:

[openxs@Fedora 5.0]$ uname -a
Linux Fedora 2.4.22-1.2115.nptl #1 Wed Oct 29 15:42:51 EST 2003 i686 i686 i386 GNU/Linux
[5 Oct 2007 12:30] Alexander Nozdrin
This is duplicate of BUG#20550.