List:Commits« Previous MessageNext Message »
From:konstantin Date:October 31 2007 3:33pm
Subject:bk commit into 5.1 tree (kostja:1.2605) BUG#12713
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2007-10-31 18:33:13+03:00, kostja@bodhi.(none) +3 -0
  Cleanup: rename select_send::status to select_send::is_result_set_started.
  Add select_send::cleanup.
  Fix a compilation warning.
  Issues spotted while working on the fix for Bug#12713.

  sql-common/client.c@stripped, 2007-10-31 18:33:06+03:00, kostja@bodhi.(none) +0 -1
    Fix a warning.

  sql/sql_class.cc@stripped, 2007-10-31 18:33:06+03:00, kostja@bodhi.(none) +22 -8
    Give a variable a more specific name. Rewrite an incorrect comment.
    Add a cleanup for select_send. The only case now this cleanup can be
    necessary is when we have a prepared statement inside a stored procedure, 
    and a continue handler. At first execution, the statement is killed
    after having executed select_send::send_fields. At the second execution
    it is killed after having executed select_send::send_fields.

  sql/sql_class.h@stripped, 2007-10-31 18:33:06+03:00, kostja@bodhi.(none) +8 -2
    Rename a member. Add comments.

diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc	2007-10-30 22:35:11 +03:00
+++ b/sql/sql_class.cc	2007-10-31 18:33:06 +03:00
@@ -1305,23 +1305,26 @@ bool select_send::send_fields(List<Item>
 {
   bool res;
   if (!(res= thd->protocol->send_fields(&list, flags)))
-    status= 1;
+    is_result_set_started= 1;
   return res;
 }
 
 void select_send::abort()
 {
   DBUG_ENTER("select_send::abort");
-  if (status && thd->spcont &&
+  if (is_result_set_started && thd->spcont &&
       thd->spcont->find_handler(thd, 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
+      We're executing a stored procedure, have an open result
+      set, an SQL exception conditiona and a handler for it.
+      In this situation we must abort the current statement,
+      silence the error and start executing the continue/exit
+      handler.
+      Before aborting the statement, let's end the open result set, as
+      otherwise the client will hang due to the violation of the
+      client/server protocol.
     */
     thd->net.report_error= 0;
     send_eof();
@@ -1331,6 +1334,17 @@ void select_send::abort()
 }
 
 
+/** 
+  Cleanup an instance of this class for re-use
+  at next execution of a prepared statement/
+  stored procedure statement.
+*/
+
+void select_send::cleanup()
+{
+  is_result_set_started= FALSE;
+}
+
 /* Send data to client. Returns 0 if ok */
 
 bool select_send::send_data(List<Item> &items)
@@ -1392,7 +1406,7 @@ bool select_send::send_eof()
   if (! thd->is_error())
   {
     ::send_eof(thd);
-    status= 0;
+    is_result_set_started= 0;
     return 0;
   }
   else
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h	2007-10-30 22:35:11 +03:00
+++ b/sql/sql_class.h	2007-10-31 18:33:06 +03:00
@@ -2051,14 +2051,20 @@ public:
 
 
 class select_send :public select_result {
-  int status;
+  /**
+    True if we have sent result set metadata to the client.
+    In this case the client always expects us to end the result
+    set with an eof or error packet
+  */
+  bool is_result_set_started;
 public:
-  select_send() :status(0) {}
+  select_send() :is_result_set_started(FALSE) {}
   bool send_fields(List<Item> &list, uint flags);
   bool send_data(List<Item> &items);
   bool send_eof();
   virtual bool check_simple_select() const { return FALSE; }
   void abort();
+  virtual void cleanup();
 };
 
 
diff -Nrup a/sql-common/client.c b/sql-common/client.c
--- a/sql-common/client.c	2007-10-31 17:16:51 +03:00
+++ b/sql-common/client.c	2007-10-31 18:33:06 +03:00
@@ -1714,7 +1714,6 @@ static MYSQL_METHODS client_methods=
 C_MODE_START
 int mysql_init_character_set(MYSQL *mysql)
 {
-  NET		*net= &mysql->net;
   const char *default_collation_name;
   
   /* Set character set */
Thread
bk commit into 5.1 tree (kostja:1.2605) BUG#12713konstantin31 Oct