List:Internals« Previous MessageNext Message »
From:Sergey Petrunia Date:July 5 2005 1:00am
Subject:bk commit into 5.0 tree (sergefp:1.1877) BUG#9814
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of psergey. When psergey 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.1877 05/07/04 23:00:23 sergefp@stripped +3 -0
  Fix for BUG#9814: Clear thd->net.no_send_error before each SP instruction 
  execution. Failure to do so caused the erroneous statements to send nothing
  and hang the client.

  sql/sp_head.cc
    1.155 05/07/04 23:00:20 sergefp@stripped +6 -0
    Fix for BUG#9814: Clear thd->net.no_send_error before each SP instruction 
    execution. Failure to do so caused the erroneous statements to send nothing
    and hang the client.

  mysql-test/t/sp-error.test
    1.75 05/07/04 23:00:20 sergefp@stripped +38 -0
    Testcase for BUG#09814.

  mysql-test/r/sp-error.result
    1.73 05/07/04 23:00:20 sergefp@stripped +30 -0
    Testcase for BUG#9814. Note that the result demonstrates that currently
    mysql-test-run ignores errors in multi-statement if they arrive after first 
    resultset has been received.    

# 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:	sergefp
# Host:	newbox.mylan
# Root:	/home/psergey/mysql-5.0-jul4

--- 1.72/mysql-test/r/sp-error.result	2005-07-01 12:51:49 +00:00
+++ 1.73/mysql-test/r/sp-error.result	2005-07-04 23:00:20 +00:00
@@ -1,3 +1,4 @@
+drop table if exists t1, t2;
 delete from mysql.proc;
 create procedure syntaxerror(t int)|
 ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '' at line 1
@@ -635,3 +636,32 @@
 create function f() returns int begin execute stmt;
 ERROR 0A000: EXECUTE is not allowed in stored procedures
 deallocate prepare stmt;
+create table t1(f1 int);
+create table t2(f1 int);
+CREATE PROCEDURE SP001()
+P1: BEGIN
+DECLARE ENDTABLE INT DEFAULT 0;
+DECLARE TEMP_NUM INT;
+DECLARE TEMP_SUM INT;
+DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
+DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
+DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
+SET ENDTABLE=0;
+SET TEMP_SUM=0;
+SET TEMP_NUM=0;
+OPEN C1;
+FETCH C1 INTO TEMP_NUM;
+WHILE ENDTABLE = 0 DO
+SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
+FETCH C1 INTO TEMP_NUM;
+END WHILE;
+SELECT TEMP_SUM;
+CLOSE C1;
+CLOSE C1;
+SELECT 'end of proc';
+END P1|
+call SP001();
+TEMP_SUM
+0
+drop procedure SP001;
+drop table t1, t2;

--- 1.74/mysql-test/t/sp-error.test	2005-07-01 12:51:49 +00:00
+++ 1.75/mysql-test/t/sp-error.test	2005-07-04 23:00:20 +00:00
@@ -2,6 +2,10 @@
 # Stored PROCEDURE error tests
 #
 
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
 # Make sure we don't have any procedures left.
 delete from mysql.proc;
 
@@ -933,3 +937,37 @@
 create function f() returns int begin execute stmt;
 deallocate prepare stmt;
 
+# BUG#9814: Closing a cursor that is not open 
+create table t1(f1 int);
+create table t2(f1 int);
+ 
+delimiter |;
+CREATE PROCEDURE SP001()
+P1: BEGIN
+  DECLARE ENDTABLE INT DEFAULT 0;
+  DECLARE TEMP_NUM INT;
+  DECLARE TEMP_SUM INT;
+  DECLARE C1 CURSOR FOR SELECT F1 FROM t1;
+  DECLARE C2 CURSOR FOR SELECT F1 FROM t2;
+  DECLARE CONTINUE HANDLER FOR NOT FOUND SET ENDTABLE = 1;
+
+  SET ENDTABLE=0;
+  SET TEMP_SUM=0;
+  SET TEMP_NUM=0;
+  
+  OPEN C1;
+
+  FETCH C1 INTO TEMP_NUM;
+  WHILE ENDTABLE = 0 DO
+          SET TEMP_SUM=TEMP_NUM+TEMP_SUM;
+          FETCH C1 INTO TEMP_NUM;
+  END WHILE;
+  SELECT TEMP_SUM;
+  CLOSE C1;
+  CLOSE C1;
+  SELECT 'end of proc';
+END P1|
+delimiter ;|
+call SP001();
+drop procedure SP001;
+drop table t1, t2;

--- 1.154/sql/sp_head.cc	2005-07-01 04:05:35 +00:00
+++ 1.155/sql/sp_head.cc	2005-07-04 23:00:20 +00:00
@@ -642,6 +642,12 @@
       items made during other permanent subquery transformations).
     */
     thd->current_arena= i;
+    /*
+      no_send_error may have been set by the previous SP instruction when it
+      sent eof. Allow the current SP instruction to produce an error.
+      (multi-statement execution code clears no_send_error, too)
+    */
+    thd->net.no_send_error= 0;
     ret= i->execute(thd, &ip);
     if (i->free_list)
       cleanup_items(i->free_list);
Thread
bk commit into 5.0 tree (sergefp:1.1877) BUG#9814Sergey Petrunia4 Jul