From a43c40f10f264c236f9cbe02ad1b9b63787bcecd Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Mon, 30 Aug 2004 21:47:52 +0300 Subject: [PATCH] fixed printing of stored procedure functions names (BUG#5149) --- mysql-test/r/view.result | 10 ++++++++++ mysql-test/t/view.test | 10 ++++++++++ sql/item_func.cc | 15 ++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 18da4882894..28162334546 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1166,3 +1166,13 @@ Table Create Table v3 CREATE VIEW `test`.`v3` AS select `v1`.`col1` AS `a`,`v2`.`col1` AS `b` from `test`.`v1` join `test`.`v2` where (`v1`.`col1` = `v2`.`col1`) drop view v3, v2, v1; drop table t2, t1; +create function `f``1` () returns int return 5; +create view v1 as select test.`f``1` (); +show create view v1; +Table Create Table +v1 CREATE VIEW `test`.`v1` AS select `test`.`f``1`() AS `test.``f````1`` ()` +select * from v1; +test.`f``1` () +5 +drop view v1; +drop function `f``1`; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index e73133afa67..4f5a6f3ddc4 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1106,3 +1106,13 @@ select * from v3; show create view v3; drop view v3, v2, v1; drop table t2, t1; + +# +# VIEW based on functions with complex names +# +create function `f``1` () returns int return 5; +create view v1 as select test.`f``1` (); +show create view v1; +select * from v1; +drop view v1; +drop function `f``1`; diff --git a/sql/item_func.cc b/sql/item_func.cc index c2c93586af8..f5a9d9ef9bc 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3270,9 +3270,22 @@ Item_func_sp::Item_func_sp(sp_name *name, List &list) const char * Item_func_sp::func_name() const { - return m_name->m_name.str; + THD * thd= current_thd; + uint len= ((m_name->m_db.length + + m_name->m_name.length)*2 + //characters*quoting + 2 + // ` and ` + 1 + // . + 1); // end of string + String qname(alloc_root(&thd->mem_root, len), len, + system_charset_info); + qname.length(0); + append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length); + qname.append('.'); + append_identifier(thd, &qname, m_name->m_name.str, m_name->m_name.length); + return qname.ptr(); } + int Item_func_sp::execute(Item **itp) {