Bug #10588 Addition of two variables with binary value produce incorrect result.
Submitted: 12 May 2005 11:18 Modified: 13 May 2005 8:42
Reporter: Disha Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.5 Beta OS:Windows (Windows 2000 Server)
Assigned to: CPU Architecture:Any

[12 May 2005 11:18] Disha
Description:
If we do an addition of two variables with binary values, the result is zero (which is incorrect). No warning or error is displayed. If we try actual binary values insted of the variables then the addition works correctly.

How to repeat:
1. Start the MySQL client and connect to the database with valid user and password.
2. Set the delimiter to //
3. Create two variables with binary values and two variables with non binary values:
   set @a=b'1'//
   set @b=b'1'//
   set @c=1//
   set @d=1//

4. Now execute the follows which adds two values:
   select (b'1' + b'1')//
   select (@a + @b)//
   select (@c + @d)//

Expected Results: 
1. The output of all commands should be same.

Actual Results: 
1. The command using variables with binary values fails. The command output for all commands is as follows:

   mysql>    select (b'1' + b'1')//
   +---------------+
   | (b'1' + b'1') |
   +---------------+
   |             2 |
   +---------------+
   1 row in set (0.00 sec)
   
   mysql>    select (@a + @b)//
   +-----------+
   | (@a + @b) |
   +-----------+
   |         0 |
   +-----------+
   1 row in set (0.00 sec)
   
   mysql>    select (@c + @d)//
   +-----------+
   | (@c + @d) |
   +-----------+
   |         2 |
   +-----------+
   1 row in set (0.00 sec)
   
   mysql>
[12 May 2005 11:42] MySQL Verification Team
Verified on Linux too.
[13 May 2005 8:42] Sergei Golubchik
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

see also bug#10577