1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
unknown
2008-01-31 23:46:26 +03:00
parent e30a0dda8f
commit 754c3f51ec
3 changed files with 38 additions and 0 deletions

View File

@ -6578,6 +6578,23 @@ DROP PROCEDURE db28318_a.t1;
DROP PROCEDURE db28318_b.t2; DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a; DROP DATABASE db28318_a;
DROP DATABASE db28318_b; 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 # -- End of 5.0 tests
# ------------------------------------------------------------------ # ------------------------------------------------------------------

View File

@ -7699,6 +7699,25 @@ DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a; DROP DATABASE db28318_a;
DROP DATABASE db28318_b; 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 # ------------------------------------------------------------------
--echo # -- End of 5.0 tests --echo # -- End of 5.0 tests

View File

@ -5515,6 +5515,8 @@ Item_func_sp::make_field(Send_field *tmp_field)
DBUG_ENTER("Item_func_sp::make_field"); DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field); DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field); sp_result_field->make_field(tmp_field);
if (name)
tmp_field->col_name= name;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }