Bug #2219 cast on NULL value is not correct
Submitted: 26 Dec 2003 15:34 Modified: 12 Jan 2004 6:33
Reporter: Georg Richter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.2 OS:Linux (Linux)
Assigned to: MySQL Verification Team CPU Architecture:Any

[26 Dec 2003 15:34] Georg Richter
Description:
cast doesn't return correct result when converting NULL to numeric. 
When converting a NULL value to numeric data type NULL should be returned 
instead of 0. 

How to repeat:
mysql> select cast(NULL as date); 
+--------------------+ 
| cast(NULL as date) | 
+--------------------+ 
| NULL               | 
+--------------------+ 
1 row in set (0.00 sec) 
 
mysql> select cast(NULL as char); 
+--------------------+ 
| cast(NULL as char) | 
+--------------------+ 
| NULL               | 
+--------------------+ 
1 row in set (0.00 sec) 
 
mysql> select cast(NULL as signed); 
+----------------------+ 
| cast(NULL as signed) | 
+----------------------+ 
|                    0 | 
+----------------------+ 
1 row in set (0.00 sec)
[27 Dec 2003 6:50] 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:

Fix will come in 4.1.2
[12 Jan 2004 6:33] MySQL Verification Team
Committed.