List:Internals« Previous MessageNext Message »
From:konstantin Date:July 14 2005 1:27pm
Subject:bk commit into 5.0 tree (konstantin:1.1927)
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.1927 05/07/14 15:27:24 konstantin@stripped +5 -0
  Implement MarkM optimization request to avoid redundnat packet exchange
  in cursors.

  tests/mysql_client_test.c
    1.135 05/07/14 15:27:15 konstantin@stripped +1 -22
    - remove a test for dropped functionality

  sql/sql_select.h
    1.92 05/07/14 15:27:15 konstantin@stripped +1 -1
    - add an empty Cursor destructor

  sql/sql_select.cc
    1.332 05/07/14 15:27:14 konstantin@stripped +0 -6
    Remove a destructor: cursor destruction can not be done by simply
    calling a destructor, because of cross-references between cursor
    and statement memory. 

  sql/sql_prepare.cc
    1.136 05/07/14 15:27:14 konstantin@stripped +30 -13
    - implement Prepared_statement::close_cursor,
    - implicitly close an open cursor in mysql_stmt_execute instead of 
      issuing an error (to reduce the need to explicitly close cursors
      and save network bandwidth).
    - cleanup

  libmysql/libmysql.c
    1.223 05/07/14 15:27:14 konstantin@stripped +2 -3
    - reset_stmt_handle(): don't reset the server side just because we have 
      an open cursor: the server will close the cursor automatically if 
      needed

# 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:	/media/sda1/mysql/mysql-5.0-10760-new

--- 1.222/libmysql/libmysql.c	2005-07-12 12:58:14 +04:00
+++ 1.223/libmysql/libmysql.c	2005-07-14 15:27:14 +04:00
@@ -4907,13 +4907,12 @@
   {
     MYSQL *mysql= stmt->mysql;
     MYSQL_DATA *result= &stmt->result;
-    my_bool has_cursor= stmt->read_row_func == stmt_read_row_from_cursor;
 
     /*
       Reset stored result set if so was requested or it's a part
       of cursor fetch.
     */
-    if (result->data && (has_cursor || (flags & RESET_STORE_RESULT)))
+    if (result->data && (flags & RESET_STORE_RESULT))
     {
       /* Result buffered */
       free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
@@ -4944,7 +4943,7 @@
           mysql->status= MYSQL_STATUS_READY;
         }
       }
-      if (has_cursor || (flags & RESET_SERVER_SIDE))
+      if (flags & RESET_SERVER_SIDE)
       {
         /*
           Reset the server side statement and close the server side

--- 1.331/sql/sql_select.cc	2005-07-04 04:44:31 +04:00
+++ 1.332/sql/sql_select.cc	2005-07-14 15:27:14 +04:00
@@ -1915,12 +1915,6 @@
 }
 
 
-Cursor::~Cursor()
-{
-  if (is_open())
-    close(FALSE);
-}
-
 /*********************************************************************/
 
 /*

--- 1.91/sql/sql_select.h	2005-07-01 15:45:09 +04:00
+++ 1.92/sql/sql_select.h	2005-07-14 15:27:15 +04:00
@@ -408,7 +408,7 @@
 
   void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; }
   Cursor(THD *thd);
-  ~Cursor();
+  ~Cursor() {}
 };
 
 

--- 1.135/sql/sql_prepare.cc	2005-07-13 18:05:50 +04:00
+++ 1.136/sql/sql_prepare.cc	2005-07-14 15:27:14 +04:00
@@ -106,6 +106,7 @@
   virtual ~Prepared_statement();
   void setup_set_params();
   virtual Query_arena::Type type() const;
+  virtual void close_cursor();
 };
 
 static void execute_stmt(THD *thd, Prepared_statement *stmt,
@@ -1986,10 +1987,7 @@
 
   cursor= stmt->cursor;
   if (cursor && cursor->is_open())
-  {
-    my_error(ER_EXEC_STMT_WITH_OPEN_CURSOR, MYF(0));
-    DBUG_VOID_RETURN;
-  }
+    stmt->close_cursor();
 
   DBUG_ASSERT(thd->free_list == NULL);
   mysql_reset_thd_for_next_command(thd);
@@ -2284,6 +2282,7 @@
   if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset")))
     DBUG_VOID_RETURN;
 
+  stmt->close_cursor();                    /* will reset statement params */
   cursor= stmt->cursor;
   if (cursor && cursor->is_open())
   {
@@ -2295,12 +2294,6 @@
 
   stmt->state= Query_arena::PREPARED;
 
-  /*
-    Clear parameters from data which could be set by
-    mysql_stmt_send_long_data() call.
-  */
-  reset_stmt_params(stmt);
-
   mysql_reset_thd_for_next_command(thd);
   send_ok(thd);
 
@@ -2448,10 +2441,17 @@
 Prepared_statement::~Prepared_statement()
 {
   if (cursor)
+  {
+    if (cursor->is_open())
+    {
+      cursor->close(FALSE);
+      free_items();
+      free_root(cursor->mem_root, MYF(0));
+    }
     cursor->Cursor::~Cursor();
-  free_items();
-  if (cursor)
-    free_root(cursor->mem_root, MYF(0));
+  }
+  else
+    free_items();
   delete lex->result;
 }
 
@@ -2459,4 +2459,21 @@
 Query_arena::Type Prepared_statement::type() const
 {
   return PREPARED_STATEMENT;
+}
+
+
+void Prepared_statement::close_cursor()
+{
+  if (cursor && cursor->is_open())
+  {
+    thd->change_list= cursor->change_list;
+    cursor->close(FALSE);
+    cleanup_stmt_and_thd_after_use(this, thd);
+    free_root(cursor->mem_root, MYF(0));
+  }
+  /*
+    Clear parameters from data which could be set by
+    mysql_stmt_send_long_data() call.
+  */
+  reset_stmt_params(this);
 }

--- 1.134/tests/mysql_client_test.c	2005-07-14 01:19:42 +04:00
+++ 1.135/tests/mysql_client_test.c	2005-07-14 15:27:15 +04:00
@@ -13050,27 +13050,6 @@
     check_execute(stmt, rc);
     if (!opt_silent && i == 0)
       printf("Fetched row: %s\n", a);
-    /*
-      Although protocol-wise an attempt to execute a statement which
-      already has an open cursor associated with it will yield an error,
-      the client library behavior tested here is consistent with
-      the non-cursor execution scenario: mysql_stmt_execute will
-      silently close the cursor if necessary.
-    */
-    {
-      char buff[9];
-      /* Fill in the execute packet */
-      int4store(buff, stmt->stmt_id);
-      buff[4]= 0;                               /* Flag */
-      int4store(buff+5, 1);                     /* Reserved for array bind */
-      rc= ((*mysql->methods->advanced_command)(mysql, COM_STMT_EXECUTE, buff,
-                                               sizeof(buff), 0,0,1) ||
-           (*mysql->methods->read_query_result)(mysql));
-      DIE_UNLESS(rc);
-      if (!opt_silent && i == 0)
-        printf("Got error (as expected): %s\n", mysql_error(mysql));
-    }
-
     rc= mysql_stmt_execute(stmt);
     check_execute(stmt, rc);
 
@@ -13429,7 +13408,7 @@
   bind[1].length= &a_len;
   rc= mysql_stmt_bind_param(stmt, bind);
   check_execute(stmt, rc);
-  for (i= 0; i < 34; i++)
+  for (i= 0; i < 42; i++)
   {
     id_val= (i+1)*10;
     sprintf(a, "a%d", i);
Thread
bk commit into 5.0 tree (konstantin:1.1927)konstantin14 Jul