List:Commits« Previous MessageNext Message »
From:cbell Date:March 15 2007 6:14pm
Subject:bk commit into 5.1 tree (cbell:1.2484)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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-03-15 14:13:45-04:00, cbell@mysql_cab_desk. +2 -0
  WL#3570 - Default backup
    
  This patch contains changes to the initial prototype code to make this code
  the initial v0.2 code for the default backup algorithm. 
  
  It also contains documentation in doxygen format. More updates may be pending
  for corrections to the documentation.

  sql/default_driver.cc@stripped, 2007-03-15 14:13:42-04:00, cbell@mysql_cab_desk. +20 -15
    WL#3570 - Default backup
      
    This patch contains changes to the initial prototype code to make this code
    the initial v0.2 code for the default backup algorithm. 

  sql/default_driver.h@stripped, 2007-03-15 14:13:42-04:00, cbell@mysql_cab_desk. +172 -29
    WL#3570 - Default backup
      
    This patch contains changes to the initial prototype code to make this code
    the initial v0.2 code for the default backup algorithm. 

# 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.1_WL_3570

--- 1.1/sql/default_driver.cc	2007-03-15 14:13:58 -04:00
+++ 1.2/sql/default_driver.cc	2007-03-15 14:13:58 -04:00
@@ -20,8 +20,6 @@
 
 /* 
   TODO list:
-    - The reading and writing of blob fields is disabled. The code needs
-      some work to ensure blob fields are restored properly.
     - Change code in send_data to allow random table writes -- the backup
       algorithm may send blocks of data in a random order from among the
       tables in the list. 
@@ -64,7 +62,7 @@
   
   /* 
      Create a TABLE_LIST * list for iterating through the tables.
-     Initialize the list for openning the tables in read mode.
+     Initialize the list for opening the tables in read mode.
   */
   tables_in_backup= build_table_list(tables, TL_READ);
   all_tables= tables_in_backup;
@@ -329,7 +327,7 @@
         mode on and get the first blob in the list.
       */
       read_blobs= (cur_table->s->blob_fields > 0);
