Bug #10129 Mathematical function with 18 input variables returns null
Submitted: 24 Apr 2005 16:34 Modified: 10 Aug 2005 11:45
Reporter: Nikos Sarris Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: User-defined functions ( UDF ) Severity:S2 (Serious)
Version:5.0.4-beta OS:Windows (WinXP Pro SP2)
Assigned to: Alexey Botchkov CPU Architecture:Any

[24 Apr 2005 16:34] Nikos Sarris
Description:
The following function returns "null" , whatever the input variables:

CREATE FUNCTION `test`.`f_M2`(m int,c float,g float,a float,b float,Dxm float,Nxm10 float,Dxm10 float,Nx float,Nxm float,Sx1 float,Sxm float,Dx float,Rx float,Rxm float,Mxm float,Tx1 float,Txm float) 
RETURNS float

BEGIN

RETURN (12*(8.5311*Dxm+Nxm10-0.4583*Dxm10))/((1-c)*(Nx-Nxm+g*(Sx1-Sxm-(m-1)*Nxm))-a*(1+0.5*g*(m-1))*Nx-b*Dx-(Rx-Rxm-m*Mxm)-g*(Tx1-Txm-(m-1)*Rxm-0.5*m*(m-1)*Mxm));

END;

How to repeat:
CREATE FUNCTION `test`.`f_M2`(m int,c float,g float,a float,b float,Dxm float,Nxm10 float,Dxm10 float,Nx float,Nxm float,Sx1 float,Sxm float,Dx float,Rx float,Rxm float,Mxm float,Tx1 float,Txm float) 
RETURNS float

BEGIN

RETURN (12*(8.5311*Dxm+Nxm10-0.4583*Dxm10))/((1-c)*(Nx-Nxm+g*(Sx1-Sxm-(m-1)*Nxm))-a*(1+0.5*g*(m-1))*Nx-b*Dx-(Rx-Rxm-m*Mxm)-g*(Tx1-Txm-(m-1)*Rxm-0.5*m*(m-1)*Mxm));

END;

In query browser : SELECT f_M2(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
returns single line/column with NULL as result
[24 Apr 2005 18:02] Jorge del Conde
Neither our console client nor query browser returned NULL:

mysql> SELECT f_M2(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
    -> //
+-------------------------------------------+
| f_M2(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) |
+-------------------------------------------+
|                          -108.87359619141 |
+-------------------------------------------+

This was tested on 5.0.5 from bk
[24 Apr 2005 20:34] Hartmut Holzgraefe
seems to be a windows only bug, 5.0.4 on linux gives the expected result
[24 Apr 2005 20:39] Nikos Sarris
Here's the imyodbc output

+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> SELECT f_M2(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)
+------------------------------------------+
| f_M2(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)|
+------------------------------------------+
|                                          |
+------------------------------------------+
SQLRowCount returns 1
1 rows fetched
[10 Aug 2005 11:45] Alexey Botchkov
Tried this with 5.0.7 on WinXP.
The SELECT You suggested produced proper result.
Probably the error was fixed meanwhile.