Bug #10242 Call to FLOOR() in sproc or func crashes 5.04 server
Submitted: 28 Apr 2005 20:12 Modified: 28 Apr 2005 21:38
Reporter: Peter Brawley (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.04 OS:Windows (WinXP)
Assigned to: CPU Architecture:Any

[28 Apr 2005 20:12] Peter Brawley
Description:
This function does nothing but declare two ints and assign the result of a call to FLOOR() to one of them. It crashes mysqld-max 5.04.

USE test;
DROP FUNCTION IF EXISTS Test;
DELIMITER |
CREATE FUNCTION Test() RETURNS INT
BEGIN
  DECLARE days INT default 7;
  DECLARE res INT DEFAULT 0;
  SET res = FLOOR(days/7);
  RETURN res;
END;
|
DELIMITER ;

How to repeat:
As above

Suggested fix:
None found.
[28 Apr 2005 21:38] MySQL Verification Team
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

c:\mysql\bin>mysql -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.6-beta-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> USE test;
Database changed
mysql> DROP FUNCTION IF EXISTS Test;
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> DELIMITER |
mysql> CREATE FUNCTION Test() RETURNS INT
    -> BEGIN
    ->   DECLARE days INT default 7;
    ->   DECLARE res INT DEFAULT 0;
    ->   SET res = FLOOR(days/7);
    ->   RETURN res;
    -> END;
    -> |
Query OK, 0 rows affected (0.03 sec)

mysql> DELIMITER ;
mysql> select Test();
+--------+
| Test() |
+--------+
|      1 |
+--------+
1 row in set (0.00 sec)