-      read_blobs= 0;
+      //read_blobs= 0;
       if (read_blobs)
       {
         reading= 0;
@@ -412,7 +410,7 @@
   
   /* 
      Create a TABLE_LIST * list for iterating through the tables.
-     Initialize the list for openning the tables in write mode.
+     Initialize the list for opening the tables in write mode.
   */
   tables_in_backup= build_table_list(tables, TL_WRITE);
   all_tables= tables_in_backup;
@@ -435,7 +433,7 @@
 
   RETURNS
     backup::OK    - rows deleted.
-    backup::Error - problem with delting rows.
+    backup::Error - problem with deleting rows.
 */
 result_t Restore::truncate_table(TABLE *tbl)
 {
@@ -615,18 +613,22 @@
   {
     memcpy(cur_table->record[0], buf.data, cur_table->s->reclength);    
     cur_table->use_all_columns();
-    last_write_res = hdl->write_row(cur_table->record[0]);
-    DBUG_ASSERT(last_write_res == 0);
-    if (last_write_res == 0)
-      writing= 1;
     /*
       Check for the existence of blobs. If no blobs, we're finished 
-      writing data for this row. If there are blobs, turn write_blob
-      mode on and get the first blob in the list.
+      writing data for this row so just run the write_row(). If there
+      are blobs, turn write_blob mode on and get the first blob in 
+      the list. The write_row() call will be delayed until after all
+      blobs are written.
     */
     write_blobs= (cur_table->s->blob_fields > 0);
-    write_blobs= 0;
-    if (write_blobs)
+    if (!write_blobs)
+    {
+      last_write_res = hdl->write_row(cur_table->record[0]);
+      DBUG_ASSERT(last_write_res == 0);
+      if (last_write_res == 0)
+        writing= 1;
+    }
+    else
     {
       writing= 0;
       cur_blob= cur_table->s->blob_field;
@@ -662,7 +664,10 @@
     cur_blob++; 
     if (cur_blob == last_blob_ptr)
     {
-      writing= 1;
+      last_write_res = hdl->write_row(cur_table->record[0]);
+      DBUG_ASSERT(last_write_res == 0);
+      if (last_write_res == 0)
+        writing= 1;
       write_blobs= 0;
     }
     DBUG_RETURN(backup::OK);

--- 1.1/sql/default_driver.h	2007-03-15 14:13:58 -04:00
+++ 1.2/sql/default_driver.h	2007-03-15 14:13:58 -04:00
@@ -49,7 +49,7 @@
  *
  * @brief Encapsulates default online backup/restore functionality.
  *
- * This class is used to initiate the default backup algorthm, which is used 
+ * This class is used to initiate the default backup algorithm, which is used 
  * by the backup kernel to create a backup image of data stored in any
  * engine that does not have a native backup driver. It may also be used as
  * an option by the user. 
@@ -111,6 +111,8 @@
  * The backup class is a row-level backup mechanism designed to perform
  * a table scan on each table reading the rows and saving the data to the
  * buffer from the backup algorithm.
+ *
+ * @see <backup driver>
  */ 
 class Backup: public Backup_driver
 {
@@ -120,31 +122,106 @@
     virtual ~Backup();
     size_t size()  { return UNKNOWN_SIZE; };
     size_t init_size() { return 0; };
+
+    /** 
+     * @brief Start backup process.
+     *
+     * This method locks all of the tables for reading.
+     *
+     * @return
+     * backup::OK    - all tables locked properly.
+     * backup::Error - problem with locking tables.
+     */
     result_t begin();
+
+    /** 
+     * @brief End backup process.
+     *
+     * This method unlocks all of the tables.
+     *
+     * @return
+     * backup::OK    - all tables unlocked.
+     */
     result_t end();
+
+    /** 
+     * @brief Get the data for a row in the table.
+     * This method is the main method used in the backup operation. It is
+     * responsible for reading a row from the table and placing the data in
+     * the buffer (buf.data) and setting the correct attributes for processing
+     * (e.g., buf.size = size of record data).
+     *
+     * Control of the method is accomplished by using several modes that
+     * signal portions of the method to run. These modes are:
+     *
+     * initialized    - Signals (when false) method to initialize variables
+     *                  and prepare for backup process. When true, indicates
+     *                  the initialization process is complete.
+     * get_next_table - Signals method to move to the next table in the list.
+     *                  May be used in conjunction with reading and read_blobs.
+     * reading        - Signals method to read next row of data.
+     * read_blobs     - Signals that row has blobs and to read blob data.
+     *
+     * @return
+     * backup::INIT_DODE - initialization phase complete.
+     * backup::OK        - data read.
+     * backup::Error     - problem with reading data.
+     */
     result_t get_data(Buffer &buf);
     result_t lock();
     result_t unlock();
     result_t cancel() { return backup::OK; };
     void free() { delete this; };
   private:
+    /**
+     * @brief Start table read.
+     *
+     * This method saves the handler for the table and initializes the 
+     * handler for reading.
+     *
+     * @return
+     * backup::OK    - handler initialized properly.
+     * backup::Error - problem with hander initialization.
+     */
     result_t start_tbl_read(TABLE *tbl);
+
+    /**
+     * @brief End table read.
+     *
+     * This method signals the handler that the reading process is complete.
+     *
+     * @return
+     * backup::OK    - handler read stopped properly.
+     * backup::Error - problem with hander.
+     */
     result_t end_tbl_read();
-    int next_table();
-    int initialized;
-    int reading;
-    int last_read_res;
-    int tbl_num;
-    int read_blobs;
-    int get_next_table;
-    TABLE *cur_table;
-    THD *m_thd;
-    handler *hdl;
-    uint *cur_blob;
-    uint *last_blob_ptr;
-	  TABLE_LIST *tables_in_backup;
-    TABLE_LIST *all_tables;
-    MY_BITMAP *read_set;
+
+    /** 
+     * @brief Get next table in the list.
+     *
+     * This method iterates through the list of tables selecting the
+     * next table in the list and starting the read process.
+     *
+     * @return
+     * 0  - no errors.
+     * -1 - no more tables in list.
+     */
+    int next_table();  
+
+    int initialized;               ///< Indicates code has been initialized.
+    int reading;                   ///< Indicates mode is read row.
+    int last_read_res;             ///< The last result code from handler.
+    int tbl_num;                   ///< The index of the current table.
+    int read_blobs;                ///< Indicates mode is read blob data.
+    int get_next_table;            ///< Indicates get the next table in list.
+    TABLE *cur_table;              ///< The table currently being read.
+    THD *m_thd;                    ///< Pointer to current thread struct.
+    handler *hdl;                  ///< Pointer to table handler.
+    uint *cur_blob;                ///< The current blob field.
+    uint *last_blob_ptr;           ///< Position of last blob field.
+	  TABLE_LIST *tables_in_backup;  ///< List of tables used in backup.
+    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
+    MY_BITMAP *read_set;           ///< The file read set.
 };
 
 /**
@@ -155,6 +232,8 @@
  * The restore class is a row-level backup mechanism designed to restore
  * data for each table by writing the data for the rows from the
  * buffer given by the backup algorithm.
+ *
+ * @see <restore driver>
  */ 
 class Restore: public Restore_driver
 {
@@ -162,27 +241,91 @@
     enum has_data_info { YES, WAIT, EOD };
     Restore(const Table_list &tables, THD *t_thd);
     virtual ~Restore();
+
+    /** 
+     * @brief Start restore process.
+     *
+     * This method locks all of the tables for writing.
+     *
+     * @return
+     * backup::OK    - all tables locked properly.
+     * backup::Error - problem with locking tables.
+     */
     result_t  begin();
+
+    /** 
+     * @brief End restore process.
+     *
+     * This method unlocks all of the tables.
+     *
+     * @return
+     * backup::OK    - all tables unlocked.
+     */
     result_t  end();
+
+    /** 
+     * @brief Restore the data for a row in the table.
+     *
+     * This method is the main method used in the restore operation. It is
+     * responsible for writing a row to the table.
+     *
+     * Control of the method is accomplished by using several modes that
+     * signal portions of the method to run. These modes are:
+     *
+     * initialized    - Signals (when false) method to initialize variables
+     *                  and prepare for restore process. When true, indicates
+     *                  the initialization process is complete.
+     * get_next_table - Signals method to move to the next table in the list.
+     *                  May be used in conjunction with writing and write_blobs.
+     * writing        - Signals method to write next row of data.
+     * write_blobs    - Signals that row has blobs and to write blob data.
+     *
+     * @return
+     * backup::INIT_DODE - initialization phase complete.
+     * backup::OK        - data written.
+     * backup::Error     - problem with writing data.
+     */
     result_t  send_data(Buffer &buf);
     result_t  cancel() { return backup::OK; };
     void free() { delete this; };
  private:
+    /**
+     * @brief Truncate table.
+     *
+     * This method saves the handler for the table and deletes all rows in
+     * the table.
+     *
+     * @return
+     * backup::OK    - rows deleted.
+     * backup::Error - problem with deleting rows.
+     */
     result_t truncate_table(TABLE *tbl);
+
+    /** 
+     * @brief Get next table in the list.
+     *
+     * This method iterates through the list of tables selecting the
+     * next table in the list and starting the read process.
+     *
+     * @return
+     * 0  - no errors.
+     * -1 - no more tables in list.
+     */
     int next_table();
-    int initialized;
-    int last_write_res;
-    int tbl_num;
-    int write_blobs;
-    int writing;
-    int get_next_table;
-    TABLE *cur_table;
-    THD *m_thd;
-    handler *hdl;
-    uint *cur_blob;
-    uint *last_blob_ptr;
- 	  TABLE_LIST *tables_in_backup;
-    TABLE_LIST *all_tables;
+
+    int initialized;               ///< Indicates code has been initialized.
+    int writing;                   ///< Indicates mode is write row.
+    int last_write_res;            ///< The last result code from handler.
+    int tbl_num;                   ///< The index of the current table.
+    int write_blobs;               ///< Indicates mode is write blob data.
+    int get_next_table;            ///< Indicates get the next table in list.
+    TABLE *cur_table;              ///< The table currently being read.
+    THD *m_thd;                    ///< Pointer to current thread struct.
+    handler *hdl;                  ///< Pointer to table handler.
+    uint *cur_blob;                ///< The current blob field.
+    uint *last_blob_ptr;           ///< Position of last blob field.
+	  TABLE_LIST *tables_in_backup;  ///< List of tables used in backup.
+    TABLE_LIST *all_tables;        ///< Reference to list of tables used.
 };
 } // default_backup namespace
 #endif

Thread
bk commit into 5.1 tree (cbell:1.2484)cbell15 Mar