List:Internals« Previous MessageNext Message »
From:pem Date:September 13 2005 4:05pm
Subject:bk commit into 5.0 tree (pem:1.1948) BUG#7049
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.1948 05/09/13 15:32:42 pem@stripped +4 -0
  Fixed BUG#12379: PROCEDURE with HANDLER calling FUNCTION with error
                   get strange result
    according to Monty's suggestions, fixing the SELECT behaviour on errors
    with SP handlers. Note that some warnings from SELECT still shows up when
    the handler has caught - this is an effect of another known bug (BUG#7049).

  sql/sql_class.h
    1.264 05/09/13 15:32:35 pem@stripped +3 -1
    Abort selects on errors more graceful with SP handlers.

  sql/sql_class.cc
    1.210 05/09/13 15:32:34 pem@stripped +27 -1
    Abort selects on errors more graceful with SP handlers.

  mysql-test/t/sp.test
    1.147 05/09/13 15:32:34 pem@stripped +55 -0
    New test cases for BUG#12379.

  mysql-test/r/sp.result
    1.152 05/09/13 15:32:34 pem@stripped +59 -0
    New test cases for BUG#12379.

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

--- 1.209/sql/sql_class.cc	2005-09-09 09:44:07 +02:00
+++ 1.210/sql/sql_class.cc	2005-09-13 15:32:34 +02:00
@@ -865,9 +865,34 @@
 
 bool select_send::send_fields(List<Item> &list, uint flags)
 {
-  return thd->protocol->send_fields(&list, flags);
+  bool res;
+  if (!(res= thd->protocol->send_fields(&list, flags)))
+    status= 1;
+  return res;
 }
 
+void select_send::abort()
+{
+  DBUG_ENTER("select_send::abort");
+  if (status && thd->spcont &&
+      thd->spcont->find_handler(thd->net.last_errno,
+                                MYSQL_ERROR::WARN_LEVEL_ERROR))
+  {
+    /*
+      Executing stored procedure without a handler.
+      Here we should actually send an error to the client,
+      but as an error will break a multiple result set, the only thing we
+      can do for now is to nicely end the current data set and remembering
+      the error so that the calling routine will abort
+    */
+    thd->net.report_error= 0;
+    send_eof();
+    thd->net.report_error= 1; // Abort SP
+  }
+  DBUG_VOID_RETURN;
+}
+
+
 /* Send data to client. Returns 0 if ok */
 
 bool select_send::send_data(List<Item> &items)
@@ -930,6 +955,7 @@
   if (!thd->net.report_error)
   {
     ::send_eof(thd);
+    status= 0;
     return 0;
   }
   else

--- 1.263/sql/sql_class.h	2005-09-07 17:39:41 +02:00
+++ 1.264/sql/sql_class.h	2005-09-13 15:32:35 +02:00
@@ -1658,12 +1658,14 @@
 
 
 class select_send :public select_result {
+  int status;
 public:
-  select_send() {}
+  select_send() :status(0) {}
   bool send_fields(List<Item> &list, uint flags);
   bool send_data(List<Item> &items);
   bool send_eof();
   bool simple_select() { return 1; }
+  void abort();
 };
 
 

--- 1.151/mysql-test/r/sp.result	2005-09-13 12:50:11 +02:00
+++ 1.152/mysql-test/r/sp.result	2005-09-13 15:32:34 +02:00
@@ -3264,4 +3264,63 @@
 NULL
 drop procedure bug131333|
 drop function bug131333|
+drop function if exists bug12379|
+drop procedure if exists bug12379_1|
+drop procedure if exists bug12379_2|
+drop procedure if exists bug12379_3|
+drop table if exists t3|
+create table t3 (c1 char(1) primary key not null)|
+create function bug12379()
+returns integer
+begin
+insert into t3 values('X');
+insert into t3 values('X');
+return 0;
+end|
+create procedure bug12379_1()
+begin
+declare exit handler for sqlexception select 42;
+select bug12379();
+END|
+create procedure bug12379_2()
+begin
+declare exit handler for sqlexception begin end;
+select bug12379();
+end|
+create procedure bug12379_3()
+begin
+select bug12379();
+end|
+select bug12379()|
+ERROR 23000: Duplicate entry 'X' for key 1
+select 1|
+1
+1
+call bug12379_1()|
+bug12379()
+42
+42
+Warnings:
+Error	1062	Duplicate entry 'X' for key 1
+Warning	1417	A routine failed and has neither NO SQL nor READS SQL DATA in its
declaration and binary logging is enabled; if non-transactional tables were updated, the
binary log will miss their changes
+select 2|
+2
+2
+call bug12379_2()|
+bug12379()
+Warnings:
+Error	1062	Duplicate entry 'X' for key 1
+Warning	1417	A routine failed and has neither NO SQL nor READS SQL DATA in its
declaration and binary logging is enabled; if non-transactional tables were updated, the
binary log will miss their changes
+select 3|
+3
+3
+call bug12379_3()|
+ERROR 23000: Duplicate entry 'X' for key 1
+select 4|
+4
+4
+drop function bug12379|
+drop procedure bug12379_1|
+drop procedure bug12379_2|
+drop procedure bug12379_3|
 drop table t1,t2;

--- 1.146/mysql-test/t/sp.test	2005-09-13 12:50:11 +02:00
+++ 1.147/mysql-test/t/sp.test	2005-09-13 15:32:34 +02:00
@@ -4109,6 +4109,61 @@
 
 
 #
+# BUG#12379: PROCEDURE with HANDLER calling FUNCTION with error get
+#            strange result
+#
+--disable_warnings
+drop function if exists bug12379|
+drop procedure if exists bug12379_1|
+drop procedure if exists bug12379_2|
+drop procedure if exists bug12379_3|
+drop table if exists t3|
+--enable_warnings
+
+create table t3 (c1 char(1) primary key not null)|
+
+create function bug12379()
+  returns integer
+begin
+   insert into t3 values('X');
+   insert into t3 values('X');
+   return 0;
+end|
+
+create procedure bug12379_1()
+begin
+   declare exit handler for sqlexception select 42;
+
+   select bug12379();
+END|
+create procedure bug12379_2()
+begin
+   declare exit handler for sqlexception begin end;
+
+   select bug12379();
+end|
+create procedure bug12379_3()
+begin
+   select bug12379();
+end|
+
+--error 1062
+select bug12379()|
+select 1|
+call bug12379_1()|
+select 2|
+call bug12379_2()|
+select 3|
+--error 1062
+call bug12379_3()|
+select 4|
+
+drop function bug12379|
+drop procedure bug12379_1|
+drop procedure bug12379_2|
+drop procedure bug12379_3|
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings
Thread
bk commit into 5.0 tree (pem:1.1948) BUG#7049pem13 Sep