MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:cbell Date:July 2 2007 5:27pm
Subject:bk commit into 5.2 tree (cbell:1.2547)
View as plain text  
Below is the list of changes that have just been committed into a local
5.2 repository of cbell. When cbell 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-07-02 13:27:13-04:00, cbell@mysql_cab_desk. +9 -0
  WL#3570 : Default Backup
  
  This patch corrects a problem found in valgrind testing, includes
  some minor enhancements to the backup_snapshot test, and minor 
  enhancements to memory management in building the table list.

  mysql-test/r/backup_snapshot.result@stripped, 2007-07-02 13:27:07-04:00, cbell@mysql_cab_desk. +1 -1
    WL#3776 : Snapshot driver
    
    This patch removes the warning guards and the IF EXISTS since the 
    database should exist at end of the test.

  mysql-test/t/backup_snapshot.test@stripped, 2007-07-02 13:27:07-04:00, cbell@mysql_cab_desk. +1 -3
    WL#3776 : Snapshot driver
    
    This patch updates the result file for the backup_snapshot test.

  sql/backup/backup_aux.h@stripped, 2007-07-02 13:27:08-04:00, cbell@mysql_cab_desk. +19 -0
    WL#3327 : Online Backup
    
    Added a method to free a table list.

  sql/backup/be_default.cc@stripped, 2007-07-02 13:27:08-04:00, cbell@mysql_cab_desk. +17 -6
    WL#3570 : Default Driver
    
    This patch corrects a problem found in valgrind testing. The patch adds
    a call to the resest() method in the buffer_iterator class to free the
    memory allocated when writing a multiple block record during restore.

  sql/backup/be_default.h@stripped, 2007-07-02 13:27:08-04:00, cbell@mysql_cab_desk. +11 -11
    WL#3570 : Default Driver
    WL#3776 : Snapshot Driver
    
    This patch adds calls to free_table_list() so that the default and
    snapshot drivers deallocate memory allocated in build_table_list().

  sql/backup/be_snapshot.cc@stripped, 2007-07-02 13:27:09-04:00, cbell@mysql_cab_desk. +3 -13
    WL#3776 : Snapshot Driver
    
    This patch changes the constructor to use the default driver (parent)'s 
    constructor to create the table list by passing into the constructor
    the type of lock requested.

  sql/backup/be_snapshot.h@stripped, 2007-07-02 13:27:09-04:00, cbell@mysql_cab_desk. +3 -2
    WL#3776 : Snapshot Driver
    
    This patch changes the constructor to use the default driver (parent)'s 
    constructor to create the table list by passing into the constructor
    the type of lock requested.

  sql/backup/buffer_iterator.cc@stripped, 2007-07-02 13:27:10-04:00, cbell@mysql_cab_desk. +2 -0
    WL#350 : Default Driver
    
    This patch adds additional enhancements to allow calling Reset() method
    repeatedly.

  sql/backup/sql_backup.cc@stripped, 2007-07-02 13:27:10-04:00, cbell@mysql_cab_desk. +1 -1
    WL#3327 : Online Backup
    
    This patch changes the memory allocation from sql_alloc to my_malloc.
    The memory is freed in the destructors of default and snapshot drivers.

# 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:	cbell
# Host:	mysql_cab_desk.
# Root:	C:/source/c++/mysql-5.2-backup-test

--- 1.7/sql/backup/be_default.cc	2007-07-02 13:27:20 -04:00
+++ 1.8/sql/backup/be_default.cc	2007-07-02 13:27:20 -04:00
@@ -100,14 +100,15 @@
                             Backup_driver* &drv)
 {
   DBUG_ENTER("Engine::get_backup");
-  Backup *ptr= new default_backup::Backup(tables, m_thd);
+  Backup *ptr= new default_backup::Backup(tables, m_thd, TL_READ_NO_INSERT);
   if (!ptr)
     DBUG_RETURN(ERROR);
   drv= ptr;
   DBUG_RETURN(OK);
 }
 
