From 078f717804acf940cb9fc4ffeaf81f0c8dc05fd6 Mon Sep 17 00:00:00 2001 From: "pem@mysql.comhem.se" <> Date: Thu, 10 Jun 2004 17:07:53 +0200 Subject: [PATCH] Fixed BUG#3132: Stored function returns empty when used in union. --- mysql-test/r/sp.result | 7 +++++++ mysql-test/t/sp.test | 9 +++++++++ sql/item_func.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 1e1558f91af..5cdffbdc52c 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -1353,6 +1353,13 @@ drop procedure bug2564_1| drop procedure bug2564_2| drop function bug2564_3| drop function bug2564_4| +create function bug3132(s char(20)) returns char(50) +return concat('Hello, ', s, '!')| +select bug3132('Bob') union all select bug3132('Judy')| +bug3132('Bob') +Hello, Bob! +Hello, Judy! +drop function bug3132| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| create procedure ifac(n int unsigned) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 81b7b440c4d..2571a5b0674 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -1551,6 +1551,15 @@ drop procedure bug2564_2| drop function bug2564_3| drop function bug2564_4| +# +# BUG#3132 +# +create function bug3132(s char(20)) returns char(50) + return concat('Hello, ', s, '!')| + +select bug3132('Bob') union all select bug3132('Judy')| +drop function bug3132| + # # Some "real" examples diff --git a/sql/item_func.cc b/sql/item_func.cc index c4cb8a7a2f0..ac7025a391a 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3320,7 +3320,7 @@ Item_func_sp::fix_length_and_dec() switch (m_sp->result()) { case STRING_RESULT: maybe_null= 1; - max_length= 0; + max_length= MAX_BLOB_WIDTH; break; case REAL_RESULT: decimals= NOT_FIXED_DEC;