diff options
-rw-r--r-- | mysql-test/r/sp.result | 17 | ||||
-rw-r--r-- | mysql-test/t/sp.test | 19 | ||||
-rw-r--r-- | sql/item_func.cc | 2 |
3 files changed, 38 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 061bbafd9a1..d93bc858cc3 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -6578,6 +6578,23 @@ DROP PROCEDURE db28318_a.t1; DROP PROCEDURE db28318_b.t2; DROP DATABASE db28318_a; DROP DATABASE db28318_b; +# +# Bug#30787: Stored function ignores user defined alias. +# +use test; +drop function if exists func30787; +create table t1(f1 int); +insert into t1 values(1),(2); +create function func30787(p1 int) returns int +begin +return p1; +end | +select (select func30787(f1)) as ttt from t1; +ttt +1 +2 +drop function func30787; +drop table t1; # ------------------------------------------------------------------ # -- End of 5.0 tests # ------------------------------------------------------------------ diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 785e7e3793c..b9cba0f489f 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -7699,6 +7699,25 @@ DROP PROCEDURE db28318_b.t2; DROP DATABASE db28318_a; DROP DATABASE db28318_b; +--echo # +--echo # Bug#30787: Stored function ignores user defined alias. +--echo # +use test; +--disable_warnings +drop function if exists func30787; +--enable_warnings +create table t1(f1 int); +insert into t1 values(1),(2); +delimiter |; +create function func30787(p1 int) returns int +begin + return p1; +end | +delimiter ;| +select (select func30787(f1)) as ttt from t1; +drop function func30787; +drop table t1; + --echo # ------------------------------------------------------------------ --echo # -- End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 639e069d24e..dbde4237511 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5515,6 +5515,8 @@ Item_func_sp::make_field(Send_field *tmp_field) DBUG_ENTER("Item_func_sp::make_field"); DBUG_ASSERT(sp_result_field); sp_result_field->make_field(tmp_field); + if (name) + tmp_field->col_name= name; DBUG_VOID_RETURN; } |