List:Internals« Previous MessageNext Message »
From:monty Date:July 29 2005 2:06am
Subject:bk commit into 5.0 tree (monty:1.1916)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of monty. When monty 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.1916 05/07/29 05:06:35 monty@stripped +3 -0
  Ensure we free all items for prepared statements
  Before the fix in ~Prepared_statments we got a memory leak when executing mysql_client_test.test
  Note that test 'variables.test' fails.
  This will be fixed when Jimw pushes the fix for Bug 10351

  sql/sql_prepare.cc
    1.143 05/07/29 05:06:31 monty@stripped +20 -4
    More debugging information
    Ensure we free all items for prepared statements
    Before the fix in ~Prepared_statments we got a memory leak when executing mysql_client_test.test

  sql/item.cc
    1.160 05/07/29 05:06:31 monty@stripped +2 -0
    More debugging information

  mysys/default.c
    1.77 05/07/29 05:06:31 monty@stripped +1 -1
    Fixed typo

# 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:	monty
# Host:	narttu.mysql.com
# Root:	/home/my/mysql-5.0

--- 1.76/mysys/default.c	2005-07-28 16:08:52 +03:00
+++ 1.77/mysys/default.c	2005-07-29 05:06:31 +03:00
@@ -1023,7 +1023,7 @@
           }
           else
           {
-            /' No parent directory (strange). Use current dir + '\' '*/
+            /* No parent directory (strange). Use current dir + '\' */
             last[1]= 0;
           }
           break;

--- 1.159/sql/item.cc	2005-07-26 12:51:32 +03:00
+++ 1.160/sql/item.cc	2005-07-29 05:06:31 +03:00
@@ -2188,6 +2188,7 @@
 
 void Item_param::reset()
 {
+  DBUG_ENTER("Item_param::reset");
   /* Shrink string buffer if it's bigger than max possible CHAR column */
   if (str_value.alloced_length() > MAX_CHAR_WIDTH)
     str_value.free();
@@ -2212,6 +2213,7 @@
     DBUG_ASSERTS(state != NO_VALUE) in all Item_param::get_*
     methods).
   */
+  DBUG_VOID_RETURN;
 }
 
 

--- 1.142/sql/sql_prepare.cc	2005-07-20 02:33:19 +03:00
+++ 1.143/sql/sql_prepare.cc	2005-07-29 05:06:31 +03:00
@@ -1682,10 +1682,12 @@
 
 static void cleanup_stmt_and_thd_after_use(Statement *stmt, THD *thd)
 {
+  DBUG_ENTER("cleanup_stmt_and_thd_after_use");
   stmt->lex->unit.cleanup();
   cleanup_items(stmt->free_list);
   thd->rollback_item_tree_changes();
   thd->cleanup_after_query();
+  DBUG_VOID_RETURN;
 }
 
 /*
@@ -1982,7 +1984,8 @@
   if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
     DBUG_VOID_RETURN;
 
-  DBUG_PRINT("exec_query:", ("%s", stmt->query));
+  DBUG_PRINT("exec_query", ("%s", stmt->query));
+  DBUG_PRINT("info",("stmt: %p", stmt));
 
   /* Check if we got an error when sending long data */
   if (stmt->state == Query_arena::ERROR)
@@ -2125,6 +2128,8 @@
     DBUG_VOID_RETURN;
   }
 
+  DBUG_PRINT("info",("stmt: %p", stmt));
+
   /* Must go before setting variables, as it clears thd->user_var_events */
   mysql_reset_thd_for_next_command(thd);
   thd->set_n_backup_statement(stmt, &stmt_backup);
@@ -2445,19 +2450,26 @@
 
 Prepared_statement::~Prepared_statement()
 {
+  DBUG_ENTER("Prepared_statement::~Prepared_statement");
+  DBUG_PRINT("enter",("stmt: %p  cursor: %p", this, cursor));
   if (cursor)
   {
     if (cursor->is_open())
     {
       cursor->close(FALSE);
-      free_items();
+      cleanup_items(free_list);
+      thd->rollback_item_tree_changes();
       free_root(cursor->mem_root, MYF(0));
     }
     cursor->Cursor::~Cursor();
   }
-  else
-    free_items();
+  /*
+    We have to call free on the items even if cleanup is called as some items,
+    like Item_param, don't free everything until free_items()
+  */
+  free_items();
   delete lex->result;
+  DBUG_VOID_RETURN;
 }
 
 
@@ -2469,6 +2481,9 @@
 
 void Prepared_statement::close_cursor()
 {
+  DBUG_ENTER("Prepared_statement::close_cursor");
+  DBUG_PRINT("enter",("stmt: %p", this));
+
   if (cursor && cursor->is_open())
   {
     thd->change_list= cursor->change_list;
@@ -2483,4 +2498,5 @@
     mysql_stmt_send_long_data() call.
   */
   reset_stmt_params(this);
+  DBUG_VOID_RETURN;
 }
Thread
bk commit into 5.0 tree (monty:1.1916)monty29 Jul