MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:pem Date:November 15 2005 12:14pm
Subject:bk commit into 5.0 tree (pem:1.1962) BUG#14723
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of pem. When pem does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1962 05/11/15 13:10:12 pem@stripped +3 -0
  Fixed BUG#14723: Dumping of stored functions seems to cause corruption
                   in the function body
    Changed the way the end of query was found from the lex state.
    The routine body was not extracted correctly when using the
    /*!version ... */ wrapper (in dump files); for some types of routines
    (e.g. with a label at the first begin), the trailing "*/" was not skipped.
    This is a recommit for the 5.0.16-release tree.

  sql/sp_head.cc
    1.194 05/11/15 13:09:36 pem@stripped +14 -11
    Changed the way the end of the definition and body is found from the lex state.
    In the case of /*!version */ wrappers we must take the trailing " */" into account.

  mysql-test/t/sp.test
    1.163 05/11/15 13:09:36 pem@stripped +32 -0
    New test case for BUG#14723.

  mysql-test/r/sp.result
    1.170 05/11/15 13:09:36 pem@stripped +31 -0
    New test case for BUG#14723.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pem
# Host:	mysql.comhem.se
# Root:	/usr/home/pem/bug14723-5016/mysql-5.0-release

--- 1.169/mysql-test/r/sp.result	2005-11-03 12:20:07 +01:00
+++ 1.170/mysql-test/r/sp.result	2005-11-15 13:09:36 +01:00
@@ -3617,4 +3617,35 @@
 drop table t3, t4|
 drop procedure bug14210|
 set @@session.max_heap_table_size=default|
+drop function if exists bug14723|
+drop procedure if exists bug14723|
+/*!50003 create function bug14723()
+returns bigint(20)
+main_loop: begin
+return 42;
+end */;;
+show create function bug14723;;
+Function	sql_mode	Create Function
+bug14723		CREATE FUNCTION `bug14723`() RETURNS bigint(20)
+main_loop: begin
+return 42;
+end
+select bug14723();;
+bug14723()
+42
+/*!50003 create procedure bug14723()
+main_loop: begin
+select 42;
+end */;;
+show create procedure bug14723;;
+Procedure	sql_mode	Create Procedure
+bug14723		CREATE PROCEDURE `bug14723`()
+main_loop: begin
+select 42;
+end
+call bug14723();;
+42
+42
+drop function bug14723|
+drop procedure bug14723|
 drop table t1,t2;

--- 1.162/mysql-test/t/sp.test	2005-11-03 12:20:07 +01:00
+++ 1.163/mysql-test/t/sp.test	2005-11-15 13:09:36 +01:00
@@ -4541,6 +4541,38 @@
 drop procedure bug14210|
 set @@session.max_heap_table_size=default|
 
+
+#
+# BUG#1473: Dumping of stored functions seems to cause corruption in
+#           the function body
+#
+--disable_warnings
+drop function if exists bug14723|
+drop procedure if exists bug14723|
+--enable_warnings
+
+delimiter ;;|
+/*!50003 create function bug14723()
+ returns bigint(20)
+main_loop: begin
+  return 42;
+end */;;
+show create function bug14723;;
+select bug14723();;
+
+/*!50003 create procedure bug14723()
+main_loop: begin
+  select 42;
+end */;;
+show create procedure bug14723;;
+call bug14723();;
+
+delimiter |;;
+
+drop function bug14723|
+drop procedure bug14723|
+
+
 #
 # BUG#NNNN: New bug synopsis
 #

--- 1.193/sql/sp_head.cc	2005-10-21 13:07:50 +02:00
+++ 1.194/sql/sp_head.cc	2005-11-15 13:09:36 +01:00
@@ -476,7 +476,7 @@
 sp_head::init_strings(THD *thd, LEX *lex, sp_name *name)
 {
   DBUG_ENTER("sp_head::init_strings");
-  uint n;			/* Counter for nul trimming */ 
+  uchar *endp;                  /* Used to trim the end */
   /* During parsing, we must use thd->mem_root */
   MEM_ROOT *root= thd->mem_root;
 
@@ -509,17 +509,20 @@
                                (char *)m_param_begin, m_params.length);
   }
 
-  m_body.length= lex->ptr - m_body_begin;
-  /* Trim nuls at the end */
-  n= 0;
-  while (m_body.length && m_body_begin[m_body.length-1] == '\0')
-  {
-    m_body.length-= 1;
-    n+= 1;
-  }
+  /* If ptr has overrun end_of_query then end_of_query is the end */
+  endp= (lex->ptr > lex->end_of_query ? lex->end_of_query : lex->ptr);
+  /*
+    Trim "garbage" at the end. This is sometimes needed with the
+    "/ * ! VERSION... * /" wrapper in dump files.
+  */
+  while (m_body_begin < endp &&
+         (endp[-1] <= ' ' || endp[-1] == '*' ||
+          endp[-1] == '/' || endp[-1] == ';'))
+    endp-= 1;
+
+  m_body.length= endp - m_body_begin;
   m_body.str= strmake_root(root, (char *)m_body_begin, m_body.length);
-  m_defstr.length= lex->ptr - lex->buf;
-  m_defstr.length-= n;
+  m_defstr.length= endp - lex->buf;
   m_defstr.str= strmake_root(root, (char *)lex->buf, m_defstr.length);
   DBUG_VOID_RETURN;
 }
Thread
bk commit into 5.0 tree (pem:1.1962) BUG#14723pem15 Nov