List:Internals« Previous MessageNext Message »
From:pem Date:November 8 2005 2:50pm
Subject:bk commit into 5.0 tree (pem:1.1973) BUG#14643
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.1973 05/11/08 14:47:33 pem@stripped +3 -0
  Fixed BUG#14643: Stored Procedure: Continuing after failed var.
                   initialization crashes server.
    Make sure variables are initialized to something (like null) when
    the default initialization fails and a continue handler is in effect.

  sql/sp_head.cc
    1.194 05/11/08 14:47:25 pem@stripped +20 -0
    Make sure variables are initialized to something (like null) when
    the default initialization fails and a continue handler is in effect.
    If this also fails (out of memory), we have to abort without letting
    the handler catch.

  mysql-test/t/sp.test
    1.163 05/11/08 14:47:25 pem@stripped +44 -0
    New test case for BUG#14643.

  mysql-test/r/sp.result
    1.170 05/11/08 14:47:25 pem@stripped +36 -0
    New test case for BUG#14643.

# 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/bug14643/mysql-5.0

--- 1.169/mysql-test/r/sp.result	2005-11-03 12:20:07 +01:00
+++ 1.170/mysql-test/r/sp.result	2005-11-08 14:47:25 +01:00
@@ -3617,4 +3617,40 @@
 drop table t3, t4|
 drop procedure bug14210|
 set @@session.max_heap_table_size=default|
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+create procedure bug14643_1()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+begin
+declare v int default x;
+if v = 1 then
+select 1;
+else
+select 2;
+end if;
+end;
+end|
+create procedure bug14643_2()
+begin
+declare continue handler for sqlexception select 'boo' as 'Handler';
+case x
+when 1 then
+select 1;
+else
+select 2;
+end case;
+end|
+call bug14643_1()|
+Handler
+boo
+2
+2
+call bug14643_2()|
+Handler
+boo
+2
+2
+drop procedure bug14643_1|
+drop procedure bug14643_2|
 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-08 14:47:25 +01:00
@@ -4541,6 +4541,50 @@
 drop procedure bug14210|
 set @@session.max_heap_table_size=default|
 
+
+#
+# BUG#14643: Stored Procedure: Continuing after failed var. initialization
+#            crashes server.
+#
+--disable_warnings
+drop procedure if exists bug14643_1|
+drop procedure if exists bug14643_2|
+--enable_warnings
+
+create procedure bug14643_1()
+begin
+  declare continue handler for sqlexception select 'boo' as 'Handler';
+
+  begin
+    declare v int default x;
+
+    if v = 1 then
+      select 1;
+    else
+      select 2;
+    end if;
+  end;
+end|
+
+create procedure bug14643_2()
+begin
+  declare continue handler for sqlexception select 'boo' as 'Handler';
+
+  case x
+  when 1 then
+    select 1;
+  else
+    select 2;
+  end case;
+end|
+
+call bug14643_1()|
+call bug14643_2()|
+
+drop procedure bug14643_1|
+drop procedure bug14643_2|
+
+
 #
 # 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-08 14:47:25 +01:00
@@ -2031,6 +2031,26 @@
 {
   int res= thd->spcont->set_item_eval(thd, m_offset, &m_value, m_type);
 
+  if (res < 0 &&
+      thd->spcont->get_item(m_offset) == NULL &&
+      thd->spcont->found_handler_here())
+  {
+    /*
+      Failed to evaluate the value, the variable is still not initialized,
+      and a handler has been found. Set to null so we can continue.
+    */
+    Item *it= new Item_null();
+
+    if (!it || thd->spcont->set_item_eval(thd, m_offset, &it, m_type) < 0)
+    {                           /* If this also failed, we have to abort */
+      sp_rcontext *spcont= thd->spcont;
+
+      thd->spcont= 0;           /* Avoid handlers */
+      my_error(ER_OUT_OF_RESOURCES, MYF(0));
+      spcont->clear_handler();
+      thd->spcont= spcont;
+    }
+  }
   *nextp = m_ip+1;
   return res;
 }
Thread
bk commit into 5.0 tree (pem:1.1973) BUG#14643pem8 Nov