Commit 0c08d2b2 authored by unknown's avatar unknown

Bug #28605: SHOW CREATE VIEW with views using stored_procedures no

 longer showing SP names.
SHOW CREATE VIEW uses Item::print() methods to reconstruct the 
statement text from the parse tree.
The print() method for stored procedure calls needs allocate 
space to print the function's quoted name.
It was incorrectly calculating the length of the buffer needed 
(was too short).
Fixed to reflect the actual space needed.


mysql-test/r/sp.result:
  Bug #28605: test case
mysql-test/t/sp.test:
  Bug #28605: test case
sql/item_func.cc:
  Bug #28605: fixed the string length calculation
parent e5ab3b7e
...@@ -6152,3 +6152,14 @@ count(*) ...@@ -6152,3 +6152,14 @@ count(*)
3 3
drop table t1,t2; drop table t1,t2;
drop function bug27354; drop function bug27354;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1`
DROP VIEW v1;
DROP FUNCTION metered;
DROP TABLE t1;
End of 5.0 tests
...@@ -7112,3 +7112,23 @@ select count(*) from t1 /* must be 3 */; ...@@ -7112,3 +7112,23 @@ select count(*) from t1 /* must be 3 */;
drop table t1,t2; drop table t1,t2;
drop function bug27354; drop function bug27354;
#
# Bug #28605: SHOW CREATE VIEW with views using stored_procedures no longer
# showing SP names.
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP FUNCTION metered;
DROP TABLE t1;
--echo End of 5.0 tests
...@@ -5213,10 +5213,11 @@ Item_func_sp::func_name() const ...@@ -5213,10 +5213,11 @@ Item_func_sp::func_name() const
{ {
THD *thd= current_thd; THD *thd= current_thd;
/* Calculate length to avoid reallocation of string for sure */ /* Calculate length to avoid reallocation of string for sure */
uint len= ((m_name->m_explicit_name ? m_name->m_db.length : 0 + uint len= (((m_name->m_explicit_name ? m_name->m_db.length : 0) +
m_name->m_name.length)*2 + //characters*quoting m_name->m_name.length)*2 + //characters*quoting
2 + // ` and ` 2 + // ` and `
1 + // . (m_name->m_explicit_name ?
3 : 0) + // '`', '`' and '.' for the db
1 + // end of string 1 + // end of string
ALIGN_SIZE(1)); // to avoid String reallocation ALIGN_SIZE(1)); // to avoid String reallocation
String qname((char *)alloc_root(thd->mem_root, len), len, String qname((char *)alloc_root(thd->mem_root, len), len,
......
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