Bug #2219 cast on NULL value is not correct
Submitted: 26 Dec 2003 16:34 Modified: 12 Jan 2004 7:33
Reporter: Georg Richter
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:4.1.2 OS:Linux (Linux)
Assigned to: Sinisa Milivojevic Target Version:

[26 Dec 2003 16: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 7:50] Sinisa Milivojevic
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 7:33] Sinisa Milivojevic
Committed.