-Backup::Backup(const Table_list &tables, THD *t_thd): Backup_driver(tables)
+Backup::Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type): 
+               Backup_driver(tables)
 {
   DBUG_PRINT("default_backup",("Creating backup driver"));
   m_thd= t_thd;         /* save current thread */
@@ -120,8 +121,15 @@
      Create a TABLE_LIST * list for iterating through the tables.
      Initialize the list for opening the tables in read mode.
   */
-  tables_in_backup= build_table_list(tables, TL_READ_NO_INSERT);
+  tables_in_backup= build_table_list(tables, lock_type);
   all_tables= tables_in_backup;
+
+  /*
+     Initialize the list for opening the tables in read mode.
+  */
+  if (all_tables)
+    for (TABLE_LIST *tbl= all_tables; tbl != NULL; tbl= tbl->next_global)
+      tbl->lock_type= lock_type;
 }
 
 /**
@@ -344,6 +352,8 @@
     size_t rec_size= 0; 
 
     rec_size= rec_buffer.get_next((byte **)&ptr, (buf.size - META_SIZE));
+    memcpy((byte *)buf.data + META_SIZE, ptr, rec_size);
+    buf.size = rec_size + META_SIZE;
     if (rec_buffer.num_windows(buf.size - META_SIZE) == 0)
     {
       *buf.data= RCD_LAST;
@@ -352,8 +362,6 @@
     }
     else
       *buf.data= RCD_DATA;
-    memcpy((byte *)buf.data + META_SIZE, ptr, rec_size);
-    buf.size = rec_size + META_SIZE;
     break;
   }
 
@@ -730,6 +738,7 @@
         rec_buffer.put_next((byte *)buf.data + META_SIZE, size);
         ptr= (byte *)rec_buffer.get_base_ptr();
         memcpy(cur_table->record[0], ptr, cur_table->s->reclength);
+        rec_buffer.reset();
         mode= CHECK_BLOBS;
       }
       default:
@@ -821,7 +830,8 @@
     case BLOB_FIRST:
     {
       max_blob_size= uint4korr(buf.data + META_SIZE);
-      blob_buffer.initialize(max_blob_size);
+      blob_ptrs[blob_ptr_index]= (byte *)my_malloc(max_blob_size, MYF(MY_WME));
+      blob_buffer.initialize(blob_ptrs[blob_ptr_index], max_blob_size);
       size= buf.size - META_SIZE - 4;
       blob_buffer.put_next((byte *)buf.data + META_SIZE + 4, size);
       mode= WRITE_BLOB;
@@ -847,6 +857,7 @@
       ptr= (byte *)blob_buffer.get_base_ptr();
       ((Field_blob*) cur_table->field[*cur_blob])->set_ptr(max_blob_size, 
         (uchar *)ptr);
+      blob_ptr_index++;
       mode= CHECK_BLOBS;
       DBUG_RETURN(PROCESSING);
     }

--- 1.5/sql/backup/be_default.h	2007-07-02 13:27:20 -04:00
+++ 1.6/sql/backup/be_default.h	2007-07-02 13:27:20 -04:00
@@ -5,6 +5,7 @@
 #include <backup/archive.h>   // to define default backup image class
 #include "archive.h"
 #include "buffer_iterator.h"
+#include "backup_aux.h"
 
 namespace default_backup {
 
@@ -83,8 +84,8 @@
 {
   public:
     enum has_data_info { YES, WAIT, EOD };
-    Backup(const Table_list &tables, THD *t_thd);
-    virtual ~Backup() {};
+    Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type);
+    virtual ~Backup() { backup::free_table_list(all_tables); }; 
     size_t size()  { return UNKNOWN_SIZE; };
     size_t init_size() { return 0; };
     result_t  begin(const size_t) { return backup::OK; };
@@ -101,10 +102,8 @@
     void free() { delete this; };
 
  protected:
-    THD *m_thd;                    ///< Pointer to current thread struct.
-    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
-    TABLE_LIST *tables_in_backup;  ///< List of tables used in backup.
     my_bool lock_called;           ///< Checks to see if locks have been reached.
+    THD *m_thd;                    ///< Pointer to current thread struct.
 
   private:
     /*
@@ -135,6 +134,8 @@
     Buffer_iterator rec_buffer;    ///< Buffer iterator for windowing records
     Buffer_iterator blob_buffer;   ///< Buffer iterator for windowing BLOB fields
     byte *ptr;                     ///< Pointer to blob data from record.
+    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
+    TABLE_LIST *tables_in_backup;  ///< List of tables used in backup.
 };
 
 /**
@@ -153,7 +154,7 @@
   public:
     enum has_data_info { YES, WAIT, EOD };
     Restore(const Table_list &tables, THD *t_thd);
-    virtual ~Restore() {};
+    virtual ~Restore() { backup::free_table_list(all_tables); };
     result_t  begin(const size_t) { return backup::OK; };
     result_t  end();
     result_t  send_data(Buffer &buf);
@@ -161,10 +162,6 @@
     TABLE_LIST *get_table_list() { return all_tables; }
     void free() { delete this; };
 
- protected:
-    THD *m_thd;                    ///< Pointer to current thread struct.
-    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
-
  private:
      /*
       We use an enum to control the flow of the algorithm. Each mode 
@@ -194,6 +191,8 @@
     TABLE_LIST *tables_in_backup;  ///< List of tables used in backup.
     byte *blob_ptrs[MAX_FIELDS];   ///< List of blob pointers used
     int blob_ptr_index;            ///< Position in blob pointer list
+    THD *m_thd;                    ///< Pointer to current thread struct.
+    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
 };
 } // default_backup namespace
 
@@ -224,7 +223,8 @@
   { return TRUE; }; // accept all tables
 
   result_t get_backup_driver(Backup_driver* &ptr)
-  { return (ptr= new default_backup::Backup(tables,::current_thd)) ? OK : ERROR; }
+  { return (ptr= new default_backup::Backup(tables,::current_thd, 
+                                            TL_READ_NO_INSERT)) ? OK : ERROR; }
 
   result_t get_restore_driver(Restore_driver* &ptr)
   { return (ptr= new default_backup::Restore(tables,::current_thd)) ? OK : ERROR; }

--- 1.2/sql/backup/buffer_iterator.cc	2007-07-02 13:27:20 -04:00
+++ 1.3/sql/backup/buffer_iterator.cc	2007-07-02 13:27:20 -04:00
@@ -78,6 +78,8 @@
   DBUG_ENTER("buffer_iterator::reset()");
   if (alloc_used && buffer)
     my_free(buffer, MYF(0));
+  alloc_used= FALSE;
+  buffer= NULL;
   DBUG_RETURN(0);
 }
 

--- 1.1/mysql-test/r/backup_snapshot.result	2007-07-02 13:27:20 -04:00
+++ 1.2/mysql-test/r/backup_snapshot.result	2007-07-02 13:27:20 -04:00
@@ -55,4 +55,4 @@
 SELECT COUNT(*) FROM bup_snapshot.t1;
 COUNT(*)
 10
-DROP DATABASE IF EXISTS bup_snapshot;
+DROP DATABASE bup_snapshot;

--- 1.1/mysql-test/t/backup_snapshot.test	2007-07-02 13:27:20 -04:00
+++ 1.2/mysql-test/t/backup_snapshot.test	2007-07-02 13:27:20 -04:00
@@ -74,9 +74,7 @@
 SELECT * FROM bup_snapshot.t1 WHERE word LIKE '-%';
 SELECT COUNT(*) FROM bup_snapshot.t1;
 
---disable_warnings
-DROP DATABASE IF EXISTS bup_snapshot;
---enable_warnings
+DROP DATABASE bup_snapshot;
 
 --exec rm $MYSQLTEST_VARDIR/master-data/bup_snapshot.bak
 

--- 1.2/sql/backup/be_snapshot.cc	2007-07-02 13:27:20 -04:00
+++ 1.3/sql/backup/be_snapshot.cc	2007-07-02 13:27:20 -04:00
@@ -70,28 +70,18 @@
 &drv)
 {
   DBUG_ENTER("Engine::get_backup");
-  Backup *ptr= new snapshot_backup::Backup(tables, m_thd);
+  Backup *ptr= new snapshot_backup::Backup(tables, m_thd, TL_READ);
   if (!ptr)
     DBUG_RETURN(ERROR);
   drv= (backup::Backup_driver *)ptr;
   DBUG_RETURN(OK);
 }
 
-Backup::Backup(const Table_list &tables, THD *t_thd): 
-  default_backup::Backup(tables, t_thd)
+Backup::Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type): 
+  default_backup::Backup(tables, t_thd, lock_type)
 {
   DBUG_PRINT("default_backup",("Creating backup driver"));
   lock_called= FALSE;   /* lock has not been called */
