Commit a6ebd634 authored by gkodinov/kgeorge@magare.gmz's avatar gkodinov/kgeorge@magare.gmz
Browse files

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.
parent 48fe2802
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -6152,3 +6152,14 @@ count(*)
3
drop table t1,t2;
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
+20 −0
Original line number Diff line number Diff line
@@ -7112,3 +7112,23 @@ select count(*) from t1 /* must be 3 */;

drop table t1,t2;
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
+3 −2
Original line number Diff line number Diff line
@@ -5213,10 +5213,11 @@ Item_func_sp::func_name() const
{
  THD *thd= current_thd;
  /* 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
             2 +                         // ` and `
             1 +                         // .
             (m_name->m_explicit_name ?
              3 : 0) +                   // '`', '`' and '.' for the db
             1 +                         // end of string
             ALIGN_SIZE(1));             // to avoid String reallocation
  String qname((char *)alloc_root(thd->mem_root, len), len,