From 754c3f51ec6e0557b8c4ca2f141ee74075e11b48 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Jan 2008 23:46:26 +0300 Subject: Bug#30787: Stored function ignores user defined alias. Simple subselects are pulled into upper selects. This operation substitutes the pulled subselect for the first item from the select list of the subselect. If an alias is defined for a subselect it is inherited by the replacement item. As this is done after fix_fields phase this alias isn't showed if the replacement item is a stored function. This happens because the Item_func_sp::make_field function makes send field from its result_field and ignores the defined alias. Now when an alias is defined the Item_func_sp::make_field function sets it for the returned field. mysql-test/t/sp.test: Added a test case for the bug#30787: Stored function ignores user defined alias. mysql-test/r/sp.result: Added a test case for the bug#30787: Stored function ignores user defined alias. sql/item_func.cc: Bug#30787: Stored function ignores user defined alias. Now when an alias is defined the Item_func_sp::make_field function sets it for the returned field. --- mysql-test/r/sp.result | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mysql-test/r/sp.result') 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 # ------------------------------------------------------------------ -- cgit v1.2.1