List:Commits« Previous MessageNext Message »
From:eugene Date:January 29 2008 8:21pm
Subject:bk commit into 5.0 tree (evgen:1.2593) BUG#30787
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen.  When evgen does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2008-01-29 23:21:18+03:00, evgen@stripped +3 -0
  Bug#30787: Stored function ignores user defined alias.
  
  Simple subselects are pulled into upper selects. This is done by substituting
  subselects with first item in the item list of the subselect. If an alias is
  set on the subselect it's set on the substituting item also. As this is done
  after fix_fields phase this alias isn't showed if substituting item is a
  stored function. This happens because the Item_func_sp::make_field function
  makes send field from its result_field and ignores user defined alias.
  
  Now when an alias is defined the Item_func_sp::make_field function sets it on
  the returned field.

  mysql-test/r/sp.result@stripped, 2008-01-29 23:20:08+03:00, evgen@stripped +17 -0
    Added a test case for the bug#30787: Stored function ignores user defined alias.

  mysql-test/t/sp.test@stripped, 2008-01-29 23:19:48+03:00, evgen@stripped +19 -0
    Added a test case for the bug#30787: Stored function ignores user defined alias.

  sql/item_func.cc@stripped, 2008-01-29 23:20:20+03:00, evgen@stripped +2 -0
    Bug#30787: Stored function ignores user defined alias.
    Now when an alias is defined the Item_func_sp::make_field function sets it on
    the returned field.

diff -Nrup a/mysql-test/r/sp.result b/mysql-test/r/sp.result
--- a/mysql-test/r/sp.result	2007-10-29 13:58:08 +03:00
+++ b/mysql-test/r/sp.result	2008-01-29 23:20:08 +03:00
@@ -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 -Nrup a/mysql-test/t/sp.test b/mysql-test/t/sp.test
--- a/mysql-test/t/sp.test	2007-10-29 13:58:08 +03:00
+++ b/mysql-test/t/sp.test	2008-01-29 23:19:48 +03:00
@@ -7700,6 +7700,25 @@ 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
 --echo # ------------------------------------------------------------------
diff -Nrup a/sql/item_func.cc b/sql/item_func.cc
--- a/sql/item_func.cc	2008-01-17 20:13:30 +03:00
+++ b/sql/item_func.cc	2008-01-29 23:20:20 +03:00
@@ -5515,6 +5515,8 @@ Item_func_sp::make_field(Send_field *tmp
   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;
 }
 
Thread
bk commit into 5.0 tree (evgen:1.2593) BUG#30787eugene29 Jan