Bug #20154 Empty string in text/varchar columns should not be displayed as NULL
Submitted: 30 May 2006 20:29 Modified: 30 May 2006 21:12
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.21 OS:Linux (Debian GNU/Linux Sid)
Assigned to: CPU Architecture:Any

[30 May 2006 20:29] Christian Hammers
Description:
As reported as Debian Bug #368663 by Larry Holish <ljholish@speakeasy.net> and confirmed by me:
An empty string ("") in varchar and text columns should not be displayed as NULL it the client
as it does not pass the "is null" test.

bye,

-christian-

How to repeat:
mysql> CREATE TABLE t (a varchar(255) default null,   b text default null);
mysql> INSERT INTO t VALUES ("", "");

mysql> SELECT * FROM t;
+------+------+
| a    | b    |
+------+------+
| NULL | NULL | 
+------+------+
1 row in set (0.00 sec)

Suggested fix:
Display "" instead of NULL.
[30 May 2006 20:31] Christian Hammers
I've just found #20067 which describes the same problem but was reported in the category
"MySQL Query Browser". It should probably reassigned to "Server", too, and merged with this one.
[30 May 2006 21:12] Valeriy Kravchuk
Thank you for a problem report. Looks like a duplicate of bug #19564, already fixed in 5.0.22. Please, check.

mysql> CREATE TABLE t (a varchar(255) default null,   b text default null);
Query OK, 0 rows affected (0.02 sec)

mysql> INSERT INTO t VALUES ("", "");
Query OK, 1 row affected (0.01 sec)

mysql>  SELECT * FROM t;
+------+------+
| a    | b    |
+------+------+
|      |      |
+------+------+
1 row in set (0.01 sec)

mysql> select version();
+------------+
| version()  |
+------------+
| 5.0.23-log |
+------------+
1 row in set (0.01 sec)