Commit fa8a74b3 authored by unknown's avatar unknown

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


mysql-test/r/view.result:
  tested problem when function name length close to ALIGN_SIZE
mysql-test/t/view.test:
  tested problem when function name length close to ALIGN_SIZE
sql/item_func.cc:
  fixed case when real length very close to calculated (less then ALIGN)
parent 36b5ed33
......@@ -1176,3 +1176,10 @@ test.`f``1` ()
5
drop view v1;
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;
select * from v1;
drop view v1;
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 *
Item_func_sp::func_name() const
{
THD * thd= current_thd;
/* Calculate length to avoud reallocation of string for sure */
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,
1 + // end of string
ALIGN_SIZE(1)); // to avoid String reallocation
String qname((char *)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);
......
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