-
-  /*
-     Create a TABLE_LIST * list for iterating through the tables.
-     Initialize the list for opening the tables in read mode.
-  */
-  tables_in_backup= build_table_list(tables, TL_READ);
-  all_tables= tables_in_backup;
-  if (all_tables)
-    for (TABLE_LIST *tbl= all_tables; tbl != NULL; tbl= tbl->next_global)
-      tbl->lock_type= TL_READ;
 }
 
 /**

--- 1.2/sql/backup/be_snapshot.h	2007-07-02 13:27:20 -04:00
+++ 1.3/sql/backup/be_snapshot.h	2007-07-02 13:27:20 -04:00
@@ -58,7 +58,7 @@
 class Backup: public default_backup::Backup
 {
   public:
-    Backup(const Table_list &tables, THD *t_thd);
+    Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type);
     virtual ~Backup(){};
     result_t begin(const size_t) { return backup::OK; };
     result_t end();
@@ -117,7 +117,8 @@
   }; // accept all tables that support consistent read
 
   result_t get_backup_driver(Backup_driver* &ptr)
-  { return (ptr= new snapshot_backup::Backup(tables,::current_thd)) ? OK : ERROR; }
+  { return (ptr= new snapshot_backup::Backup(tables,::current_thd, 
+                                             TL_READ)) ? OK : ERROR; }
 
   result_t get_restore_driver(Restore_driver* &ptr)
   { return (ptr= new snapshot_backup::Restore(tables,::current_thd)) ? OK : ERROR; }

--- 1.1/sql/backup/backup_aux.h	2007-07-02 13:27:20 -04:00
+++ 1.2/sql/backup/backup_aux.h	2007-07-02 13:27:20 -04:00
@@ -64,6 +64,25 @@
   return 0 == ::mysql_change_db(thd,&db_name,TRUE);
 }
 
+/*
+  Free the memory for the table list.
+*/
+inline int free_table_list(TABLE_LIST *all_tables)
+{
+  if (all_tables)
+  {
+    TABLE_LIST *tbl= all_tables; 
+    TABLE_LIST *prev= tbl;
+    while (tbl != NULL)
+    {
+      prev= tbl;
+      tbl= tbl->next_global;
+      my_free(prev, MYF(0));
+    }
+  }
+  return 0;
+}
+
 } // backup namespace
 
 #endif

--- 1.13/sql/backup/sql_backup.cc	2007-07-02 13:27:20 -04:00
+++ 1.14/sql/backup/sql_backup.cc	2007-07-02 13:27:20 -04:00
@@ -1233,7 +1233,7 @@
 
   for( uint tno=0; tno < tables.count() ; tno++ )
   {
-    TABLE_LIST *ptr= (TABLE_LIST*)sql_alloc(sizeof(TABLE_LIST));
+    TABLE_LIST *ptr= (TABLE_LIST*)my_malloc(sizeof(TABLE_LIST), MYF(MY_WME));
     DBUG_ASSERT(ptr);  // FIXME: report error instead
     bzero(ptr,sizeof(TABLE_LIST));
 

Thread
bk commit into 5.2 tree (cbell:1.2547)cbell2 Jul