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

fixed case when real length very close to calculated (BUG#5150)

parent a43c40f1
...@@ -1176,3 +1176,10 @@ test.`f``1` () ...@@ -1176,3 +1176,10 @@ test.`f``1` ()
5 5
drop view v1; drop view v1;
drop function `f``1`; drop function `f``1`;
create function x () returns int return 5;
create view v1 as select x ();
select * from v1;
x ()
5
drop view v1;
drop function x;
...@@ -1116,3 +1116,12 @@ show create view v1; ...@@ -1116,3 +1116,12 @@ show create view v1;
select * from v1; select * from v1;
drop view v1; drop view v1;
drop function `f``1`; drop function `f``1`;
#
# tested problem when function name length close to ALIGN_SIZE
#
create function x () returns int return 5;
create view v1 as select x ();
select * from v1;
drop view v1;
drop function x;
...@@ -3271,12 +3271,14 @@ const char * ...@@ -3271,12 +3271,14 @@ const char *
Item_func_sp::func_name() const Item_func_sp::func_name() const
{ {
THD * thd= current_thd; THD * thd= current_thd;
/* Calculate length to avoud reallocation of string for sure */
uint len= ((m_name->m_db.length + uint len= ((m_name->m_db.length +
m_name->m_name.length)*2 + //characters*quoting m_name->m_name.length)*2 + //characters*quoting
2 + // ` and ` 2 + // ` and `
1 + // . 1 + // .
1); // end of string 1 + // end of string
String qname(alloc_root(&thd->mem_root, len), len, ALIGN_SIZE(1)); // to avoid String reallocation
String qname((char *)alloc_root(&thd->mem_root, len), len,
system_charset_info); system_charset_info);
qname.length(0); qname.length(0);
append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length); append_identifier(thd, &qname, m_name->m_db.str, m_name->m_db.length);
......
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