Commit 21635469 authored by unknown's avatar unknown

Fixed BUG#3132: Stored function returns empty when used in union.


mysql-test/r/sp.result:
  Added testcase for BUG#3132.
mysql-test/t/sp.test:
  Added testcase for BUG#3132.
sql/item_func.cc:
  Set a useful max_length in Item_func_sp so field widths are correctly calculated.
parent afb15e96
...@@ -1353,6 +1353,13 @@ drop procedure bug2564_1| ...@@ -1353,6 +1353,13 @@ drop procedure bug2564_1|
drop procedure bug2564_2| drop procedure bug2564_2|
drop function bug2564_3| drop function bug2564_3|
drop function bug2564_4| 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| drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)| create table fac (n int unsigned not null primary key, f bigint unsigned)|
create procedure ifac(n int unsigned) create procedure ifac(n int unsigned)
......
...@@ -1551,6 +1551,15 @@ drop procedure bug2564_2| ...@@ -1551,6 +1551,15 @@ drop procedure bug2564_2|
drop function bug2564_3| drop function bug2564_3|
drop function bug2564_4| 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 # Some "real" examples
......
...@@ -3320,7 +3320,7 @@ Item_func_sp::fix_length_and_dec() ...@@ -3320,7 +3320,7 @@ Item_func_sp::fix_length_and_dec()
switch (m_sp->result()) { switch (m_sp->result()) {
case STRING_RESULT: case STRING_RESULT:
maybe_null= 1; maybe_null= 1;
max_length= 0; max_length= MAX_BLOB_WIDTH;
break; break;
case REAL_RESULT: case REAL_RESULT:
decimals= NOT_FIXED_DEC; decimals= NOT_FIXED_DEC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment