Bug #9559 Functions: Numeric Operations using -ve value gives incorrect results.
Submitted: 1 Apr 2005 14:55 Modified: 31 May 2005 11:01
Reporter: Disha Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.3 Beta OS:Windows (Windows 2003)
Assigned to: Per-Erik Martin CPU Architecture:Any

[1 Apr 2005 14:55] Disha
Description:
If a function returns the result of a numeric operation, in which a negative value is used, the function always returns 0 regardless of the values passed.

This works fine when used in a stored procedure.

How to repeat:
delimiter //
Drop function if exists fn1//
Create function fn1() returns INT  
Begin
             set @y = -6/2;
	return @y;
End//
Select fn1()//

Actual Result:
	+---------+
	| fn1(15)  |
	+---------+
	|       0    |
	+---------+

Expected Result:
	+---------+
	| fn1(15)  |
	+---------+
	|       -3   |
	+---------+
	

Suggested fix:
[1 Apr 2005 15:02] Disha
Updated version
[27 May 2005 18:35] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/25316