List:Commits« Previous MessageNext Message »
From:rsomla Date:April 20 2007 5:38am
Subject:bk commit into 5.1 tree (rafal:1.2523)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of rafal. When rafal 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-04-20 07:37:57+02:00, rafal@quant.(none) +5 -0
  WL#3327: Driver API change: rename buf.stream_no -> buf.table_no.

  sql/backup/backup_engine.h@stripped, 2007-04-20 07:37:51+02:00, rafal@quant.(none) +42 -36
    Rename: buf.stream_no -> buf.table_no.

  sql/backup/be_default.cc@stripped, 2007-04-20 07:37:52+02:00, rafal@quant.(none) +9 -9
    Rename: buf.stream_no -> buf.table_no.

  sql/backup/be_nodata.cc@stripped, 2007-04-20 07:37:52+02:00, rafal@quant.(none) +2 -2
    Rename: buf.stream_no -> buf.table_no.

  sql/backup/data_backup.cc@stripped, 2007-04-20 07:37:52+02:00, rafal@quant.(none) +8 -8
    Rename: buf.stream_no -> buf.table_no.

  storage/archive/abackup.cc@stripped, 2007-04-20 07:37:52+02:00, rafal@quant.(none) +6 -6
    Rename: buf.stream_no -> buf.table_no.

# 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:	rafal
# Host:	quant.(none)
# Root:	/ext/mysql/bk/backup/prototype-push

--- 1.14/sql/backup/be_default.cc	2007-04-20 07:38:03 +02:00
+++ 1.15/sql/backup/be_default.cc	2007-04-20 07:38:03 +02:00
@@ -242,7 +242,7 @@
 {
   DBUG_ENTER("Default_backup::get_data(Buffer &buf)");
 
-  buf.stream_no= tbl_num;
+  buf.table_no= tbl_num;
   /*
     If class has been initialized and we need to read the next table,
     advance the current table pointer and initialize read process.
@@ -261,7 +261,7 @@
     {
       if (cur_table == NULL)
       {
-        buf.stream_no= tbl_num;
+        buf.table_no= tbl_num;
         buf.size= 0;
         buf.last= TRUE;
       }
@@ -272,16 +272,16 @@
       start_tbl_read(cur_table);
       tbl_num++;
       reading= 1;
-      buf.stream_no= tbl_num;
+      buf.table_no= tbl_num;
     }
   }
   /*
-    Initialize the reading process. Return INIT_DONE to indicate complete.
+    Initialize the reading process. Return READY to indicate complete.
   */
   if (!initialized)
   {
     buf.size= 0;
-    buf.stream_no= 0;
+    buf.table_no= 0;
     buf.last= TRUE;
     initialized= 1;
     reading= 1;
@@ -564,7 +564,7 @@
 {
   DBUG_ENTER("Restore::send_data");
   DBUG_PRINT("default/restore",("Got packet with %lu bytes from stream %u",
-                                (unsigned long)buf.size, buf.stream_no));
+                                (unsigned long)buf.size, buf.table_no));
 
   /*
     If class has been initialized and we need to get the next table,
@@ -582,7 +582,7 @@
       find the table in question. This is needed if any tables (more
       than MAX_RETRIES are empty!
     */
-    if ((tbl_num + 1) == buf.stream_no) //do normal sequential lookup
+    if ((tbl_num + 1) == buf.table_no) //do normal sequential lookup
       res= next_table();
     else                                //do linear search
     {
@@ -595,7 +595,7 @@
         i++;
         res= next_table();
       }
-      while ((i != buf.stream_no) && !res);
+      while ((i != buf.table_no) && !res);
       tbl_num= i - 1;
     }
     if (res)
@@ -628,7 +628,7 @@
     receiving data from the backup for a different table. Set the mode to
     get the next table in the list.
   */
