Bug #28157 CHAR(0) displays NULL
Submitted: 30 Apr 2007 3:44 Modified: 30 Apr 2007 5:10
Reporter: Mike Painter Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Data Types Severity:S3 (Non-critical)
Version:5.0.22 OS:Any
Assigned to: CPU Architecture:Any

[30 Apr 2007 3:44] Mike Painter
Description:
CHAR(0) fields, which should be NULL or "" are always displayed as NULL in the query results regardless of their value.

How to repeat:
CREATE TABLE a ( a1 CHAR(0) NULL );
INSERT INTO a VALUES ( "" ), ( NULL );

SELECT a1, a1 IS NULL FROM a;

Current Result:
+------+------------+
| a1   | a1 IS NULL |
+------+------------+
| NULL |          0 |
| NULL |          1 |
+------+------------+

Should Be:
+------+------------+
| a1   | a1 IS NULL |
+------+------------+
|      |          0 |
| NULL |          1 |
+------+------------+

Suggested fix:
Make CHAR(0) fields with a value of "" return "" instead of NULL
[30 Apr 2007 5:10] Valeriy Kravchuk
Please, use newer version, 5.0.37. It works exactly as you expected there.