From 2e72ae3d818cef271dc348ba4ba781f66d4c1ec3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 May 2006 22:35:51 -0400 Subject: [PATCH] Bug#19564: mysql displays NULL instead of space Correct a bug (that I introduced, after using Oracle's database software for too many years) where the length of the database-sent data is incorrectly used to infer NULLness. client/mysql.cc: No longer use the length of the data to infer whether it is NULL or not. mysql-test/r/mysql.result: Add result and version marker, and correct previous result. mysql-test/t/mysql.test: Add test and version marker --- client/mysql.cc | 2 +- mysql-test/r/mysql.result | 12 ++++++++++-- mysql-test/t/mysql.test | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 7b46aaf67ce..50e5569a0ec 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2319,7 +2319,7 @@ print_table_data(MYSQL_RES *result) uint extra_padding; /* If this column may have a null value, use "NULL" for empty. */ - if (! not_null_flag[off] && (lengths[off] == 0)) + if (! not_null_flag[off] && (cur[off] == NULL)) { buffer= "NULL"; data_length= 4; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index a067d3ad0f8..4b7084e813c 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -74,7 +74,7 @@ c_cp932 +----------------------+------------+--------+ | >a < | b | 123421 | | >a < | 0123456789 | 4 | -| >abcd< | NULL | 4 | +| >abcd< | | 4 | +----------------------+------------+--------+ +------+------+---------------------------+ | i | j | k | @@ -94,6 +94,14 @@ c_cp932 | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | i | int(11) | YES | | NULL | | -| j | int(11) | NO | | NULL | | +| j | int(11) | NO | | | | | k | int(11) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ ++------+------+ +| i | s1 | ++------+------+ +| 1 | x | +| 2 | NULL | +| 3 | | ++------+------+ +End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index e76553f42e7..ac4c323f51e 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -72,3 +72,11 @@ drop table t1; # --exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;" +# +# Bug#19564: mysql displays NULL instead of space +# +--exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;" + +--echo End of 5.0 tests + +