-  else if (tbl_num != buf.stream_no)
+  else if (tbl_num != buf.table_no)
   {
     get_next_table= 1;
     DBUG_RETURN(backup::PROCESSING);

--- 1.4/sql/backup/backup_engine.h	2007-04-20 07:38:03 +02:00
+++ 1.5/sql/backup/backup_engine.h	2007-04-20 07:38:03 +02:00
@@ -115,47 +115,53 @@
 /**
   @class Buffer
 
-  @brief Used for data transfers between backup kernel and backup/restore drivers.
+  @brief Used for data transfers between backup kernel and backup/restore
+  drivers.
 
-  Apart from allocated memory a Buffer structure contains fields informing about its size
-  and holding other information about contained data.
-  Buffers are created and memory is allocated by backup kernel. It is also
-  kernel's responsibility to write contents of buffers to a backup stream.
+  Apart from allocated memory a Buffer structure contains fields informing about
+  its size and holding other information about contained data. Buffers are
+  created and memory is allocated by backup kernel. It is also kernel's
+  responsibility to write contents of buffers to a backup stream.
 
   Data created by a backup driver is opaque to the kernel. However, to support
-  restore of only selected tables, the backup image is divided into several
-  "data streams" corresponding to individual tables.
+  selective restores, each block of data can be assigned to one of the tables
+  being backed-up. This is done by setting <code>table_no</code> member of the
+  buffer structure to the number of the table to which this data belongs. Tables
+  are numbered from 1 acoording to their position in the list passed when driver
+  is created (<code>m_list</code> member of <code>Driver</code> class). If some
+  of the data doesn't correspond to any particular table, then
+  <code>table_no</code> should be set to 0.
+
+  This way, driver can create several "streams" of data blocks. For each table
+  there is a stream corresponding to that table and there is one "shared stream"
+  consisting of blocks with <code>table_no</code> set to 0. Upon restore, kernel
+  sends to a restore driver only blocks corresponding to the tables being
+  restored plus all the blocks from the shared stream.
 
-  There is one stream per each backed-up table plus one extra "shared stream"
-  containing any data common to all tables. One stream contains all data which
-  together with data from the shared stream allows to restore the corresponding
-  table. When, upon restore, a user selects only some tables to be restored
-  from archive, a restore driver will get data from the shared stream and
-  streams corresponding to the restored tables only.
-
-  As an example consider a request for backing-up tables t1, t2 and t3.
-  It creates backup image consisting of four data streams:
+  For example, consider backing-up three tables t1, t2 and t3. Data blocks
+  produced by a backup driver are divided into four streams:
   <pre>
   #0: shared data
   #1: data for table t1
   #2: data for table t2
   #3: data for table t3
   </pre>
-  Later, a user wants to restore tables t1 and t3 only. The backup kernel will
-  send to a restore driver streams #0, #1 and #3 but not #2. Hence stream #2
-  should not contain any data which would be needed to restore t1 or t3.
-
-  It is up to a backup driver how it distributes its backup data
-  among the streams. It is possible that all data will be sent in
-  the shared stream and per table streams will be empty or vice versa.
-  However, it is important to keep in mind that upon restore only the shared
-  stream and the streams corresponding to the tables being restored will be
-  send back to a restore driver.
-
-  When filling a buffer with data, backup driver informs to which stream it
-  belongs by setting its <code>stream_no</code> member. If this is the last
-  chunk of data in this stream, then <code>last</code> member must be set to
-  TRUE. Otherwise, <code>last</code> should be FALSE.
+  When a user restores tables t1 and t3, only blocks from streams #0, #1 and #3
+  will be sent to a restore driver, but not the ones from stream #2.
+
+  Using this approach, backup engine can arrange its backup image data in the
+  way which best suits its internal data representation. If needed, all data can
+  be put in the shared stream #0, so that all of it will be sent back to
+  a restore driver. On the other hand, if possible, backup data can be
+  distributed into per table streams to reduce the amount of data transferred
+  upon a selective restore.
+
+  Backup driver signals end of data in a given stream by setting
+  <code>buf.last</code> flag to TRUE when get_data(buf) fills the last block of
+  data from that stream (otherwise <code>buf.last</code> should be FALSE). This
+  should be done for each stream used by the driver. Upon restore, kernel sets
+  <code>buf.last</code> to TRUE when sending to a restore driver the last block
+  of data from a stream.
 
   A driver learns about the size of a buffer provided by the kernel from its
   <code>size</code> member. It does not have to fill the buffer completely.
@@ -168,18 +174,18 @@
 struct Buffer
 {
   size_t  size;       ///< size of the buffer (of memory block pointed by data).
-  uint    stream_no;  ///< Number of the stream to which data in the buffer belongs.
+  uint    table_no;   ///< Number of the table to which data in the buffer belongs.
   bool    last;       ///< <code>TRUE</code> if this is last block of data in the stream.
   byte    *data;      ///< Pointer to data area.
 
-  Buffer(): data(NULL),size(0),stream_no(0),last(TRUE)
+  Buffer(): data(NULL),size(0),table_no(0),last(FALSE)
   {}
 
   void reset(size_t len)
   {
-    size=      len;
-    stream_no= 0;
-    last=      TRUE;
+    size= len;
+    table_no= 0;
+    last= FALSE;
   }
 };
 

--- 1.2/sql/backup/be_nodata.cc	2007-04-20 07:38:03 +02:00
+++ 1.3/sql/backup/be_nodata.cc	2007-04-20 07:38:03 +02:00
@@ -9,7 +9,7 @@
 
   buf.last= true;
   buf.size= 0;
-  buf.stream_no= 0;
+  buf.table_no= 0;
 
   switch (stage) {
 
@@ -22,7 +22,7 @@
 
     if (table <= m_tables.count())
     {
-      buf.stream_no= table++;
+      buf.table_no= table++;
       return OK;
     }
     else

--- 1.14/sql/backup/data_backup.cc	2007-04-20 07:38:03 +02:00
+++ 1.15/sql/backup/data_backup.cc	2007-04-20 07:38:03 +02:00
@@ -766,11 +766,11 @@
 
         if (m_buf.last)
         {
-          mark_stream_closed(m_buf.stream_no);
+          mark_stream_closed(m_buf.table_no);
           if (all_streams_closed())
             DBUG_PRINT("backup/data",(" all streams of %s closed",m_name));
           else
-            DBUG_PRINT("backup/data",(" stream %u closed",m_buf.stream_no));
+            DBUG_PRINT("backup/data",(" stream %u closed",m_buf.table_no));
         }
 
         m_buf.data= m_buf_head;
@@ -781,7 +781,7 @@
           // TODO: use OStream interface for consistency
           m_buf.size+= 4;
           int2store(m_buf.data,m_drv_no+1);
-          int2store(m_buf.data+2,m_buf.stream_no);
+          int2store(m_buf.data+2,m_buf.table_no);
           mode= WRITING;
         }
         else
@@ -816,8 +816,8 @@
       case Block_writer::OK:
 
         howmuch= m_buf.size;
-        DBUG_PRINT("backup/data",(" added %lu bytes from %s to archive (drv_no=%u, stream_no=%u)",
-                                  (unsigned long)howmuch, m_name, m_drv_no, m_buf.stream_no));
+        DBUG_PRINT("backup/data",(" added %lu bytes from %s to archive (drv_no=%u, table_no=%u)",
+                                  (unsigned long)howmuch, m_name, m_drv_no, m_buf.table_no));
 
         mode= READING;
         break;
@@ -850,7 +850,7 @@
 Block_writer::result_t
 Block_writer::get_buf(Buffer &buf)
 {
-  buf.stream_no= 0;
+  buf.table_no= 0;
   buf.last= FALSE;
   buf.size= buf_size;
   buf.data= m_str.get_window(buf.size);
@@ -951,12 +951,12 @@
       DBUG_ASSERT(buf.data);
 
       img_no= uint2korr(buf.data);
-      buf.stream_no= uint2korr(buf.data+2);
+      buf.table_no= uint2korr(buf.data+2);
       buf.data += 4;
       buf.size -= 4;
 
       DBUG_PRINT("restore",("Got %lu bytes of subimage %u data (stream %u)",
-                 (unsigned long)buf.size, img_no, buf.stream_no));
+                 (unsigned long)buf.size, img_no, buf.table_no));
 
     case SENDING:
 

--- 1.18/storage/archive/abackup.cc	2007-04-20 07:38:04 +02:00
+++ 1.19/storage/archive/abackup.cc	2007-04-20 07:38:04 +02:00
@@ -213,7 +213,7 @@
   
   result_t ret;
   
-  buf.stream_no= 0;
+  buf.table_no= 0;
   buf.last= TRUE;
 
   switch (state) {
@@ -230,7 +230,7 @@
   case DUMPING:  
     {
       Table_backup  *image= images[stream];
-      buf.stream_no= stream+1;
+      buf.table_no= stream+1;
         
       switch( image->has_data() )
       {
@@ -597,7 +597,7 @@
 result_t Restore::send_data(Buffer &buf)
 {
   DBUG_PRINT("archive/restore",("Got packet with %lu bytes from stream %u",
-                                (unsigned long)buf.size, buf.stream_no));
+                                (unsigned long)buf.size, buf.table_no));
                                 
   if( !images )
     return backup::ERROR;
@@ -608,10 +608,10 @@
     return backup::OK;
   };
   
-  if( buf.stream_no == 0 )
+  if( buf.table_no == 0 )
     return backup::OK;  // common stream not used.
   
-  Table_restore *img = images[buf.stream_no-1];
+  Table_restore *img = images[buf.table_no-1];
   
   if( !img )
     return backup::ERROR;
@@ -625,7 +625,7 @@
       stage= DONE;
     img->finish();  
     delete img;
-    images[buf.stream_no-1]= NULL;
+    images[buf.table_no-1]= NULL;
   };    
 
   return backup::OK;
Thread
bk commit into 5.1 tree (rafal:1.2523)rsomla20 Apr