From 0c17b6ed37011ba2997f129f2b32f811a397eab5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Jul 2005 08:11:23 +0200 Subject: [PATCH] fix for bug#8692 mysql-test/r/sp.result: added expected result for bug #8692 mysql-test/t/sp.test: added testcase for bug #8692 sql/protocol_cursor.cc: fixed detecting of null fields: A field contains a null value only if length is NULL_LENGTH --- mysql-test/r/sp.result | 24 ++++++++++++++++++++++++ mysql-test/t/sp.test | 28 ++++++++++++++++++++++++++++ sql/protocol_cursor.cc | 3 +-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index fd63204e32f..69900edf3d9 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3099,4 +3099,28 @@ select @@sort_buffer_size| 1000000 set @@sort_buffer_size = @x| drop procedure bug9538| +drop procedure if exists bug8692| +create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))| +insert into t3 values ('', '', '', '', '', '', NULL)| +Warnings: +Warning 1265 Data truncated for column 'c3' at row 1 +create procedure bug8692() +begin +declare v1 VARCHAR(10); +declare v2 VARCHAR(10); +declare v3 VARCHAR(10); +declare v4 VARCHAR(10); +declare v5 VARCHAR(10); +declare v6 VARCHAR(10); +declare v7 VARCHAR(10); +declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3; +open c8692; +fetch c8692 into v1,v2,v3,v4,v5,v6,v7; +select v1, v2, v3, v4, v5, v6, v7; +end| +call bug8692()| +v1 v2 v3 v4 v5 v6 v7 + NULL +drop procedure bug8692| +drop table t3| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index d9e6163cbc7..1a35df40a17 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3876,6 +3876,34 @@ set @@sort_buffer_size = @x| drop procedure bug9538| +# +# BUG#8692: Cursor fetch of empty string +# +--disable_warnings +drop procedure if exists bug8692| +--enable_warnings +create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))| +insert into t3 values ('', '', '', '', '', '', NULL)| + +create procedure bug8692() +begin + declare v1 VARCHAR(10); + declare v2 VARCHAR(10); + declare v3 VARCHAR(10); + declare v4 VARCHAR(10); + declare v5 VARCHAR(10); + declare v6 VARCHAR(10); + declare v7 VARCHAR(10); + declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3; + open c8692; + fetch c8692 into v1,v2,v3,v4,v5,v6,v7; + select v1, v2, v3, v4, v5, v6, v7; +end| + +call bug8692()| +drop procedure bug8692| +drop table t3| + # # BUG#NNNN: New bug synopsis # diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index ed2d0b583d0..093a2bf2b90 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -114,8 +114,7 @@ bool Protocol_cursor::write() for (; cur_field < fields_end; cur_field++, data_tmp++) { - if ((len= net_field_length((uchar **)&cp)) == 0 || - len == NULL_LENGTH) + if ((len= net_field_length((uchar **)&cp)) == NULL_LENGTH) { *data_tmp= 0; }