Commit a43c40f1 authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fixed printing of stored procedure functions names (BUG#5149)

parent 508fb5aa
...@@ -1166,3 +1166,13 @@ Table Create Table ...@@ -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`) 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 view v3, v2, v1;
drop table t2, t1; 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`;
...@@ -1106,3 +1106,13 @@ select * from v3; ...@@ -1106,3 +1106,13 @@ select * from v3;
show create view v3; show create view v3;
drop view v3, v2, v1; drop view v3, v2, v1;
drop table t2, t1; 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`;
...@@ -3270,9 +3270,22 @@ Item_func_sp::Item_func_sp(sp_name *name, List<Item> &list) ...@@ -3270,9 +3270,22 @@ Item_func_sp::Item_func_sp(sp_name *name, List<Item> &list)
const char * const char *
Item_func_sp::func_name() const 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 int
Item_func_sp::execute(Item **itp) Item_func_sp::execute(Item **itp)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment