Bug #72335 | INCORRECT BIT COLUMN VALUE RETURNED IN THE STORED PROCEDURE OUT PARAM | ||
---|---|---|---|
Submitted: | 14 Apr 2014 6:16 | Modified: | 21 Apr 2014 8:47 |
Reporter: | Ashish Kumar | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[14 Apr 2014 6:16]
Ashish Kumar
[15 Apr 2014 9:55]
MySQL Verification Team
Hello Ashish, Thank you for the report. Could you try below SP? delimiter // DROP PROCEDURE IF EXISTS atstgt.SXRGXT_GETDESC; CREATE PROCEDURE atstgt.SXRGXT_GETDESC (out flagout BIT(64)) BEGIN select flag into flagout from atstgt.SXRGXT_XSYSTEM where STATE ='FL'; END // delimiter ; ^^ removed BIN() from SELECT Imho, you are copying into a BIT type var and hence no need to use bin(flag) explicitly.. // I tried it on 5.6.17 and works for me.. ================================================ mysql> create database atstgt; Query OK, 1 row affected (0.00 sec) mysql> use atstgt; Database changed mysql> mysql> DROP TABLE IF EXISTS atstgt.SXRGXT_XSYSTEM; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> CREATE TABLE atstgt.SXRGXT_XSYSTEM ( STATE CHAR(2),DESCRIPTION VARCHAR(50), flag bit(8) ); Query OK, 0 rows affected (0.03 sec) mysql> INSERT INTO atstgt.SXRGXT_XSYSTEM VALUES ('FL' ,'Florida',b'1'); Query OK, 1 row affected (0.01 sec) mysql> delimiter // mysql> DROP PROCEDURE IF EXISTS atstgt.SXRGXT_GETDESC; -> CREATE PROCEDURE atstgt.SXRGXT_GETDESC (out flagout BIT(64)) -> BEGIN -> select flag into flagout from atstgt.SXRGXT_XSYSTEM where STATE ='FL'; -> END // Query OK, 0 rows affected, 1 warning (0.00 sec) Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> call atstgt.SXRGXT_GETDESC(@flagout); Query OK, 1 row affected (0.00 sec) mysql> select @flagout; +----------+ | @flagout | +----------+ | 1 | +----------+ 1 row in set (0.00 sec) ================================================
[21 Apr 2014 7:50]
Ashish Kumar
Thank you for update. So for using bit in stored procedure outparam , do we always need to define its length as 64 like below ? Will it not work for smaller lengths ? CREATE PROCEDURE atstgt.SXRGXT_GETDESC (out flagout BIT(64)) I still have to test it for the boundary values. Thanks,
[21 Apr 2014 8:47]
MySQL Verification Team
You may have to test boundary values, but if you assign a value to a BIT(64) column that is less than 64 bits long, the value is padded on the left with zeros. For example, assigning a value of b'101' to a BIT(6) column is, in effect, the same as assigning b'000101'. We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug. Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/ Thank you for your interest in MySQL.