MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:konstantin Date:August 18 2005 10:09pm
Subject:bk commit into 5.0 tree (konstantin:1.1989) BUG#12168
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja 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.1989 05/08/19 02:09:50 konstantin@stripped +3 -0
  A fix and a test case for Bug#12168 " 'DECLARE CONTINUE HANDLER FOR NOT
   FOUND ...' in conditional handled incorrectly".

  sql/sp_head.h
    1.65 05/08/19 02:09:45 konstantin@stripped +6 -0
    Implement sp_instr_hpush_jump::opt_move: whenever we remove
    an instruction during optimization, we need to adjust instruction pointer
    values stored in all instructions. In addition to that,
    sp_instr_hpush_jump, which coresponds to DECLARE CONTINUE HANDLER, 
    needs m_handler pointer to be fixed. m_handler points to the 
    instruction with the continue handler, and without the patch the wrong
    value of m_handler was pointing at FETCH, resulting in an error
    message and abnormal SP termination.
    An alternative way to fix the problem would be to remove m_handler
    and always use m_ip+1 instead.
    value, which was pointing at FETCH instruction, which resulted
    in FETCH being called as a handler for end-of-data in the very same FETCH.

  mysql-test/t/sp.test
    1.139 05/08/19 02:09:45 konstantin@stripped +66 -0
    A test case for Bug#12168 "'DECLARE CONTINUE HANDLER FOR NOT 
    FOUND ...' in conditional handled incorrectly"

  mysql-test/r/sp.result
    1.144 05/08/19 02:09:45 konstantin@stripped +67 -0
    Test results fixed (Bug#12168)

# 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:	konstantin
# Host:	dragonfly.local
# Root:	/opt/local/work/mysql-5.0-12168

--- 1.143/mysql-test/r/sp.result	2005-08-18 13:23:47 +04:00
+++ 1.144/mysql-test/r/sp.result	2005-08-19 02:09:45 +04:00
@@ -3100,4 +3100,71 @@
 call p_bug11247(10)|
 drop function f_bug11247|
 drop procedure p_bug11247|
+drop procedure if exists bug12168|
+drop table if exists t1, t2;
+--enable_warnings|
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4);
+create table t2 (a int);
+create procedure bug12168(arg1 char(1))
+begin
+declare b, c integer;
+if arg1 = 'a' then
+begin
+declare c1 cursor for select a from t1 where a % 2;
+declare continue handler for not found set b = 1;
+set b = 0;
+open c1;
+c1_repeat: repeat
+fetch c1 into c;
+if (b = 1) then
+leave c1_repeat;
+end if;
+insert into t2 values (c);
+until b = 1
+end repeat;
+end;
+end if;
+if arg1 = 'b' then
+begin
+declare c2 cursor for select a from t1 where not a % 2;
+declare continue handler for not found set b = 1;
+set b = 0;
+open c2;
+c2_repeat: repeat
+fetch c2 into c;
+if (b = 1) then
+leave c2_repeat;
+end if;
+insert into t2 values (c);
+until b = 1
+end repeat;
+end;
+end if;
+end|
+call bug12168('a')|
+select * from t2|
+a
+1
+3
+truncate t2;
+call bug12168('b')|
+select * from t2|
+a
+2
+4
+truncate t2;
+call bug12168('a')|
+select * from t2|
+a
+1
+3
+truncate t2;
+call bug12168('b')|
+select * from t2|
+a
+2
+4
+truncate t2;
+drop procedure if exists bug12168|
 drop table t1,t2;

--- 1.138/mysql-test/t/sp.test	2005-08-18 13:23:47 +04:00
+++ 1.139/mysql-test/t/sp.test	2005-08-19 02:09:45 +04:00
@@ -3928,6 +3928,72 @@
 call p_bug11247(10)|
 drop function f_bug11247|
 drop procedure p_bug11247|
+#
+# BUG#12168: "'DECLARE CONTINUE HANDLER FOR NOT FOUND ...' in conditional
+# handled incorrectly"
+#
+--disable_warnings
+drop procedure if exists bug12168|
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4);
+
+create table t2 (a int);
+
+create procedure bug12168(arg1 char(1))
+begin
+  declare b, c integer;
+  if arg1 = 'a' then
+    begin
+      declare c1 cursor for select a from t1 where a % 2;
+      declare continue handler for not found set b = 1;
+      set b = 0;
+      open c1;
+      c1_repeat: repeat
+        fetch c1 into c;
+        if (b = 1) then
+          leave c1_repeat;
+        end if;
+
+        insert into t2 values (c);
+        until b = 1
+      end repeat;
+    end;
+  end if;
+  if arg1 = 'b' then
+    begin
+      declare c2 cursor for select a from t1 where not a % 2;
+      declare continue handler for not found set b = 1;
+      set b = 0;
+      open c2;
+      c2_repeat: repeat
+        fetch c2 into c;
+        if (b = 1) then
+          leave c2_repeat;
+        end if;
+
+        insert into t2 values (c);
+        until b = 1
+      end repeat;
+    end;
+  end if;
+end|
+
+call bug12168('a')|
+select * from t2|
+truncate t2;
+call bug12168('b')|
+select * from t2|
+truncate t2;
+call bug12168('a')|
+select * from t2|
+truncate t2;
+call bug12168('b')|
+select * from t2|
+truncate t2;
+drop procedure if exists bug12168|
 
 #
 # BUG#NNNN: New bug synopsis

--- 1.64/sql/sp_head.h	2005-08-03 07:44:29 +04:00
+++ 1.65/sql/sp_head.h	2005-08-19 02:09:45 +04:00
@@ -727,6 +727,12 @@
 
   virtual void print(String *str);
 
+  virtual void opt_move(uint dst, List<sp_instr> *ibp)
+  {
+    sp_instr_jump::opt_move(dst, ibp);
+    m_handler= m_ip+1;
+  }
+
   virtual uint opt_mark(sp_head *sp);
 
   virtual uint opt_shortcut_jump(sp_head *sp, sp_instr *start)
Thread
bk commit into 5.0 tree (konstantin:1.1989) BUG#12168konstantin19 Aug