List:Commits« Previous MessageNext Message »
From:rsomla Date:February 27 2008 8:04pm
Subject:bk commit into 6.0 tree (rafal:1.2768) WL#4212
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 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, 2008-02-27 21:04:14+01:00, rafal@quant.(none) +28 -0
  WL#4212 (Online Backup : Kernel updates for object metadata changes)
  
  This patch contains code layout changes and other fixes requested by reviewers.

  sql/backup/api_types.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +29 -28
    Code layout changes to make it more conforming to our coding guidelines. Change _no ending to _num in names. 

  sql/backup/backup_aux.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +22 -17
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/backup_engine.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +9 -9
    Code layout changes to make it more conforming to our coding guidelines. Change _no ending to _num in names. 

  sql/backup/backup_info.cc@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +56 -50
    - Code layout changes to make it more conforming to our coding guidelines. 
    - Extending comments and function documentation.
    - Removing TEST_ERROR_IF macros.

  sql/backup/backup_info.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +10 -10
    Cosmetic changes.

  sql/backup/backup_kernel.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +13 -7
    Cosmetic changes (remove too long lines).

  sql/backup/backup_test.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +8 -8
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/be_default.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +12 -12
    Change _no ending to _num in names. 

  sql/backup/be_default.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +4 -4
    Cosmetic changes.

  sql/backup/be_native.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +7 -7
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/be_snapshot.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +8 -8
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/be_thread.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +2 -2
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/data_backup.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +120 -108
    Code layout changes to make it more conforming to our coding guidelines. 
    Change _no ending to _num in names.
    Rename of IStream and OStream.

  sql/backup/debug.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +1 -41
    Remove TEST_ERROR_IF macro and friends.

  sql/backup/image_info.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +52 -37
    Code layout changes to make it more conforming to our coding guidelines. 
    Change _no ending to _num in names. 
    Document explicit values given in the code.
    Added implementation of Image_info::has_db() method.

  sql/backup/image_info.h@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +63 -58
    Fix integer types used for indexing objects in the catalogue.
    Document the 256 limit on number of snapshots.
    Change _no ending to _num in names.
    Remove default implementation of Snapshot_info::name() method.

  sql/backup/kernel.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +153 -139
    Move description of backup/restore context usage inside doxygen comment.
    Reformulate/extend/update some documentation.
    Change code layout to make it more conforming to our coding guidelines.
    Added comments about correct placement of DDL blocker calls.

  sql/backup/logger.cc@stripped, 2008-02-27 21:04:09+01:00, rafal@quant.(none) +12 -10
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/logger.h@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +8 -8
    Code layout changes to make it more conforming to our coding guidelines.

  sql/backup/restore_info.h@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +12 -11
    Code layout changes to make it more conforming to our coding guidelines. IStream rename.

  sql/backup/stream.cc@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +28 -28
    Code layout changes to make it more conforming to our coding guidelines. IStream and OStream renames.

  sql/backup/stream.h@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +22 -16
    Code layout changes to make it more conforming to our coding guidelines.
    Renames IStream -> Input_stream, OStream -> Output_stream.

  sql/backup/stream_v1.c@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +19 -19
    Use "num" and "no." instead of "no".

  sql/backup/stream_v1.h@stripped, 2008-02-27 21:04:10+01:00, rafal@quant.(none) +9 -4
    Use "num" and "no." instead of "no".
    Added explanation of the fixed 256 limit for number of snapshots.

  sql/si_objects.cc@stripped, 2008-02-27 21:04:07+01:00, rafal@quant.(none) +4 -3
    Fix return value of ddl_blocker_enable() (as specified in the header file).

  sql/sql_lex.h@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +0 -1
    Remove SHOW_ARCHIVE command.

  sql/sql_parse.cc@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +0 -6
    Remove SHOW_ARCHIVE command.

  sql/sql_yacc.yy@stripped, 2008-02-27 21:04:08+01:00, rafal@quant.(none) +0 -5
    Remove SHOW_ARCHIVE command.

diff -Nrup a/sql/backup/api_types.h b/sql/backup/api_types.h
--- a/sql/backup/api_types.h	2008-02-18 13:04:23 +01:00
+++ b/sql/backup/api_types.h	2008-02-27 21:04:08 +01:00
@@ -40,15 +40,16 @@ typedef uint  version_t;
    Classes @c Db_ref and @c Table_ref are used to identify databases and tables
    inside mysql server instance.
 
-   These classes abstract the way a table or database is identified inside mysqld,
-   so that when this changes (introduction of global db/table ids, introduction
-   of catalogues) it is easy to adapt backup code to the new identification schema.
+   These classes abstract the way a table or database is identified inside 
+   mysqld, so that when this changes (introduction of global db/table ids, 
+   introduction of catalogues) it is easy to adapt backup code to the new 
+   identification schema.
 
    Regardless of the internal representation, classes provide methods returning
-   db/table name as a @c String object. Also, each table belongs to some database
-   and a method returning @c Db_ref object identifying this database is present. 
-   For @c Db_ref objects there is @c catalog() method returning name of the 
-   catalogue, but currently it always returns null string.
+   db/table name as a @c String object. Also, each table belongs to some 
+   database and a method returning @c Db_ref object identifying this database is
+   present. For @c Db_ref objects there is @c catalog() method returning name of
+   the catalogue, but currently it always returns null string.
 
    Classes are implemented so that the memory for storing names can be allocated
    outside an instance. This allows for sharing space used e.g., to store 
@@ -68,7 +69,7 @@ class Db_ref
  public:
 
   // Construct invalid reference
-  Db_ref(): m_name(NULL)
+  Db_ref() :m_name(NULL)
   {}
 
   const bool is_valid() const
@@ -81,17 +82,17 @@ class Db_ref
   { return my_null_string; }
 
   bool operator==(const Db_ref &db) const
-  { return stringcmp(m_name,&db.name())==0; }
+  { return stringcmp(m_name, &db.name()) == 0; }
 
   bool operator!=(const Db_ref &db) const
-  { return ! this->operator==(db); }
+  { return ! this->operator == (db); }
 
  protected:
 
   // Constructors are made protected as clients of this class are
   // not supposed to create instances (see comment inside Table_ref)
 
-  Db_ref(const String &name): m_name(&name)
+  Db_ref(const String &name) :m_name(&name)
   {}
 
   friend class Table_ref;
@@ -106,7 +107,7 @@ class Table_ref
  public:
 
   // Construct invalid reference
-  Table_ref(): m_name(NULL)
+  Table_ref() :m_name(NULL)
   {}
 
   const bool is_valid() const
@@ -121,7 +122,7 @@ class Table_ref
   bool operator==(const Table_ref &t) const
   {
     return m_db == t.db() &&
-           stringcmp(m_name,&t.name()) == 0;
+           stringcmp(m_name, &t.name()) == 0;
   }
 
   bool operator!=(const Table_ref &db) const
@@ -132,12 +133,12 @@ class Table_ref
   /// Produce string identifying the table (e.g. for error reporting)
   const char* describe(char *buf, size_t len) const
   {
-    my_snprintf(buf,len,"`%s`.`%s`",db().name().ptr(),name().ptr());
+    my_snprintf(buf, len, "`%s`.`%s`", db().name().ptr(), name().ptr());
     return buf;
   }
 
   const char* describe(describe_buf &buf) const
-  { return describe(buf,sizeof(buf)); }
+  { return describe(buf, sizeof(buf)); }
   
  protected:
 
@@ -148,8 +149,8 @@ class Table_ref
     when creating backup/restore driver.
   */
 
-  Table_ref(const String &db, const String &name):
-    m_db(db), m_name(&name)
+  Table_ref(const String &db, const String &name)
+    :m_db(db), m_name(&name)
   {}
 };
 
@@ -174,8 +175,8 @@ class Table_ref
    adds this interface to a list of tables represented by a linked list of
    @c TABLE_LIST structures as used elsewhere in the code. On the other hand, 
    much more space efficient implementations are possible, as for each table we 
-   need to store only table's identity (db/table name). In any case, the interface
-   to the list remains the same, as defined by this class.
+   need to store only table's identity (db/table name). In any case, the 
+   interface to the list remains the same, as defined by this class.
 
    TODO: add iterators.
  */
@@ -200,23 +201,23 @@ class Table_list
   @brief Used for data transfers between backup kernel and backup/restore
   drivers.
 
-  Apart from allocated memory a @c Buffer structure contains fields informing about
-  its size and holding other information about contained data. Buffers are
+  Apart from allocated memory a @c 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
   selective restores, each block of data can be assigned to one of the tables
-  being backed-up. This is done by setting @c table_no member of the
+  being backed-up. This is done by setting @c table_num member of the
   buffer structure to the number of the table to which this data belongs. Tables
   are numbered from 1 according to their position in the list passed when driver
   is created (@c m_tables member of @c Driver class). If
   some of the data doesn't correspond to any particular table, then
-  @c table_no should be set to 0.
+  @c table_num 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 @c table_no set to 0. Upon restore, kernel
+  consisting of blocks with @c table_num 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.
 
@@ -256,17 +257,17 @@ class Table_list
 struct Buffer
 {
   size_t  size;       ///< size of the buffer (of memory block pointed by data).
-  uint    table_no;   ///< Number of the table to which data in the buffer belongs.
+  uint    table_num;  ///< Number of the table to which data in the buffer belongs.
   bool    last;       ///< TRUE if this is last block of data in the stream.
   byte    *data;      ///< Pointer to data area.
 
-  Buffer(): size(0),table_no(0),last(FALSE), data(NULL)
+  Buffer() :size(0), table_num(0), last(FALSE), data(NULL)
   {}
 
   void reset(size_t len)
   {
     size= len;
-    table_no= 0;
+    table_num= 0;
     last= FALSE;
   }
 };
@@ -280,7 +281,7 @@ class Restore_driver;
 
 typedef backup::result_t Backup_result_t;
 typedef backup::Engine   Backup_engine;
-typedef Backup_result_t backup_factory(::handlerton *,Backup_engine*&);
+typedef Backup_result_t backup_factory(::handlerton *, Backup_engine*&);
 
 #endif
 
diff -Nrup a/sql/backup/backup_aux.h b/sql/backup/backup_aux.h
--- a/sql/backup/backup_aux.h	2008-02-12 18:17:50 +01:00
+++ b/sql/backup/backup_aux.h	2008-02-27 21:04:08 +01:00
@@ -27,7 +27,7 @@ handlerton* se_hton(storage_engine_ref s
 inline
 storage_engine_ref get_se_by_name(const LEX_STRING name)
 { 
-  plugin_ref plugin= ::ha_resolve_by_name(::current_thd,&name);
+  plugin_ref plugin= ::ha_resolve_by_name(::current_thd, &name);
   return plugin_ref_to_se_ref(plugin); 
 }
 
@@ -84,29 +84,29 @@ class String: public ::String
 {
  public:
 
-  String(const ::String &s): ::String(s)
+  String(const ::String &s) : ::String(s)
   {}
 
-  String(const ::LEX_STRING &s):
-    ::String(s.str,s.length,&::my_charset_bin) // FIXME: charset info
+  String(const ::LEX_STRING &s)
+    : ::String(s.str, s.length, &::my_charset_bin) // FIXME: charset info
   {}
 
-  String(byte *begin, byte *end):
-    ::String((char*)begin,end-begin,&::my_charset_bin) // FIXME: charset info
+  String(byte *begin, byte *end)
+    : ::String((char*)begin, end - begin, &::my_charset_bin) // FIXME: charset info
   {
     if (!begin)
-     set((char*)NULL,0,NULL);
+     set((char*)NULL, 0, NULL);
   }
 
-  String(const char *s):
-    ::String(s,&::my_charset_bin)
+  String(const char *s)
+    : ::String(s, &::my_charset_bin)
   {}
 
-  String(): ::String()
+  String() : ::String()
   {}
 };
 
-TABLE_LIST *build_table_list(const Table_list&,thr_lock_type);
+TABLE_LIST *build_table_list(const Table_list&, thr_lock_type);
 
 /*
   Free the memory for the table list.
@@ -197,10 +197,14 @@ class Map
 template<class A, class B>
 struct Map<A,B>::Node
 {
-  A key;  // Note: must be first for correct key offset value in HASH initialization
+  /* 
+    Note: key member must be first for correct key offset value in HASH 
+    initialization.
+   */
+  A key;  
   B *ptr;
 
-  Node(const A &a, B *b): key(a), ptr(b) {}
+  Node(const A &a, B *b) :key(a), ptr(b) {}
   
   static void del_key(void *node)
   { delete (Node*) node; }
@@ -226,7 +230,7 @@ template<class A, class B>
 inline
 int Map<A,B>::insert(const A &a, B *b)
 {
-  Node *n= new Node(a,b); // TODO: use mem root (?)
+  Node *n= new Node(a, b); // TODO: use mem root (?)
 
   return my_hash_insert(&m_hash, (uchar*) n);
 }
@@ -243,7 +247,8 @@ B* Map<A,B>::operator[](const A &a) cons
 
 
 /**
-  Specialization of Map template with integer indexes implemented as a Dynamic_array.
+  Specialization of Map template with integer indexes implemented as a 
+  Dynamic_array.
  */ 
 template<class T>
 class Map<uint,T>: public ::Dynamic_array< T* >
@@ -265,7 +270,7 @@ class Map<uint,T>: public ::Dynamic_arra
 
 template<class T>
 inline
-Map<uint,T>::Map(uint init_size, uint increment): Base(init_size, increment)
+Map<uint,T>::Map(uint init_size, uint increment) :Base(init_size, increment)
 {
   clear_free_space();
 }
@@ -301,7 +306,7 @@ int Map<uint,T>::insert(ulong pos, T *pt
     return 1;
 
   if (pos >= Base::array.elements)
-    Base::array.elements= pos+1;
+    Base::array.elements= pos + 1;
 
   entry= dynamic_array_ptr(array, pos);
   *(T**)entry= ptr;
diff -Nrup a/sql/backup/backup_engine.h b/sql/backup/backup_engine.h
--- a/sql/backup/backup_engine.h	2007-11-06 19:32:08 +01:00
+++ b/sql/backup/backup_engine.h	2008-02-27 21:04:08 +01:00
@@ -139,7 +139,7 @@ class Driver
                   };
 
   /// Construct from list of tables. The list is stored for future use.
-  Driver(const Table_list &tables):m_tables(tables) {};
+  Driver(const Table_list &tables) :m_tables(tables) {};
 
   virtual ~Driver() {}; // We want to inherit from this class.
 
@@ -259,9 +259,9 @@ class Backup_driver: public Driver
 {
  public:
 
-  Backup_driver(const Table_list &tables):Driver(tables) {};
+  Backup_driver(const Table_list &tables) :Driver(tables) {};
 
-  virtual ~Backup_driver() {}; // Each specific implementation will derive from this class.
+  virtual ~Backup_driver() {}; // We will derive from this class.
 
  /**
    @fn result_t get_data(Buffer &buf)
@@ -284,7 +284,7 @@ class Backup_driver: public Driver
    as described in the documentation of Buffer class. It is possible to complete
    a request without putting any data in the buffer. In that case
    @c buf.size should be set to zero. The return value (OK or READY)
-   and the @c buf.table_no and @c buf.last members are
+   and the @c buf.table_num and @c buf.last members are
    interpreted as usual. However, no data is written to backup archive and such
    empty buffers are not sent back to restore driver.
 
@@ -297,7 +297,7 @@ class Backup_driver: public Driver
                the documentation of Buffer class.
 
    @retval OK  The request is completed - new data is in the buffer and
-               @c size, @c table_no and @c last members of the buffer structure
+               @c size, @c table_num and @c last members of the buffer structure
                are set accordingly.
 
    @retval READY Same as OK and additionally informs that the initial transfer
@@ -322,7 +322,7 @@ class Backup_driver: public Driver
    @note
    If backup kernel calls @c get_data() when there is no more data
    to be sent, the driver should:
-   -# set @c buf.size and @c buf.table_no to 0,
+   -# set @c buf.size and @c buf.table_num to 0,
    -# set @c buf.last to TRUE,
    -# return @c DONE.
 
@@ -465,7 +465,7 @@ class Restore_driver: public Driver
 {
  public:
 
-  Restore_driver(const Table_list &tables):Driver(tables) {};
+  Restore_driver(const Table_list &tables) :Driver(tables) {};
   virtual ~Restore_driver() {};
 
   /**
@@ -475,7 +475,7 @@ class Restore_driver: public Driver
    status of a previously accepted request.
 
    Upon restore, backup kernel calls this method periodically sending
-   consecutive blocks of data from the backup image. The @c table_no
+   consecutive blocks of data from the backup image. The @c table_num
    field in the buffer is set to indicate from which stream the data comes.
    Also, @c buf.last is TRUE if this is the last block
    in the stream.
@@ -496,7 +496,7 @@ class Restore_driver: public Driver
    call to @c get_data() with the same buffer as argument returns OK.
 
    @param  buf   (in) buffer filled with backup data. Fields @c size,
-                 @c table_no and @c last are set
+                 @c table_num and @c last are set
                  accordingly.
 
    @retval OK    The data has been successfully processed - the buffer can be
diff -Nrup a/sql/backup/backup_info.cc b/sql/backup/backup_info.cc
--- a/sql/backup/backup_info.cc	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/backup_info.cc	2008-02-27 21:04:08 +01:00
@@ -2,7 +2,7 @@
   @file
 
   Implementation of @c Backup_info class. Method @c find_backup_engine()
-  implements algorithm for selecting backup engine used to backup/restore
+  implements algorithm for selecting backup engine used to backup
   given table.
  */
 
@@ -39,7 +39,7 @@ storage_engine_ref get_storage_engine(TH
   return se;
 }
 
-/// Determine if a given storage engine has native backup engine.
+/// Determine if a given storage engine has native backup support.
 static
 bool has_native_backup(storage_engine_ref se)
 {
@@ -51,12 +51,10 @@ bool has_native_backup(storage_engine_re
 /**
   Find backup engine which can backup data of a given table.
 
-  @param[in] tbl  Table_ref describing the table
+  @param[in] tbl  the table to be backed-up
 
   @returns pointer to a Snapshot_info instance representing 
   snapshot to which the given table can be added. 
-
-  @todo Add error messages.
  */
 backup::Snapshot_info* 
 Backup_info::find_backup_engine(const backup::Table_ref &tbl)
@@ -74,7 +72,7 @@ Backup_info::find_backup_engine(const ba
   
   if (!se)
   {
-    m_ctx.fatal_error(ER_NO_STORAGE_ENGINE,tbl.describe(buf));
+    m_ctx.fatal_error(ER_NO_STORAGE_ENGINE, tbl.describe(buf));
     DBUG_RETURN(NULL);
   }
   
@@ -83,24 +81,28 @@ Backup_info::find_backup_engine(const ba
   if (!snap)
     if (has_native_backup(se))
     {
-      Native_snapshot *nsnap= new Native_snapshot(m_ctx,se);
+      Native_snapshot *nsnap= new Native_snapshot(m_ctx, se);
       DBUG_ASSERT(nsnap);
       snapshots.push_front(nsnap);
-      native_snapshots.insert(se,nsnap);
+      native_snapshots.insert(se, nsnap);
 
       /*
         Question: Can native snapshot for a given storage engine not accept
         a table using that engine? If yes, then what to do in that case - error 
         or try other (default) snapshots?
        */     
-      DBUG_ASSERT(nsnap->accept(tbl,se));
+      DBUG_ASSERT(nsnap->accept(tbl, se));
       snap= nsnap;
     }
   
   /* 
     If we couldn't locate native snapshot for that table - iterate over
     all existing snapshots and see if one of them can accept the table.
-    At the end, the snapshots using default backup engines will be tried.
+    
+    The order on the snapshots list determines the preferred backup method 
+    for a table. The snapshots for the built-in backup engines are always 
+    present at the end of this list so that they can be selected as a last
+    resort.
   */
     
   if (!snap)
@@ -108,7 +110,7 @@ Backup_info::find_backup_engine(const ba
     List_iterator<Snapshot_info> it(snapshots);
     
     while ((snap= it++))
-      if (snap->accept(tbl,se))
+      if (snap->accept(tbl, se))
         break;
   }
 
@@ -128,12 +130,11 @@ Backup_info::find_backup_engine(const ba
   Create @c Backup_info instance and prepare it for populating with objects.
  
   Snapshots created by the built-in backup engines are added to @c snapshots
-  list to be used in the backup engine selection algoritm in 
+  list to be used in the backup engine selection algorithm in 
   @c find_backup_engine().
  */
-Backup_info::Backup_info(Backup_restore_ctx &ctx):
-  m_state(ERROR), m_ctx(ctx), 
-  native_snapshots(8)
+Backup_info::Backup_info(Backup_restore_ctx &ctx)
+  :m_state(ERROR), m_ctx(ctx), native_snapshots(8)
 {
   using namespace backup;
 
@@ -141,8 +142,12 @@ Backup_info::Backup_info(Backup_restore_
 
   bzero(m_snap, sizeof(m_snap));
 
-  // create default and CS snapshot objects - order is important!
-  
+  /* 
+    Create default and CS snapshot objects and add them to the snapshots list.
+    Note that the default snapshot should be the last element on that list, as a
+    "catch all" entry. 
+   */
+
   snap= new CS_snapshot(m_ctx); // reports errors
 
   if (!snap || !snap->is_valid())
@@ -192,8 +197,8 @@ int Backup_info::close()
 
   // report backup drivers used in the image
   
-  for (uint no=0; no < snap_count(); ++no)
-    m_ctx.report_driver(m_snap[no]->name());
+  for (ushort n=0; n < snap_count(); ++n)
+    m_ctx.report_driver(m_snap[n]->name());
   
   m_state= CLOSED;
   return 0;
@@ -202,8 +207,12 @@ int Backup_info::close()
 /**
   Select database object for backup.
   
-  The object is added to the backup image's catalogue. A pointer to the
-  servers obj::Obj instance is saved for later usage.
+  The object is added to the backup catalogue as an instance of 
+  @c Image_info::Db class. A pointer to the obj::Obj instance is saved there for
+  later usage.
+  
+  @returns Pointer to the @c Image_info::Db instance or NULL if database could
+  not be added.
  */ 
 backup::Image_info::Db* Backup_info::add_db(obs::Obj *obj)
 {
@@ -220,12 +229,14 @@ backup::Image_info::Db* Backup_info::add
 }
 
 /**
-  Select given databases for restore.
+  Select given databases for backup.
+
+  @param[in]  list of databases to be backed-up
 
   For each database, all objects stored in that database are also added to
   the image.
 
-  @todo Report errors.
+  @returns 0 on success, error code otherwise.
  */
 int Backup_info::add_dbs(List< ::LEX_STRING > &dbs)
 {
@@ -280,7 +291,7 @@ int Backup_info::add_dbs(List< ::LEX_STR
 
   if (!unknown_dbs.is_empty())
   {
-    m_ctx.fatal_error(ER_BAD_DB_ERROR,unknown_dbs.c_ptr());
+    m_ctx.fatal_error(ER_BAD_DB_ERROR, unknown_dbs.c_ptr());
     goto error;
   }
 
@@ -298,7 +309,7 @@ int Backup_info::add_dbs(List< ::LEX_STR
   For each database, all objects stored in that database are also added to
   the image. The internal databases are skipped.
 
-  @todo Report errors.
+  @returns 0 on success, error code otherwise.
 */
 int Backup_info::add_all_dbs()
 {
@@ -320,7 +331,8 @@ int Backup_info::add_all_dbs()
     // skip internal databases
     if (is_internal_db_name(obj->get_name()))
     {
-      DBUG_PRINT("backup",(" Skipping internal database %s",obj->get_name()->ptr()));
+      DBUG_PRINT("backup",(" Skipping internal database %s", 
+                           obj->get_name()->ptr()));
       delete obj;
       continue;
     }
@@ -358,22 +370,18 @@ int Backup_info::add_all_dbs()
 
 /**
   Add to image all objects belonging to a given database.
+
+  @returns 0 on success, error code otherwise.
  */
 int Backup_info::add_db_items(Db &db)
 {
   using namespace obs;
 
-  ObjIterator *it= get_db_tables(m_ctx.m_thd,&db.name()); 
-
-  /*
-    If error debugging is switched on (see debug.h) then I_S.TABLES access
-    error will be triggered when backing up database whose name starts with 'a'.
-   */
-  TEST_ERROR_IF(db.name().ptr()[0]=='a');
+  ObjIterator *it= get_db_tables(m_ctx.m_thd, &db.name()); 
 
-  if (!it || TEST_ERROR)
+  if (!it)
   {
-    m_ctx.fatal_error(ER_BACKUP_LIST_DB_TABLES,db.name().ptr());
+    m_ctx.fatal_error(ER_BACKUP_LIST_DB_TABLES, db.name().ptr());
     return ERROR;
   }
   
@@ -389,7 +397,7 @@ int Backup_info::add_db_items(Db &db)
       add_table() method selects/creates a snapshot to which this table is added.
       The backup engine is choosen in Backup_info::find_backup_engine() method.
     */
-    Table *tbl= add_table(db,obj); // reports errors
+    Table *tbl= add_table(db, obj); // reports errors
 
     if (!tbl)
     {
@@ -426,7 +434,7 @@ class Tbl: public backup::Table_ref
 {
  public:
 
-   Tbl(obs::Obj *obj): backup::Table_ref(*obj->get_db_name(),*obj->get_name())
+   Tbl(obs::Obj *obj) :backup::Table_ref(*obj->get_db_name(), *obj->get_name())
    {}
 
    ~Tbl()
@@ -438,13 +446,18 @@ class Tbl: public backup::Table_ref
 /**
   Select table object for backup.
 
-  The object is added to the backup image's catalogue. A pointer to the
-  servers obj::Obj instance is saved for later usage. This method picks 
-  the best available backup engine for the table using @c find_backup_engine() 
-  method.
+  @param[in]  dbi   database to which the table belongs
+  @param[in]  obj   table object
+
+  The object is added to the backup image's catalogue as an instance of
+  @c Image_info::Table class. A pointer to the obj::Obj instance is saved for 
+  later usage. This method picks the best available backup engine for the table 
+  using @c find_backup_engine() method.
 
   @todo Correctly handle temporary tables.
-  @todo Implement error debug code.
+
+  @returns Pointer to the @c Image_info::Table class instance or NULL if table
+  could not be added.
 */
 backup::Image_info::Table* Backup_info::add_table(Db &dbi, obs::Obj *obj)
 {
@@ -455,13 +468,6 @@ backup::Image_info::Table* Backup_info::
   Tbl t(obj);
   // TODO: skip table if it is a tmp one
   
-  /*
-    TODO:
-    If error debugging is switched on (see debug.h) then any table whose
-    name starts with 'b' will trigger error when added to backup image.
-    TEST_ERROR_IF(t.name().ptr()[0]=='b');
-   */
-
   backup::Snapshot_info *snap= find_backup_engine(t); // reports errors
 
   if (!snap)
@@ -479,6 +485,6 @@ backup::Image_info::Table* Backup_info::
   tbl->m_obj_ptr= obj;
 
   DBUG_PRINT("backup",(" table %s backed-up with %s engine (snapshot %d)",
-                      t.name().ptr(), snap->name(), snap->m_no));
+                      t.name().ptr(), snap->name(), snap->m_num));
   return tbl;
 }
diff -Nrup a/sql/backup/backup_info.h b/sql/backup/backup_info.h
--- a/sql/backup/backup_info.h	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/backup_info.h	2008-02-27 21:04:08 +01:00
@@ -10,9 +10,10 @@ namespace backup {
 
 class Native_snapshot;
 class Logger;
-class OStream;
+class Output_stream;
 
-int write_table_data(THD*, backup::Logger&, Backup_info&, backup::OStream&);
+int write_table_data(THD*, backup::Logger&, Backup_info&, 
+                     backup::Output_stream&);
 
 } // backup namespace
 
@@ -21,11 +22,10 @@ int write_table_data(THD*, backup::Logge
   to backup.
 
   A pointer to empty @c Backup_info instance is returned by 
-  @c Backup_restore_ctx::prepare_for_backup() method.
-  Methods @c add_dbs() or @c add_all_dbs() can be used to select which databases
-  should be backed up. When this is done, the @c Backup_info object should be
-  "closed" with @c close() method. Only then it is ready to be used in a backup
-  operation.
+  @c Backup_restore_ctx::prepare_for_backup() method. Methods @c add_dbs() or 
+  @c add_all_dbs() can be used to select which databases should be backed up. 
+  When this is done, the @c Backup_info object should be "closed" with 
+  @c close() method. Only then we are ready for backup operation.
 */
 class Backup_info: public backup::Image_info
 {
@@ -71,12 +71,12 @@ class Backup_info: public backup::Image_
     Given reference to a storage engine, a corresponding native snapshot object
     can be quickly located if it was already created. 
    */ 
-  Map<storage_engine_ref,backup::Native_snapshot > native_snapshots;
+  Map<storage_engine_ref, backup::Native_snapshot > native_snapshots;
 
-  String serialization_buf; ///< Used to store serialization strings of backed-up objects.
+  String serialization_buf; ///< Used to store serialization strings of objects.
   
   friend int backup::write_table_data(THD*, backup::Logger&, Backup_info&, 
-                                      backup::OStream&);
+                                      backup::Output_stream&);
   // Needs access to serialization_buf
   friend int ::bcat_get_item_create_query(st_bstream_image_header *catalogue,
                                struct st_bstream_item_info *item,
diff -Nrup a/sql/backup/backup_kernel.h b/sql/backup/backup_kernel.h
--- a/sql/backup/backup_kernel.h	2008-02-19 18:00:37 +01:00
+++ b/sql/backup/backup_kernel.h	2008-02-27 21:04:08 +01:00
@@ -42,8 +42,8 @@ class Mem_allocator;
 class Stream;
 class Native_snapshot;
 
-int write_table_data(THD*, Logger&, Backup_info&, OStream&);
-int restore_table_data(THD*, Logger&, Restore_info&, IStream&);
+int write_table_data(THD*, Logger&, Backup_info&, Output_stream&);
+int restore_table_data(THD*, Logger&, Restore_info&, Input_stream&);
 
 }
 
@@ -76,7 +76,8 @@ class Backup_restore_ctx: public backup:
 
  private:
 
-  static bool is_running; ///< Indicates if a backup/restore operation is in progress.
+  /** Indicates if a backup/restore operation is in progress. */
+  static bool is_running;
   static pthread_mutex_t  run_lock; ///< To guard @c is_running flag.
 
   /** 
@@ -96,11 +97,16 @@ class Backup_restore_ctx: public backup:
    */ 
   int m_error;
   
-  const char *m_path;   ///< Path to the file where backup image is located.
-  bool m_remove_loc;    ///< If true, the backup image file is deleted at clean-up time.
-  backup::Stream *m_stream; ///< Pointer to the backup stream object if it is opened.
+  const char *m_path;   ///< Path to where the backup image file is located.
+
+  /** If true, the backup image file is deleted at clean-up time. */
+  bool m_remove_loc;
+
+  backup::Stream *m_stream; ///< Pointer to the backup stream object, if opened.
   backup::Image_info *m_catalog;  ///< Pointer to the image catalogue object.
-  static backup::Mem_allocator *mem_alloc; ///< Memory allocator for backup stream library.
+
+  /** Memory allocator for backup stream library. */
+  static backup::Mem_allocator *mem_alloc;
 
   int prepare(LEX_STRING location);
   void disable_fkey_constraints();
diff -Nrup a/sql/backup/backup_test.cc b/sql/backup/backup_test.cc
--- a/sql/backup/backup_test.cc	2008-01-15 00:44:12 +01:00
+++ b/sql/backup/backup_test.cc	2008-02-27 21:04:09 +01:00
@@ -39,10 +39,10 @@ int execute_backup_test_command(THD *thd
   /*
     Send field list.
   */
-  field_list.push_back(i= new Item_empty_string("db",2));
-  field_list.push_back(new Item_empty_string("name",5));
-  field_list.push_back(new Item_empty_string("type",4));
-  field_list.push_back(new Item_empty_string("serialization",13));
+  field_list.push_back(i= new Item_empty_string("db", 2));
+  field_list.push_back(new Item_empty_string("name", 5));
+  field_list.push_back(new Item_empty_string("type", 4));
+  field_list.push_back(new Item_empty_string("serialization", 13));
   protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
 
   obs::ObjIterator *it= obs::get_databases(thd);
@@ -63,7 +63,7 @@ int execute_backup_test_command(THD *thd
       // List tables..
       //
 
-      obs::ObjIterator *tit= obs::get_db_tables(thd,db->get_name());
+      obs::ObjIterator *tit= obs::get_db_tables(thd, db->get_name());
 
       if (tit)
       {
@@ -76,7 +76,7 @@ int execute_backup_test_command(THD *thd
           protocol->prepare_for_resend();
           protocol->store(const_cast<String*>(db->get_name()));
           protocol->store(const_cast<String*>(table->get_name()));
-          protocol->store("TABLE",5,system_charset_info);
+          protocol->store("TABLE", 5, system_charset_info);
           table->serialize(thd, &serial);
           protocol->store(&serial);
           protocol->write();
@@ -89,7 +89,7 @@ int execute_backup_test_command(THD *thd
       // List views.
       //
 
-      tit= obs::get_db_views(thd,db->get_name());
+      tit= obs::get_db_views(thd, db->get_name());
 
       if (tit)
       {
@@ -102,7 +102,7 @@ int execute_backup_test_command(THD *thd
           protocol->prepare_for_resend();
           protocol->store(const_cast<String*>(db->get_name()));
           protocol->store(const_cast<String*>(table->get_name()));
-          protocol->store("VIEW",5,system_charset_info);
+          protocol->store("VIEW", 5, system_charset_info);
           table->serialize(thd, &serial);
           protocol->store(&serial);
           protocol->write();
diff -Nrup a/sql/backup/be_default.cc b/sql/backup/be_default.cc
--- a/sql/backup/be_default.cc	2008-02-19 18:00:37 +01:00
+++ b/sql/backup/be_default.cc	2008-02-27 21:04:09 +01:00
@@ -109,8 +109,8 @@ result_t Engine::get_backup(const uint32
   DBUG_RETURN(OK);
 }
 
-Backup::Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type): 
-               Backup_thread_driver(tables)
+Backup::Backup(const Table_list &tables, THD *t_thd, thr_lock_type lock_type)
+  :Backup_thread_driver(tables)
 {
   DBUG_PRINT("default_backup",("Creating backup driver"));
   locking_thd->m_thd= t_thd;  /* save current thread */
@@ -290,7 +290,7 @@ result_t Backup::get_data(Buffer &buf)
   if (!locks_acquired)
   {
     buf.size= 0;
-    buf.table_no= 0; 
+    buf.table_num= 0; 
     buf.last= TRUE;
     switch (locking_thd->lock_state) {
     case LOCK_ERROR:             // Something ugly happened in locking
@@ -312,7 +312,7 @@ result_t Backup::get_data(Buffer &buf)
     }
   }
 
-  buf.table_no= tbl_num;
+  buf.table_num= tbl_num;
   buf.last= FALSE;
 
   /* 
@@ -341,14 +341,14 @@ result_t Backup::get_data(Buffer &buf)
     {
       buf.last= TRUE;
       buf.size= 0;
-      buf.table_no= 0;
+      buf.table_num= 0;
       DBUG_RETURN(OK);
     }
     else
     {
       start_tbl_read(cur_table);
       tbl_num++;
-      buf.table_no= tbl_num;
+      buf.table_num= tbl_num;
     }
   }
 
@@ -561,7 +561,7 @@ result_t Engine::get_restore(version_t, 
   DBUG_RETURN(OK);
 }
 
-Restore::Restore(const Table_list &tables, THD *t_thd): Restore_driver(tables)
+Restore::Restore(const Table_list &tables, THD *t_thd) :Restore_driver(tables)
 {
   DBUG_PRINT("default_backup",("Creating restore driver"));
   m_thd= t_thd;         /* save current thread */
@@ -719,7 +719,7 @@ result_t Restore::send_data(Buffer &buf)
 
   DBUG_ENTER("Restore::send_data");
   DBUG_PRINT("default_restore",("Got packet with %lu bytes from stream %u",
-                                (unsigned long)buf.size, buf.table_no));
+                                (unsigned long)buf.size, buf.table_num));
   
   /* 
     Determine mode of operation and execute mode.
@@ -747,7 +747,7 @@ result_t Restore::send_data(Buffer &buf)
       find the table in question. This is needed if any tables (more
       than MAX_RETRIES are empty!
     */
-    if ((tbl_num + 1) == buf.table_no) //do normal sequential lookup
+    if ((tbl_num + 1) == buf.table_num) //do normal sequential lookup
       res= next_table();
     else                                //do linear search
     {
@@ -760,14 +760,14 @@ result_t Restore::send_data(Buffer &buf)
         i++;
         res= next_table();
       }
-      while ((i != buf.table_no) && !res);
+      while ((i != buf.table_num) && !res);
       tbl_num= i - 1;
     }
     if (res)
     {
       buf.last= TRUE;
       buf.size= 0;
-      buf.table_no= 0;
+      buf.table_num= 0;
       DBUG_RETURN(OK);
     }
     else
@@ -790,7 +790,7 @@ result_t Restore::send_data(Buffer &buf)
       receiving data from the backup for a different table. Set the mode to
       get the next table in the list.
     */
-    if (tbl_num != buf.table_no)
+    if (tbl_num != buf.table_num)
     {
       mode= GET_NEXT_TABLE;
       DBUG_RETURN(PROCESSING);
diff -Nrup a/sql/backup/be_default.h b/sql/backup/be_default.h
--- a/sql/backup/be_default.h	2008-02-19 18:00:37 +01:00
+++ b/sql/backup/be_default.h	2008-02-27 21:04:09 +01:00
@@ -211,9 +211,9 @@ class Default_snapshot: public Snapshot_
 {
  public:
 
-  Default_snapshot(Logger&): Snapshot_info(1) // current version no is 1
+  Default_snapshot(Logger&) :Snapshot_info(1) // current version number is 1
   {}
-  Default_snapshot(Logger&, const version_t ver): Snapshot_info(ver)
+  Default_snapshot(Logger&, const version_t ver) :Snapshot_info(ver)
   {}
 
   enum_snap_type type() const
@@ -226,11 +226,11 @@ class Default_snapshot: public Snapshot_
   { return TRUE; }; // accept all tables
 
   result_t get_backup_driver(Backup_driver* &ptr)
-  { return (ptr= new default_backup::Backup(m_tables,::current_thd,
+  { return (ptr= new default_backup::Backup(m_tables, ::current_thd,
                                             TL_READ_NO_INSERT)) ? OK : ERROR; }
 
   result_t get_restore_driver(Restore_driver* &ptr)
-  { return (ptr= new default_backup::Restore(m_tables,::current_thd)) ? OK : ERROR; }
+  { return (ptr= new default_backup::Restore(m_tables, ::current_thd)) ? OK : ERROR; }
 
   bool is_valid(){ return TRUE; };
 
diff -Nrup a/sql/backup/be_native.h b/sql/backup/be_native.h
--- a/sql/backup/be_native.h	2008-02-19 18:00:37 +01:00
+++ b/sql/backup/be_native.h	2008-02-27 21:04:09 +01:00
@@ -19,16 +19,16 @@ class Native_snapshot: public Snapshot_i
 
  public:
 
-  Native_snapshot(Logger &log, const storage_engine_ref se): 
-    Snapshot_info(0), m_hton(NULL), m_be(NULL)
+  Native_snapshot(Logger &log, const storage_engine_ref se) 
+    :Snapshot_info(0), m_hton(NULL), m_be(NULL)
   {
     init(log, se);
     if (m_be)
       m_version= m_be->version();
   }
   
-  Native_snapshot(Logger &log, const version_t ver, const storage_engine_ref se): 
-    Snapshot_info(ver), m_hton(NULL), m_be(NULL)
+  Native_snapshot(Logger &log, const version_t ver, const storage_engine_ref se) 
+    :Snapshot_info(ver), m_hton(NULL), m_be(NULL)
   {
     init(log, se);
   }
@@ -63,13 +63,13 @@ class Native_snapshot: public Snapshot_i
   result_t get_backup_driver(Backup_driver* &drv)
   {
     DBUG_ASSERT(m_be);
-    return m_be->get_backup(Driver::PARTIAL,m_tables,drv);
+    return m_be->get_backup(Driver::PARTIAL, m_tables, drv);
   }
 
   result_t get_restore_driver(Restore_driver* &drv)
   {
     DBUG_ASSERT(m_be);
-    return m_be->get_restore(m_version,Driver::PARTIAL,m_tables,drv);
+    return m_be->get_restore(m_version, Driver::PARTIAL, m_tables, drv);
   }
 
  private:
@@ -97,7 +97,7 @@ int Native_snapshot::init(Logger &log, c
     if (m_be)
       m_be->free();
     m_be= NULL;
-    log.report_error(ER_BACKUP_CREATE_BE,m_name);
+    log.report_error(ER_BACKUP_CREATE_BE, m_name);
     return 1;
   }
   
diff -Nrup a/sql/backup/be_snapshot.h b/sql/backup/be_snapshot.h
--- a/sql/backup/be_snapshot.h	2008-02-19 18:00:37 +01:00
+++ b/sql/backup/be_snapshot.h	2008-02-27 21:04:09 +01:00
@@ -58,8 +58,8 @@ class Engine: public Backup_engine
 class Backup: public default_backup::Backup
 {
   public:
-    Backup(const Table_list &tables, THD *t_thd): 
-      default_backup::Backup(tables, t_thd, TL_READ) { tables_open= FALSE; };
+    Backup(const Table_list &tables, THD *t_thd) 
+      :default_backup::Backup(tables, t_thd, TL_READ) { tables_open= FALSE; };
     virtual ~Backup()
     {
       if (locking_thd->lock_state == LOCK_ACQUIRED)
@@ -93,8 +93,8 @@ class Backup: public default_backup::Bac
 class Restore: public default_backup::Restore
 {
   public:
-    Restore(const Table_list &tables, THD *t_thd):
-      default_backup::Restore(tables, t_thd){};
+    Restore(const Table_list &tables, THD *t_thd)
+      :default_backup::Restore(tables, t_thd){};
     virtual ~Restore(){};
     void free() { delete this; };
 };
@@ -114,9 +114,9 @@ class CS_snapshot: public Snapshot_info
 {
  public:
 
-  CS_snapshot(Logger&): Snapshot_info(1) // current version no is 1
+  CS_snapshot(Logger&) :Snapshot_info(1) // current version number is 1
   {}
-  CS_snapshot(Logger&, version_t ver): Snapshot_info(ver)
+  CS_snapshot(Logger&, version_t ver) :Snapshot_info(ver)
   {}
 
   enum_snap_type type() const
@@ -133,10 +133,10 @@ class CS_snapshot: public Snapshot_info
   }; // accept all tables that support consistent read
 
   result_t get_backup_driver(Backup_driver* &ptr)
-  { return (ptr= new snapshot_backup::Backup(m_tables,::current_thd)) ? OK : ERROR; }
+  { return (ptr= new snapshot_backup::Backup(m_tables, ::current_thd)) ? OK : ERROR; }
 
   result_t get_restore_driver(Restore_driver* &ptr)
-  { return (ptr= new snapshot_backup::Restore(m_tables,::current_thd)) ? OK : ERROR; }
+  { return (ptr= new snapshot_backup::Restore(m_tables, ::current_thd)) ? OK : ERROR; }
 
   bool is_valid(){ return TRUE; };
 
diff -Nrup a/sql/backup/be_thread.h b/sql/backup/be_thread.h
--- a/sql/backup/be_thread.h	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/be_thread.h	2008-02-27 21:04:09 +01:00
@@ -79,8 +79,8 @@ class Backup_thread_driver : public Back
 {
 public:
 
-  Backup_thread_driver(const backup::Table_list &tables):
-    Backup_driver(tables) { locking_thd = new Locking_thread_st(); }
+  Backup_thread_driver(const backup::Table_list &tables)
+    :Backup_driver(tables) { locking_thd = new Locking_thread_st(); }
   ~Backup_thread_driver() { delete locking_thd; }
 
   Locking_thread_st *locking_thd;
diff -Nrup a/sql/backup/data_backup.cc b/sql/backup/data_backup.cc
--- a/sql/backup/data_backup.cc	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/data_backup.cc	2008-02-27 21:04:09 +01:00
@@ -97,16 +97,16 @@ class Block_writer
   result_t  write_buf(const Buffer&);
   result_t  drop_buf(Buffer&);
 
-  Block_writer(byte, size_t, OStream&);
+  Block_writer(byte, size_t, Output_stream&);
   ~Block_writer();
 
  private:
 
-  byte     snap_no;   ///< snapshot to which the data belongs
-  OStream  &m_str;    ///< stream to which we write
-  size_t   buf_size;  ///< size of a single data block
-  byte     *data_buf; ///< pointer to data buffer
-  bool     taken;     ///< flag which indicates that the buffer is in use
+  byte           snap_num;  ///< snapshot to which the data belongs
+  Output_stream  &m_str;    ///< stream to which we write
+  size_t         buf_size;  ///< size of a single data block
+  byte           *data_buf; ///< pointer to data buffer
+  bool           taken;     ///< flag which indicates that the buffer is in use
 
   friend class Backup_pump;
 };
@@ -134,7 +134,8 @@ class Backup_pump
          WRITING  ///< Pump sends data to the stream.
        } mode;
 
-  size_t  init_size;  ///< The estimate returned by backup driver's @c init_data() method.
+  /** The estimate returned by backup driver's @c init_data() method. */
+  size_t  init_size;
   size_t  bytes_in, bytes_out;
 
   const char *m_name; ///< Name of the driver (for debug purposes).
@@ -166,8 +167,9 @@ class Backup_pump
 
  private:
 
-  static const uint get_buf_retries= 3; /**< if block writer has no buffers, retry
-                                              this many times before giving up */
+  /// If block writer has no buffers, retry this many times before giving up.
+  static const uint get_buf_retries= 3; 
+
   Logger        *m_log;   ///< Used to report errors if not NULL.
   Backup_driver *m_drv;   ///< Pointer to the backup driver.
   Block_writer  &m_bw;    ///< Block writer used for writing data blocks.
@@ -176,20 +178,22 @@ class Backup_pump
   /**
     Pointer to the memory area used as write buffer.
 
-    If m_buf_head is NULL and we are in READ state, then we should allocate new write
-    buffer and ask driver to fill it with data. M_buf_head is not NULL only when the
-    write buffer is being filled with data but the operation is not complete.
+    If m_buf_head is NULL and we are in READ state, then we should allocate new 
+    write buffer and ask driver to fill it with data. M_buf_head is not NULL 
+    only when the write buffer is being filled with data but the operation is 
+    not complete.
    */
   byte          *m_buf_head;
 
-  uint          m_buf_retries; ///< how many times failed to get a buffer from block writer
+  /// How many times failed to get a buffer from block writer.
+  uint          m_buf_retries;
 
   /// Bitmap showing which streams have been closed by the driver.
   MY_BITMAP     m_closed_streams;
 
-  void mark_stream_closed(uint stream_no)
+  void mark_stream_closed(uint stream_num)
   {
-    bitmap_set_bit(&m_closed_streams, stream_no);
+    bitmap_set_bit(&m_closed_streams, stream_num);
   }
 
   bool all_streams_closed()
@@ -243,11 +247,11 @@ class Scheduler
   size_t m_total;       ///< accumulated position of all drivers
   size_t m_init_left;   ///< how much of init data is left (estimate)
   uint   m_known_count; ///< no. drivers which can estimate init data size
-  OStream &m_str;       ///< stream to which we write
-  bool   cancelled;      ///< true if backup process was cancelled
+  Output_stream &m_str; ///< stream to which we write
+  bool   cancelled;     ///< true if backup process was cancelled
 
-  Scheduler(OStream &s, Logger *log):
-    init_count(0), prepare_count(0), finish_count(0),
+  Scheduler(Output_stream &s, Logger *log)
+    :init_count(0), prepare_count(0), finish_count(0),
     m_pumps(NULL), m_last(NULL), m_log(log),
     m_count(0), m_total(0), m_init_left(0), m_known_count(0),
     m_str(s), cancelled(FALSE)
@@ -257,7 +261,7 @@ class Scheduler
   void remove_pump(Pump_iterator&);
   void cancel_backup();
 
-  friend int write_table_data(THD*, Logger&, Backup_info&, OStream&);
+  friend int write_table_data(THD*, Logger&, Backup_info&, Output_stream&);
   friend class Pump_iterator;
 };
 
@@ -275,11 +279,11 @@ class Scheduler::Pump: public Backup_pum
  public:
 
   // FIXME: how to react if the buffer could not be allocated?
-  Pump(Snapshot_info &snap, OStream &s):
-    Backup_pump(snap,bw), start_pos(0),
-    bw(snap.m_no-1,DATA_BUFFER_SIZE,s)
+  Pump(Snapshot_info &snap, Output_stream &s)
+    :Backup_pump(snap, bw), start_pos(0),
+    bw(snap.m_num - 1, DATA_BUFFER_SIZE, s)
   {
-    DBUG_ASSERT(snap.m_no > 0);
+    DBUG_ASSERT(snap.m_num > 0);
   }
 
   size_t pos() const
@@ -329,9 +333,11 @@ int get_default_snapshot_tables(backup::
   }
   else
     if (backup_drv)
-     (*tables_last)->next_global= ((default_backup::Backup *)backup_drv)->get_table_list();
+     (*tables_last)->next_global=
+                      ((default_backup::Backup *)backup_drv)->get_table_list();
     else if (restore_drv)
-     (*tables_last)->next_global= ((default_backup::Restore *)restore_drv)->get_table_list();
+     (*tables_last)->next_global=
+                    ((default_backup::Restore *)restore_drv)->get_table_list();
     else
       DBUG_RETURN(ERROR);
   DBUG_RETURN(0);
@@ -464,30 +470,33 @@ int unblock_commits(THD *thd)
 
   @returns 0 on success.
  */
-int write_table_data(THD* thd, Logger &log, Backup_info &info, OStream &s)
+int write_table_data(THD* thd, Logger &log, Backup_info &info, Output_stream &s)
 {
   DBUG_ENTER("backup::write_table_data");
 
-  if (info.snap_count()==0 || info.table_count()==0) // nothing to backup
+  if (info.snap_count() == 0 || info.table_count() == 0) // nothing to backup
     DBUG_RETURN(0);
 
-  Scheduler   sch(s,&log);          // scheduler instance
+  Scheduler   sch(s, &log);          // scheduler instance
   List<Scheduler::Pump>  inactive;  // list of images not yet being created
-  size_t      max_init_size=0;      // keeps maximal init size for images in inactive list
+
+  // keeps maximal init size for images in inactive list
+  size_t      max_init_size=0;
+
   time_t      vp_time;              // to store validity point time
 
   DBUG_PRINT("backup_data",("initializing scheduler"));
 
   // add unknown "at end" drivers to scheduler, rest to inactive list
 
-  for (uint no=0; no < 256; ++no)
+  for (uint n=0; n < 256; ++n)
   {
-    Snapshot_info *i= info.m_snap[no];
+    Snapshot_info *i= info.m_snap[n];
 
     if (!i)
       continue;
 
-    Scheduler::Pump *p= new Scheduler::Pump(*i,s);
+    Scheduler::Pump *p= new Scheduler::Pump(*i, s);
 
     if (!p || !p->is_valid())
     {
@@ -661,7 +670,7 @@ int write_table_data(THD* thd, Logger &l
     log.report_state(BUP_RUNNING);
     BACKUP_BREAKPOINT("bp_running_state");
 
-    /**** VP creation (done) ********************************************/
+    /**** VP creation (end) ********************************************/
 
     // get final data from drivers
     DBUG_PRINT("backup_data",("-- FINISH PHASE --"));
@@ -721,7 +730,7 @@ class Scheduler::Pump_iterator
   Pump_iterator(): el(NULL)
   {}
 
-  Pump_iterator(const Scheduler &sch): el(sch.m_pumps)
+  Pump_iterator(const Scheduler &sch) :el(sch.m_pumps)
   {}
 
 };
@@ -754,7 +763,7 @@ int Scheduler::step()
 
   move_pump_to_end(p);
 
-  DBUG_PRINT("backup_data",("polling %s",p->m_name));
+  DBUG_PRINT("backup_data",("polling %s", p->m_name));
 
   backup_state::value before_state= p->state;
 
@@ -783,17 +792,17 @@ int Scheduler::step()
     switch (before_state) {
 
     case backup_state::INIT:
-      if (init_count>0)
+      if (init_count > 0)
         init_count--;
       break;
 
     case backup_state::PREPARING:
-      if (prepare_count>0)
+      if (prepare_count > 0)
         prepare_count--;
       break;
 
     case backup_state::FINISHING:
-      if (finish_count>0)
+      if (finish_count > 0)
         finish_count--;
       break;
 
@@ -857,7 +866,7 @@ int Scheduler::add(Pump *p)
   DBUG_PRINT("backup_data",("Adding %s to scheduler (at pos %lu)",
                             p->m_name, (unsigned long)avg));
 
-  m_pumps= list_cons(p,m_pumps);
+  m_pumps= list_cons(p, m_pumps);
   if (!m_last)
     m_last= m_pumps;
 
@@ -889,7 +898,8 @@ int Scheduler::add(Pump *p)
 
   DBUG_PRINT("backup_data",("driver counts: total=%u, init=%u, prepare=%u, finish=%u.",
                             m_count, init_count, prepare_count, finish_count));
-  DBUG_PRINT("backup_data",("total init data size estimate: %lu",(unsigned long)m_init_left));
+  DBUG_PRINT("backup_data",("total init data size estimate: %lu",
+                            (unsigned long)m_init_left));
 
   return 0;
 
@@ -907,7 +917,7 @@ void Scheduler::move_pump_to_end(const P
   DBUG_ASSERT(m_pumps);
   if (m_last != p.el)
   {
-    m_pumps= list_delete(m_pumps,p.el);
+    m_pumps= list_delete(m_pumps, p.el);
     m_last->next= p.el;
     p.el->prev= m_last;
     p.el->next= NULL;
@@ -929,7 +939,7 @@ void Scheduler::remove_pump(Pump_iterato
 
   if (m_pumps)
   {
-    m_pumps= list_delete(m_pumps,p.el);
+    m_pumps= list_delete(m_pumps, p.el);
     m_count--;
   }
 
@@ -937,7 +947,7 @@ void Scheduler::remove_pump(Pump_iterato
   {
     // destructor calls driver's free() method
     delete static_cast<Pump*>(p.el->data);
-    my_free(p.el,MYF(0));
+    my_free(p.el, MYF(0));
   }
 }
 
@@ -964,7 +974,7 @@ int Scheduler::prepare()
 {
   DBUG_ASSERT(!cancelled);
   // we should start prepare phase only when init phase is finished
-  DBUG_ASSERT(init_count==0);
+  DBUG_ASSERT(init_count == 0);
   DBUG_PRINT("backup_data",("calling prepare() for all drivers"));
 
   for (Pump_iterator it(*this); it; ++it)
@@ -988,7 +998,7 @@ int Scheduler::lock()
 {
   DBUG_ASSERT(!cancelled);
   // lock only when init and prepare phases are finished
-  DBUG_ASSERT(init_count==0 && prepare_count==0);
+  DBUG_ASSERT(init_count == 0 && prepare_count == 0);
   DBUG_PRINT("backup_data",("calling lock() for all drivers"));
 
   for (Pump_iterator it(*this); it; ++it)
@@ -1030,17 +1040,17 @@ int Scheduler::unlock()
 
  **************************************************/
 
-Backup_pump::Backup_pump(Snapshot_info &snap, Block_writer &bw):
-  state(backup_state::INACTIVE), mode(READING),
+Backup_pump::Backup_pump(Snapshot_info &snap, Block_writer &bw)
+  :state(backup_state::INACTIVE), mode(READING),
   init_size(0), bytes_in(0), bytes_out(0),
   m_drv(NULL), m_bw(bw), m_buf_head(NULL),
   m_buf_retries(0)
 {
-  DBUG_ASSERT(snap.m_no > 0);
+  DBUG_ASSERT(snap.m_num > 0);
   m_buf.data= NULL;
   bitmap_init(&m_closed_streams,
               NULL,
-              1+snap.table_count(),
+              1 + snap.table_count(),
               FALSE); // not thread safe
   m_name= snap.name();
   if (ERROR == snap.get_backup_driver(m_drv) || !m_drv)
@@ -1060,7 +1070,7 @@ Backup_pump::~Backup_pump()
 int Backup_pump::begin()
 {
   state= backup_state::INIT;
-  DBUG_PRINT("backup_data",(" %s enters INIT state",m_name));
+  DBUG_PRINT("backup_data",(" %s enters INIT state", m_name));
 
   if (ERROR == m_drv->begin(m_bw.buf_size))
   {
@@ -1068,7 +1078,7 @@ int Backup_pump::begin()
     // We check if logger is always setup. Later the assertion can
     // be replaced with "if (m_log)"
     DBUG_ASSERT(m_log);
-      m_log->report_error(ER_BACKUP_INIT_BACKUP_DRIVER,m_name);
+      m_log->report_error(ER_BACKUP_INIT_BACKUP_DRIVER, m_name);
     return ERROR;
   }
 
@@ -1080,13 +1090,13 @@ int Backup_pump::end()
 {
   if (state != backup_state::SHUT_DOWN)
   {
-    DBUG_PRINT("backup_data",(" shutting down %s",m_name));
+    DBUG_PRINT("backup_data",(" shutting down %s", m_name));
 
     if (ERROR == m_drv->end())
     {
       state= backup_state::ERROR;
       DBUG_ASSERT(m_log);
-        m_log->report_error(ER_BACKUP_STOP_BACKUP_DRIVER,m_name);
+        m_log->report_error(ER_BACKUP_STOP_BACKUP_DRIVER, m_name);
       return ERROR;
     }
 
@@ -1120,19 +1130,19 @@ int Backup_pump::prepare()
   }
 
   DBUG_PRINT("backup_data",(" preparing %s, goes to %s state",
-                            m_name,backup_state::name[state]));
+                            m_name, backup_state::name[state]));
   return 0;
 }
 
 /// Request VP from the driver.
 int Backup_pump::lock()
 {
-  DBUG_PRINT("backup_data",(" locking %s",m_name));
+  DBUG_PRINT("backup_data",(" locking %s", m_name));
   if (ERROR == m_drv->lock())
   {
     state= backup_state::ERROR;
     DBUG_ASSERT(m_log);
-      m_log->report_error(ER_BACKUP_CREATE_VP,m_name);
+      m_log->report_error(ER_BACKUP_CREATE_VP, m_name);
     return ERROR;
   }
 
@@ -1142,13 +1152,13 @@ int Backup_pump::lock()
 /// Unlock the driver after VP creation.
 int Backup_pump::unlock()
 {
-  DBUG_PRINT("backup_data",(" unlocking %s, goes to FINISHING state",m_name));
+  DBUG_PRINT("backup_data",(" unlocking %s, goes to FINISHING state", m_name));
   state= backup_state::FINISHING;
   if (ERROR == m_drv->unlock())
   {
     state= backup_state::ERROR;
     DBUG_ASSERT(m_log);
-      m_log->report_error(ER_BACKUP_UNLOCK_DRIVER,m_name);
+      m_log->report_error(ER_BACKUP_UNLOCK_DRIVER, m_name);
     return ERROR;
   }
 
@@ -1161,7 +1171,7 @@ int Backup_pump::cancel()
   {
     state= backup_state::ERROR;
     DBUG_ASSERT(m_log);
-      m_log->report_error(ER_BACKUP_CANCEL_BACKUP,m_name);
+      m_log->report_error(ER_BACKUP_CANCEL_BACKUP, m_name);
     return ERROR;
   }
   state= backup_state::CANCELLED;
@@ -1264,17 +1274,17 @@ int Backup_pump::pump(size_t *howmuch)
 
         if (m_buf.last)
         {
-          mark_stream_closed(m_buf.table_no);
+          mark_stream_closed(m_buf.table_num);
           if (all_streams_closed())
-            DBUG_PRINT("backup_data",(" all streams of %s closed",m_name));
+            DBUG_PRINT("backup_data",(" all streams of %s closed", m_name));
           else
-            DBUG_PRINT("backup_data",(" stream %u closed",m_buf.table_no));
+            DBUG_PRINT("backup_data",(" stream %u closed", m_buf.table_num));
         }
 
         m_buf.data= m_buf_head;
         m_buf_head= NULL;
 
-        if ( m_buf.size > 0 )
+        if (m_buf.size > 0)
           mode= WRITING;
         else
           m_bw.drop_buf(m_buf);
@@ -1287,7 +1297,7 @@ int Backup_pump::pump(size_t *howmuch)
       case ERROR:
       default:
         DBUG_ASSERT(m_log);
-          m_log->report_error(ER_BACKUP_GET_DATA,m_name);
+          m_log->report_error(ER_BACKUP_GET_DATA, m_name);
         state= backup_state::ERROR;
         return ERROR;
 
@@ -1312,15 +1322,17 @@ int Backup_pump::pump(size_t *howmuch)
         if (howmuch)
           *howmuch= m_buf.size;
 
-        DBUG_PRINT("backup_data",(" added %lu bytes from %s to archive (drv_no=%u, table_no=%u)",
-                                  (unsigned long)howmuch, m_name, m_bw.snap_no, m_buf.table_no));
+        DBUG_PRINT("backup_data",(" added %lu bytes from %s to archive "
+                                  "(drv_num=%u, table_num=%u)",
+                                  (unsigned long)howmuch, m_name, m_bw.snap_num,
+                                  m_buf.table_num));
         mode= READING;
         break;
 
       case Block_writer::ERROR:
 
         DBUG_ASSERT(m_log);
-          m_log->report_error(ER_BACKUP_WRITE_DATA, m_name, m_buf.table_no);
+          m_log->report_error(ER_BACKUP_WRITE_DATA, m_name, m_buf.table_num);
         state= backup_state::ERROR;
         return ERROR;
 
@@ -1333,8 +1345,8 @@ int Backup_pump::pump(size_t *howmuch)
 
   if (state != before_state)
     DBUG_PRINT("backup_data",(" %s changes state %s->%s",
-                              m_name,backup_state::name[before_state],
-                                     backup_state::name[state]));
+                              m_name, backup_state::name[before_state],
+                                      backup_state::name[state]));
   return 0;
 }
 
@@ -1353,13 +1365,13 @@ namespace backup {
 /**
   Read backup image data from a backup stream and forward it to restore drivers.
  */
-int restore_table_data(THD*, Logger &log, Restore_info &info, IStream &s)
+int restore_table_data(THD*, Logger &log, Restore_info &info, Input_stream &s)
 {
   DBUG_ENTER("restore::restore_table_data");
 
   enum { READING, SENDING, DONE, ERROR } state= READING;
 
-  if (info.snap_count()==0 || info.table_count()==0) // nothing to restore
+  if (info.snap_count() == 0 || info.table_count() == 0) // nothing to restore
     DBUG_RETURN(0);
 
   Restore_driver* drv[256];
@@ -1376,20 +1388,20 @@ int restore_table_data(THD*, Logger &log
   // Create restore drivers
   result_t res;
 
-  for (uint no=0; no < info.snap_count(); ++no)
+  for (uint n=0; n < info.snap_count(); ++n)
   {
-    drv[no]= NULL;
+    drv[n]= NULL;
 
-    Snapshot_info *snap= info.m_snap[no];
+    Snapshot_info *snap= info.m_snap[n];
 
     // note: img can be NULL if it is not used in restore.
     if (!snap)
       continue;
 
-    res= snap->get_restore_driver(drv[no]);
+    res= snap->get_restore_driver(drv[n]);
     if (res == backup::ERROR)
     {
-      log.report_error(ER_BACKUP_CREATE_RESTORE_DRIVER,snap->name());
+      log.report_error(ER_BACKUP_CREATE_RESTORE_DRIVER, snap->name());
       goto error;
     };
     
@@ -1399,7 +1411,7 @@ int restore_table_data(THD*, Logger &log
     */
     if ((snap->type() == Snapshot_info::DEFAULT_SNAPSHOT) ||
         (snap->type() == Snapshot_info::CS_SNAPSHOT))
-      get_default_snapshot_tables(NULL, (default_backup::Restore *)drv[no],
+      get_default_snapshot_tables(NULL, (default_backup::Restore *)drv[n],
                                   &table_list, &table_list_last);
   }
 
@@ -1420,19 +1432,19 @@ int restore_table_data(THD*, Logger &log
   }
 
   // Initialize the drivers.
-  for (uint no=0; no < info.snap_count(); ++no)
+  for (uint n=0; n < info.snap_count(); ++n)
   {
-    res= drv[no]->begin(0);
+    res= drv[n]->begin(0);
     if (res == backup::ERROR)
     {
-      log.report_error(ER_BACKUP_INIT_RESTORE_DRIVER,info.m_snap[no]->name());
+      log.report_error(ER_BACKUP_INIT_RESTORE_DRIVER, info.m_snap[n]->name());
       goto error;
     }
   }
 
   {
     Buffer  buf;
-    uint    snap_no=0;
+    uint    snap_num=0;
     uint    repeats=0, errors= 0;
     int     ret;
 
@@ -1453,7 +1465,7 @@ int restore_table_data(THD*, Logger &log
       case READING:
 
         bzero(&chunk_info, sizeof(chunk_info));
-        ret= bstream_rd_data_chunk(&s,&chunk_info);
+        ret= bstream_rd_data_chunk(&s, &chunk_info);
 
         switch (ret) {
 
@@ -1481,25 +1493,25 @@ int restore_table_data(THD*, Logger &log
         DBUG_ASSERT(chunk_info.data.begin);
         DBUG_ASSERT(chunk_info.data.begin < chunk_info.data.end);
 
-        snap_no= chunk_info.snap_no;
-        buf.table_no= chunk_info.table_no;
+        snap_num= chunk_info.snap_num;
+        buf.table_num= chunk_info.table_num;
         buf.last= chunk_info.flags & BSTREAM_FLAG_LAST_CHUNK;
         buf.data= chunk_info.data.begin;
         buf.size= chunk_info.data.end - chunk_info.data.begin;
 
-        if (snap_no > info.snap_count() || !(drvr= drv[snap_no]))
+        if (snap_num > info.snap_count() || !(drvr= drv[snap_num]))
         {
-          DBUG_PRINT("restore",("Skipping data from snapshot #%u",snap_no));
+          DBUG_PRINT("restore",("Skipping data from snapshot #%u", snap_num));
           state= READING;
           break;
         }
 
-        snap= info.m_snap[snap_no];
+        snap= info.m_snap[snap_num];
         // Each restore driver should have corresponding Image_info object.
         DBUG_ASSERT(snap);
 
         DBUG_PRINT("restore",("Got %lu bytes of %s image data (for table #%u)",
-                   (unsigned long)buf.size, snap->name(), buf.table_no));
+                   (unsigned long)buf.size, snap->name(), buf.table_num));
 
       case SENDING:
 
@@ -1522,7 +1534,7 @@ int restore_table_data(THD*, Logger &log
         case backup::ERROR:
           if( errors > MAX_ERRORS )
           {
-            log.report_error(ER_BACKUP_SEND_DATA, buf.table_no, snap->name());
+            log.report_error(ER_BACKUP_SEND_DATA, buf.table_num, snap->name());
             state= ERROR;
             goto error;
           }
@@ -1550,30 +1562,30 @@ int restore_table_data(THD*, Logger &log
 
     DBUG_PRINT("restore",("End of backup stream"));
     if (state != DONE)
-      DBUG_PRINT("restore",("state is %d",state));
+      DBUG_PRINT("restore",("state is %d", state));
   }
 
   { // Shutting down drivers
 
     String bad_drivers;
 
-    for (uint no=0; no < info.snap_count(); ++no)
+    for (uint n=0; n < info.snap_count(); ++n)
     {
-      if (!drv[no])
+      if (!drv[n])
         continue;
 
       DBUG_PRINT("restore",("Shutting down restore driver %s",
-                            info.m_snap[no]->name()));
-      res= drv[no]->end();
+                            info.m_snap[n]->name()));
+      res= drv[n]->end();
       if (res == backup::ERROR)
       {
         state= ERROR;
 
         if (!bad_drivers.is_empty())
           bad_drivers.append(",");
-        bad_drivers.append(info.m_snap[no]->name());
+        bad_drivers.append(info.m_snap[n]->name());
       }
-      drv[no]->free();
+      drv[n]->free();
     }
 
     if (!bad_drivers.is_empty())
@@ -1592,12 +1604,12 @@ int restore_table_data(THD*, Logger &log
 
   DBUG_PRINT("restore",("Cancelling restore process"));
 
-  for (uint no=0; no < info.snap_count(); ++no)
+  for (uint n=0; n < info.snap_count(); ++n)
   {
-    if (!drv[no])
+    if (!drv[n])
       continue;
 
-    drv[no]->free();
+    drv[n]->free();
   }
 
   DBUG_RETURN(backup::ERROR);
@@ -1615,16 +1627,16 @@ int restore_table_data(THD*, Logger &log
 
 namespace backup {
 
-Block_writer::Block_writer(byte snap_no, size_t size, OStream &s):
-  m_str(s), buf_size(size), taken(FALSE), snap_no(snap_no)
+Block_writer::Block_writer(byte snap_num, size_t size, Output_stream &s)
+  :m_str(s), buf_size(size), taken(FALSE), snap_num(snap_num)
 {
-  data_buf= (byte*)my_malloc(buf_size,MYF(0));
+  data_buf= (byte*)my_malloc(buf_size, MYF(0));
 }
 
 Block_writer::~Block_writer()
 {
   if (data_buf)
-    my_free(data_buf,MYF(0));
+    my_free(data_buf, MYF(0));
   data_buf= NULL;
 }
 
@@ -1641,7 +1653,7 @@ Block_writer::~Block_writer()
 Block_writer::result_t
 Block_writer::get_buf(Buffer &buf)
 {
-  buf.table_no= 0;
+  buf.table_num= 0;
   buf.last= FALSE;
   buf.size= buf_size;
   buf.data= NULL;
@@ -1671,13 +1683,13 @@ Block_writer::write_buf(const Buffer &bu
 {
   st_bstream_data_chunk  chunk_info;
 
-  chunk_info.table_no= buf.table_no;
+  chunk_info.table_num= buf.table_num;
   chunk_info.data.begin= buf.data;
   chunk_info.data.end= buf.data + buf.size;
   chunk_info.flags= buf.last ? BSTREAM_FLAG_LAST_CHUNK : 0x00;
-  chunk_info.snap_no= snap_no;
+  chunk_info.snap_num= snap_num;
 
-  int ret= bstream_wr_data_chunk(&m_str,&chunk_info);
+  int ret= bstream_wr_data_chunk(&m_str, &chunk_info);
 
   if (ret == BSTREAM_OK)
   {
diff -Nrup a/sql/backup/debug.h b/sql/backup/debug.h
--- a/sql/backup/debug.h	2007-12-04 18:38:07 +01:00
+++ b/sql/backup/debug.h	2008-02-27 21:04:09 +01:00
@@ -12,46 +12,6 @@
 # define DBUG_BACKUP
 #endif
 
-#ifdef DBUG_BACKUP
-
-/*
-  Macros for debugging error (or other) conditions. Usage:
-
-  TEST_ERROR_IF(<condition deciding if TEST_ERROR should be true>);
-
-  if (<other conditions> || TEST_ERROR)
-  {
-    <report error>
-  }
-
-  The additional TEST_ERROR condition will be set only if "backup_error_test"
-  error injection is set in the server.
-
-  Notes:
-   - Whenever TEST_ERROR is used in a condition, TEST_ERROR_IF() should
-     be called before - otherwise TEST_ERROR might be unintentionally TRUE.
-   - This mechanism is not thread safe.
- */
-
-namespace backup {
- extern bool test_error_flag;
-}
-
-#define TEST_ERROR  backup::test_error_flag
-// FIXME: DBUG_EXECUTE_IF below doesn't work
-#define TEST_ERROR_IF(X) \
- do { \
-   backup::test_error_flag= FALSE; \
-   DBUG_EXECUTE_IF("backup_error_test", backup::test_error_flag= (X);); \
- } while(0)
-
-#else
-
-//#define BACKUP_BREAKPOINT(S)
-#define TEST_ERROR  FALSE
-#define TEST_ERROR_IF(X)
-
-#endif
 
 /**
   @page BACKUP_BREAKPOINT Online Backup Breakpoints
@@ -265,7 +225,7 @@ namespace backup {
 #define BACKUP_BREAKPOINT(S) \
  do { \
   DBUG_PRINT("backup",("== breakpoint on '%s' ==",(S))); \
-  DBUG_EXECUTE_IF("backup_debug", DBUG_SYNC_POINT((S),BACKUP_BREAKPOINT_TIMEOUT);); \
+  DBUG_EXECUTE_IF("backup_debug", debug_sync_point((S),BACKUP_BREAKPOINT_TIMEOUT);); \
  } while (0)
 
 #endif
diff -Nrup a/sql/backup/image_info.cc b/sql/backup/image_info.cc
--- a/sql/backup/image_info.cc	2008-02-19 18:00:39 +01:00
+++ b/sql/backup/image_info.cc	2008-02-27 21:04:09 +01:00
@@ -14,8 +14,8 @@
 
 namespace backup {
 
-Image_info::Image_info():
-  data_size(0), m_table_count(0), m_dbs(16,16)
+Image_info::Image_info()
+  :data_size(0), m_table_count(0), m_dbs(16, 16)
 {
   init_alloc_root(&mem_root, 4 * 1024, 0);
 
@@ -24,18 +24,20 @@ Image_info::Image_info():
   bzero(static_cast<st_bstream_image_header*>(this),
         sizeof(st_bstream_image_header));
 
-  version= 1;
+  /* 
+    This code reads and writes backup image using version 1 of the backup 
+    image format.
+   */ 
+  version= 1; 
 
   /*
-    The arithmetic below assumes that MYSQL_VERSION_ID digits are arrenged
+    The arithmetic below assumes that MYSQL_VERSION_ID digits are arranged
     as follows: HLLRR where
     H - major version number
     L - minor version number
     R - release
-
-    TODO: check if this is correct
   */
-  DBUG_PRINT("backup",("version %d",MYSQL_VERSION_ID));
+  DBUG_PRINT("backup",("version %d", MYSQL_VERSION_ID));
   server_version.major= MYSQL_VERSION_ID / 10000;
   server_version.minor= (MYSQL_VERSION_ID % 10000) / 100;
   server_version.release= MYSQL_VERSION_ID % 100;
@@ -45,16 +47,16 @@ Image_info::Image_info():
 
   flags= 0;  // TODO: set BSTREAM_FLAG_BIG_ENDIAN flag accordingly
 
-  bzero(m_snap,sizeof(m_snap));
+  bzero(m_snap, sizeof(m_snap));
 }
 
 Image_info::~Image_info()
 {
   // Delete server table objects 
   
-  for (uint no=0; no<256; ++no)
+  for (uint n=0; n<256; ++n)
   {
-    Snapshot_info *snap= m_snap[no];
+    Snapshot_info *snap= m_snap[n];
     
     if (!snap)
       continue;
@@ -83,16 +85,15 @@ Image_info::~Image_info()
   free_root(&mem_root, MYF(0));
 }
 
-
 Image_info::Db* 
-Image_info::add_db(const String &db_name, ulong pos)
+Image_info::add_db(const String &db_name, uint pos)
 {
   Db *db= new (&mem_root) Db(db_name);
   
   if (!db)
     return NULL;
   
-  if (m_dbs.insert(pos,db))
+  if (m_dbs.insert(pos, db))
     return NULL;
   
   db->base.pos= pos;
@@ -111,28 +112,32 @@ Image_info::get_db(uint pos) const
   
   The snapshot should be non-empty, that is contain data of at least one table.
   Snapshot is added to the list of snapshots used in the image and a number is
-  assigned to it. This number is stored in @c snap.m_no. If snapshot's number
-  is @c no then pointer to a corresponding @c Snapshot_info object is stored in 
-  @c m_snap[no-1].
+  assigned to it. This number is stored in @c snap.m_num. If snapshot's number
+  is @c n then pointer to a corresponding @c Snapshot_info object is stored in 
+  @c m_snap[n-1].
   
   The @c Snapshot_info object is not owned by @c Image_info instance - it must
   be deleted externally.
  */ 
 int Image_info::add_snapshot(Snapshot_info &snap)
 {
-  uint no= st_bstream_image_header::snap_count++;
-  
-  if (no > 256)
+  uint num= st_bstream_image_header::snap_count++;
+
+  // The limit of 256 snapshots is imposed by backup stream format.  
+  if (num > 256)
     return -1;
   
-  m_snap[no]= &snap;
-  snap.m_no= no+1;
+  m_snap[num]= &snap;
+  snap.m_num= num + 1;
   
-  // Store information about snapshot in the snapshot[] table
-  
-  st_bstream_snapshot_info &info= snapshot[no];
+  /* 
+    Store information about snapshot in the snapshot[] table for the
+    backup stream library
+   */
+
+  st_bstream_snapshot_info &info= snapshot[num];
   
-  bzero(&info,sizeof(st_bstream_snapshot_info));
+  bzero(&info, sizeof(st_bstream_snapshot_info));
   info.type= enum_bstream_snapshot_type(snap.type());
   info.version= snap.version();
   info.table_count= snap.table_count();
@@ -149,15 +154,25 @@ int Image_info::add_snapshot(Snapshot_in
     info.engine.name.end= info.engine.name.begin + strlen(se_name);    
   }
   
-  return no+1;
+  return num + 1;
+}
+
+/**
+  Check if catalogue contains given database.
+ */ 
+bool Image_info::has_db(const String &db_name)
+{
+  for (uint n=0; n < m_dbs.count() ; ++n)
+    if (m_dbs[n] && m_dbs[n]->name() == db_name)
+      return TRUE;
+
+  return FALSE;
 }
 
 /**
   Add table to the catalogue.
   
   Table's data snapshot is added to the catalogue if it was not there already.
-  
-  FIXME: add_table should generate error if table name starts with 'b' (?)
  */
 Image_info::Table* 
 Image_info::add_table(Db &db, const String &table_name, 
@@ -174,13 +189,13 @@ Image_info::add_table(Db &db, const Stri
   if (db.add_table(*t))
     return NULL;
 
-  if (!snap.m_no)
-    snap.m_no= add_snapshot(snap); // reports errors
+  if (!snap.m_num)
+    snap.m_num= add_snapshot(snap); // reports errors
 
-  if (!snap.m_no)
+  if (!snap.m_num)
    return NULL;
 
-  t->snap_no= snap.m_no - 1;
+  t->snap_num= snap.m_num - 1;
   t->base.base.pos= pos;
   t->base.db= &db;
 
@@ -190,12 +205,12 @@ Image_info::add_table(Db &db, const Stri
 }
 
 Image_info::Table* 
-Image_info::get_table(uint snap_no, ulong pos) const
+Image_info::get_table(ushort snap_num, ulong pos) const
 {
-  if (snap_no > snap_count() || m_snap[snap_no] == NULL)
+  if (snap_num > snap_count() || m_snap[snap_num] == NULL)
     return NULL;
   
-  Table *t= m_snap[snap_no]->get_table(pos);
+  Table *t= m_snap[snap_num]->get_table(pos);
   
   if (!t)
     return NULL;
@@ -226,7 +241,7 @@ Image_info::Obj *find_obj(const Image_in
     const st_bstream_table_info &ti= 
                            reinterpret_cast<const st_bstream_table_info&>(item);
 
-    return info.get_table(ti.snap_no,item.pos);
+    return info.get_table(ti.snap_num, item.pos);
   }
 
   default:
@@ -236,4 +251,4 @@ Image_info::Obj *find_obj(const Image_in
 
 } // backup namespace
 
-template class Map<uint,backup::Image_info::Db>;
+template class Map<uint, backup::Image_info::Db>;
diff -Nrup a/sql/backup/image_info.h b/sql/backup/image_info.h
--- a/sql/backup/image_info.h	2008-02-19 18:00:39 +01:00
+++ b/sql/backup/image_info.h	2008-02-27 21:04:09 +01:00
@@ -27,9 +27,9 @@ class Snapshot_info;
   stored in table data snapshots created by backup drivers.
 
   For each snapshot present in the image there is a @c Snapshot_info object.
-  A pointer to n-th snapshot object is stored in @c m_snap[no]. This object 
-  contains list of tables whose data is stored in it. Note that each table must 
-  belong to exactly one snapshot.
+  A pointer to n-th snapshot object is stored in @c m_snap[n]. This object 
+  contains list of tables whose data is stored in the snapshot. Note that each 
+  table in the catalogue must belong to exactly one snapshot.
 
   Each object in the catalogue has its coordinates. The format of these 
   coordinates depends on the object type. For databases, it is just its number. 
@@ -38,7 +38,7 @@ class Snapshot_info;
   objects given their coordinates. Objects can be also browsed using one of
   the iterator classes defined within @c Image_info.
 
-  For each type of objects stored in the catalogue, there is a class derived
+  For each type of object stored in the catalogue, there is a class derived
   from @c Image_info::Obj, whose instances are used to keep information about
   such objects. These instances are owned by the @c Image_info object who is 
   responsible for freeing memory used by them. Currently a memory root is used
@@ -66,14 +66,18 @@ public: // public interface
 
    size_t     data_size;      ///< How much of table data is saved in the image.
 
-   uint       table_count() const;
+   ulong      table_count() const;
    uint       db_count() const;
-   uint       snap_count() const;
+   ushort     snap_count() const;
+
+   // Examine contents of the catalogue.
+
+   bool has_db(const String&);
 
    // Retrieve objects using their coordinates.
 
    Db*    get_db(uint pos) const;
-   Table* get_table(uint snap_no, ulong pos) const;
+   Table* get_table(ushort snap_num, ulong pos) const;
 
    // Iterators for enumerating the contents of the archive.
 
@@ -81,8 +85,12 @@ public: // public interface
    DbObj_iterator* get_db_objects(const Db &db);
 
    /**
-     Pointers to Snapshot_info objects corresponding to snapshots
-     present in the image. 
+     Pointers to @c Snapshot_info objects corresponding to the snapshots
+     present in the image.
+     
+     We can have at most 256 different snapshots which is a limitation imposed
+     by the backup stream library (the number of snapshots is stored inside 
+     backup image using one byte field).
     */ 
    Snapshot_info *m_snap[256];
    
@@ -99,7 +107,7 @@ public: // public interface
   // Populate the catalogue
   
   int    add_snapshot(Snapshot_info&);
-  Db*    add_db(const String &db_name, ulong pos);
+  Db*    add_db(const String &db_name, uint pos);
   Table* add_table(Db &db, const String &table_name, 
                    Snapshot_info &snap, ulong pos);
 
@@ -116,8 +124,8 @@ public: // public interface
 
   // storage
 
-  MEM_ROOT  mem_root;    ///< Memory root used to allocate @c Obj instaces.
-  Map<uint,Db>   m_dbs;  ///< Pointers to Db instances.
+  MEM_ROOT  mem_root;    ///< Memory root used to allocate @c Obj instances.
+  Map<uint, Db>   m_dbs; ///< Pointers to Db instances.
 
   // friends
 
@@ -136,14 +144,14 @@ Image_info::Obj* find_obj(const Image_in
   that interface using a map, which for given table number returns a pointer
   to corresponding @c Image_info::Table instance.
   
-  This class is not a container - it only stores pointers to 
+  @note This class is not a container - it only stores pointers to 
   @c Image_info::Table objects which are owned by the @c Image_info instance.
  */ 
 class Image_info::Tables:
   public Table_list,
-  public Map<uint,Image_info::Table>
+  public Map<uint, Image_info::Table>
 {
-  typedef Map<uint,Image_info::Table> Base;
+  typedef Map<uint, Image_info::Table> Base;
  
  public:
 
@@ -163,8 +171,8 @@ class Image_info::Tables:
                         when the current capacity is exceeded
  */ 
 inline
-Image_info::Tables::Tables(ulong init_size, ulong increase): 
-  Base(init_size, increase) 
+Image_info::Tables::Tables(ulong init_size, ulong increase)
+  :Base(init_size, increase) 
 {}
 
 
@@ -189,9 +197,12 @@ class Snapshot_info
  public:
 
   enum enum_snap_type {
-    NATIVE_SNAPSHOT= BI_NATIVE,   ///< snapshot created by native backup engine
-    DEFAULT_SNAPSHOT= BI_DEFAULT, ///< snapshot created by built-in, blocking backup engine
-    CS_SNAPSHOT= BI_CS            ///< snapshot created by built-in CS backup engine
+    /** snapshot created by native backup engine. */
+    NATIVE_SNAPSHOT= BI_NATIVE,
+    /** Snapshot created by built-in, blocking backup engine. */
+    DEFAULT_SNAPSHOT= BI_DEFAULT,
+    /** Snapshot created by built-in CS backup engine. */
+    CS_SNAPSHOT= BI_CS
   };
 
   virtual enum_snap_type type() const =0; 
@@ -200,10 +211,10 @@ class Snapshot_info
   /**
     Position inside image's snapshot list.
 
-    Starts with 1. M_no == 0 means that this snapshot is not included in the
+    Starts with 1. @c M_num == 0 means that this snapshot is not included in the
     backup image (for example, no tables have been added to it yet).
   */
-  ushort m_no;
+  ushort m_num;
 
   /**
     Size of the initial data transfer (estimate). This is
@@ -216,7 +227,7 @@ class Snapshot_info
 
     The name should fit into "%s backup/restore driver" pattern.
    */
-  virtual const char* name() const;
+  virtual const char* name() const =0;
 
   /// Check if instance was correctly constructed
   virtual bool is_valid() =0;
@@ -236,7 +247,7 @@ class Snapshot_info
 
  protected:
  
-  version_t m_version; ///< to store version of the snapshot's format
+  version_t m_version; ///< Stores version number of the snapshot's format.
 
   Snapshot_info(const version_t);
 
@@ -254,8 +265,8 @@ class Snapshot_info
 
 
 inline
-Snapshot_info::Snapshot_info(const version_t version): 
-  m_no(0), init_size(0), m_version(version), m_tables(128,1024)
+Snapshot_info::Snapshot_info(const version_t version) 
+  :m_num(0), init_size(0), m_version(version), m_tables(128, 1024)
 {}
 
 inline
@@ -271,9 +282,9 @@ Snapshot_info::~Snapshot_info()
 /**
   Represents object stored in a backup image.
 
-  Instances of this class store name of the object and other relevant
-  information. For each type of objects a subclass of this class is derived
-  which is specialized in storing information about that kind of objects.
+  Instances of this class store the name and other relevant information about
+  an object. For each type of object a subclass of this class is derived
+  which is specialized in storing information specific to that kind of object.
 
   Method @c info() returns a pointer to @c st_bstream_item_info structure 
   filled with data describing the corresponding object in the way required by
@@ -281,16 +292,16 @@ Snapshot_info::~Snapshot_info()
   
   Method @c materialize() can be used to create a corresponding instance of
   @c obs::Obj, to be used by server's objects services API. If @c m_obj_ptr is
-  not NULL then it contains a pointer to the corresponding @c obs:;Obj instance
-  which was obtained earlier (wither with @c materialize() or from server's 
-  object enumerators).
+  not NULL then it contains a pointer to the corresponding @c obs::Obj instance
+  which was obtained earlier (either with @c materialize() or from server's 
+  object iterators).
 */
 class Image_info::Obj: public Sql_alloc
 {
  public:
  
   /* 
-    Note: Snice we are using Sql_alloc and allocate instances using MEM_ROOT,
+    Note: Since we are using Sql_alloc and allocate instances using MEM_ROOT,
     destructors will not be called! This is also true for derived classes.
    */
   virtual ~Obj();
@@ -328,7 +339,7 @@ class Image_info::Obj: public Sql_alloc
 };
 
 inline
-Image_info::Obj::Obj(): m_obj_ptr(NULL)
+Image_info::Obj::Obj() :m_obj_ptr(NULL)
 {}
 
 inline
@@ -343,7 +354,7 @@ class Image_info::Db
    public Image_info::Obj,
    public Db_ref
 {
-  ulong m_table_count;  ///< Number of tables belonging to that database.
+  ulong m_table_count;  ///< Number of tables in the database.
 
  public:
 
@@ -356,18 +367,18 @@ class Image_info::Db
 
  private:
  
-  Table *first_table; ///< Pointer to the first table in this database's table list. 
-  Table *last_table;  ///< Pointer to the last table in this database's table list.
+  Table *first_table; ///< Pointer to the first table in database's table list. 
+  Table *last_table;  ///< Pointer to the last table in database's table list.
 
   friend class DbObj_iterator;
 };
 
 inline
-Image_info::Db::Db(const String &name):
- Db_ref(Image_info::Obj::m_name),
+Image_info::Db::Db(const String &name)
+ :Db_ref(Image_info::Obj::m_name),
  m_table_count(0), first_table(NULL), last_table(NULL)
 {
-  bzero(&base,sizeof(base));
+  bzero(&base, sizeof(base));
   base.type= BSTREAM_IT_DB;
   store_name(name);
 }
@@ -397,10 +408,10 @@ class Image_info::Table
 };
 
 inline
-Image_info::Table::Table(const Db &db, const String &name):
-  Table_ref(db.name(), Image_info::Obj::m_name), m_db(db), next_table(NULL)
+Image_info::Table::Table(const Db &db, const String &name)
+  :Table_ref(db.name(), Image_info::Obj::m_name), m_db(db), next_table(NULL)
 {
-  bzero(&base,sizeof(base));
+  bzero(&base, sizeof(base));
   base.base.type= BSTREAM_IT_TABLE;
   store_name(name);
 }
@@ -460,8 +471,7 @@ class Image_info::Iterator
 };
 
 inline
-Image_info::Iterator::Iterator(const Image_info &info): 
- m_info(info) 
+Image_info::Iterator::Iterator(const Image_info &info) :m_info(info) 
 {}
 
 inline
@@ -486,8 +496,8 @@ class Image_info::Db_iterator
 };
 
 inline
-Image_info::Db_iterator::Db_iterator(const Image_info &info): 
-  Iterator(info), pos(0)
+Image_info::Db_iterator::Db_iterator(const Image_info &info)
+  :Iterator(info), pos(0)
 {}
 
 /**
@@ -511,8 +521,8 @@ class Image_info::DbObj_iterator
 };
 
 inline
-Image_info::DbObj_iterator::DbObj_iterator(const Image_info &info, const Db &db):
- Db_iterator(info), ptr(db.first_table)
+Image_info::DbObj_iterator::DbObj_iterator(const Image_info &info, const Db &db)
+ :Db_iterator(info), ptr(db.first_table)
 {}
 
 
@@ -531,14 +541,14 @@ uint Image_info::db_count() const
 
 /// Returns total number of tables in the image.
 inline
-uint Image_info::table_count() const
+ulong Image_info::table_count() const
 { 
   return m_table_count;
 }
 
 /// Returns number of snapshots used by the image.
 inline
-uint Image_info::snap_count() const
+ushort Image_info::snap_count() const
 { 
   return st_bstream_image_header::snap_count;
 }
@@ -551,7 +561,7 @@ static
 void save_time(const time_t t, bstream_time_t &buf)
 {
   struct tm time;
-  gmtime_r(&t,&time);
+  gmtime_r(&t, &time);
   buf.year= time.tm_year;
   buf.mon= time.tm_mon;
   buf.mday= time.tm_mday;
@@ -606,7 +616,7 @@ Image_info::Db_iterator* Image_info::get
 inline
 Image_info::DbObj_iterator* Image_info::get_db_objects(const Db &db)
 {
-  return new DbObj_iterator(*this,db);
+  return new DbObj_iterator(*this, db);
 }
 
 /********************************************************************
@@ -745,11 +755,6 @@ result_t Image_info::Db::add_table(Table
 inline
 version_t Snapshot_info::version() const  
 { return m_version; }
-
-/// Default implementation of the virtual method
-inline 
-const char* Snapshot_info::name() const
-{ return "<Unknown>"; }
 
 /// Add table at a given position.
 inline
diff -Nrup a/sql/backup/kernel.cc b/sql/backup/kernel.cc
--- a/sql/backup/kernel.cc	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/kernel.cc	2008-02-27 21:04:09 +01:00
@@ -1,43 +1,21 @@
 /**
   @file
 
-  Implementation of the backup kernel API.
+  @brief Implementation of the backup kernel API.
 
-  @todo Add more error messages.
-  @todo Use internal table name representation when passing tables to
-        backup/restore drivers.
-  @todo Handle other types of meta-data in Backup_info methods.
-  @todo Handle item dependencies when adding new items.
-  @todo Handle other kinds of backup locations (far future).
- */
-
-#include "../mysql_priv.h"
-
-#include "backup_kernel.h"
-#include "logger.h"
-#include "stream.h"
-#include "debug.h"
-#include "be_native.h"
-#include "be_default.h"
-#include "be_snapshot.h"
-#include "ddl_blocker.h"
-#include "backup_progress.h"
-
-/*
-  How to use backup kernel API to perform backup and restore operations
-  =====================================================================
+  @section s1 How to use backup kernel API to perform backup and restore operations
   
   To perform backup or restore operation an appropriate context must be created.
   This involves creating required resources and correctly setting up the server.
   When operation is completed or interrupted, the context must be destroyed and
   all preparations reversed.
   
-  All this is accomplished by creating an instance of Backup_crate_ctx class and
-  then using its methods. When the instance is destroyed, the required clean-up
-  is performed.
+  All this is accomplished by creating an instance of Backup_create_ctx class and
+  then using its methods to perform the operation. When the instance is 
+  destroyed, the required clean-up is performed.
   
   This is how backup is performed using the context object:
-
+  @code
   {
   
    Backup_restore_ctx context(thd); // create context instance
@@ -55,11 +33,11 @@
    context.close(); // explicit clean-up
   
   } // if code jumps here, context destructor will do the clean-up automatically
-
+  @endcode
   
   Similar code will be used for restore (bit simpler as we don't support 
   selective restores yet):
-
+  @code
   {
   
    Backup_restore_ctx context(thd); // create context instance
@@ -70,14 +48,34 @@
    context.close(); // explicit clean-up
   
   } // if code jumps here, context destructor will do the clean-up automatically
+  @endcode
 
- */ 
+  @todo Use internal table name representation when passing tables to
+        backup/restore drivers.
+  @todo Handle other types of meta-data in Backup_info methods.
+  @todo Handle item dependencies when adding new items.
+  @todo Handle other kinds of backup locations (far future).
+*/
+
+#include "../mysql_priv.h"
+#include "../si_objects.h"
+
+#include "backup_kernel.h"
+#include "logger.h"
+#include "stream.h"
+#include "debug.h"
+#include "be_native.h"
+#include "be_default.h"
+#include "be_snapshot.h"
+#include "ddl_blocker.h"
+#include "backup_progress.h"
 
 
 /** 
   Global Initialization for online backup system.
  
-  @note This function is called when server loads its plugins.
+  @note This function is called in the server initialization sequence, just
+  after it loads all its plugins.
  */
 int backup_init()
 {
@@ -88,7 +86,8 @@ int backup_init()
 /**
   Global clean-up for online backup system.
   
-  @note This function is called when server shuts down its plugins.
+  @note This function is called in the server shut-down sequences, just before
+  it shuts-down all its plugins.
  */
 void backup_shutdown()
 {
@@ -109,6 +108,8 @@ static int send_reply(Backup_restore_ctx
   @param lex  results of parsing the statement.
 
   @note This function sends response to the client (ok, result set or error).
+
+  @returns 0 on success, error code otherwise.
  */
 
 int
@@ -126,23 +127,19 @@ execute_backup_command(THD *thd, LEX *le
   Backup_restore_ctx context(thd); // reports errors
   
   if (!context.is_valid())
-    DBUG_RETURN(send_error(context,ER_BACKUP_CONTEXT_CREATE));
+    DBUG_RETURN(send_error(context, ER_BACKUP_CONTEXT_CREATE));
 
   switch (lex->sql_command) {
 
-  case SQLCOM_SHOW_ARCHIVE:
-    
-    my_error(ER_NOT_ALLOWED_COMMAND,MYF(0));
-    DBUG_RETURN(ER_NOT_ALLOWED_COMMAND);
-
   case SQLCOM_BACKUP:
   {
     // prepare for backup operation
     
-    Backup_info *info= context.prepare_for_backup(lex->backup_dir); // reports errors
+    Backup_info *info= context.prepare_for_backup(lex->backup_dir);
+                                                              // reports errors
 
     if (!info || !info->is_valid())
-      DBUG_RETURN(send_error(context,ER_BACKUP_BACKUP_PREPARE));
+      DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP_PREPARE));
 
     BACKUP_BREAKPOINT("bp_running_state");
 
@@ -150,24 +147,24 @@ execute_backup_command(THD *thd, LEX *le
 
     if (lex->db_list.is_empty())
     {
-      context.write_message(log_level::INFO,"Backing up all databases");
+      context.write_message(log_level::INFO, "Backing up all databases");
       res= info->add_all_dbs(); // backup all databases
     }
     else
     {
-      context.write_message(log_level::INFO,"Backing up selected databases");
+      context.write_message(log_level::INFO, "Backing up selected databases");
       res= info->add_dbs(lex->db_list); // backup databases specified by user
     }
 
     info->close(); // close catalogue after filling it with objects to backup
 
     if (res || !info->is_valid())
-      DBUG_RETURN(send_error(context,ER_BACKUP_BACKUP_PREPARE));
+      DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP_PREPARE));
 
     if (info->db_count() == 0)
     {
       context.fatal_error(ER_BACKUP_NOTHING_TO_BACKUP);
-      DBUG_RETURN(send_error(context,ER_BACKUP_NOTHING_TO_BACKUP));
+      DBUG_RETURN(send_error(context, ER_BACKUP_NOTHING_TO_BACKUP));
     }
 
     // perform backup
@@ -175,7 +172,7 @@ execute_backup_command(THD *thd, LEX *le
     res= context.do_backup();
  
     if (res)
-      DBUG_RETURN(send_error(context,ER_BACKUP_BACKUP));
+      DBUG_RETURN(send_error(context, ER_BACKUP_BACKUP));
 
     BACKUP_BREAKPOINT("bp_complete_state");
     break;
@@ -186,14 +183,14 @@ execute_backup_command(THD *thd, LEX *le
     Restore_info *info= context.prepare_for_restore(lex->backup_dir);
     
     if (!info || !info->is_valid())
-      DBUG_RETURN(send_error(context,ER_BACKUP_RESTORE_PREPARE));
+      DBUG_RETURN(send_error(context, ER_BACKUP_RESTORE_PREPARE));
     
     BACKUP_BREAKPOINT("bp_running_state");
 
     res= context.do_restore();      
 
     if (res)
-      DBUG_RETURN(send_error(context,ER_BACKUP_RESTORE));
+      DBUG_RETURN(send_error(context, ER_BACKUP_RESTORE));
     
     break;
   }
@@ -208,7 +205,7 @@ execute_backup_command(THD *thd, LEX *le
   } // switch(lex->sql_command)
 
   if (context.close())
-    DBUG_RETURN(send_error(context,ER_BACKUP_CONTEXT_REMOVE));
+    DBUG_RETURN(send_error(context, ER_BACKUP_CONTEXT_REMOVE));
 
   // All seems OK - send positive reply to client
 
@@ -220,12 +217,14 @@ execute_backup_command(THD *thd, LEX *le
 
   Current implementation reports the last error saved in the logger if it exist.
   Otherwise it reports error given by @c error_code.
+
+  @returns 0 on success, error code otherwise.
  */
 int send_error(Backup_restore_ctx &log, int error_code, ...)
 {
   MYSQL_ERROR *error= log.last_saved_error();
 
-  if (error && !util::report_mysql_error(log.m_thd,error,error_code))
+  if (error && !util::report_mysql_error(log.m_thd, error, error_code))
   {
     if (error->code)
       error_code= error->code;
@@ -234,26 +233,25 @@ int send_error(Backup_restore_ctx &log, 
   {
     char buf[ERRMSGSIZE + 20];
     va_list args;
-    va_start(args,error_code);
+    va_start(args, error_code);
 
-    my_vsnprintf(buf,sizeof(buf),ER_SAFE(error_code),args);
-    my_printf_error(error_code,buf,MYF(0));
+    my_vsnprintf(buf, sizeof(buf), ER_SAFE(error_code), args);
+    my_printf_error(error_code, buf, MYF(0));
 
     va_end(args);
   }
 
   if (log.backup::Logger::m_state == backup::Logger::RUNNING)
-    log.report_stop(my_time(0),FALSE); // FASLE = no success
+    log.report_stop(my_time(0), FALSE); // FASLE = no success
   return error_code;
 }
 
 
 /**
-  Send a summary of the backup/restore operation to the client.
+  Send positive reply after a backup/restore operation.
 
-  The data about the operation is taken from filled @c Archive_info
-  structure. Parameter @c backup determines if this was backup or
-  restore operation.
+  Currently the id of the operation is returned. It can be used to select
+  correct entries form the backup progress tables.
 */
 int send_reply(Backup_restore_ctx &context)
 {
@@ -266,14 +264,14 @@ int send_reply(Backup_restore_ctx &conte
   /*
     Send field list.
   */
-  field_list.push_back(new Item_empty_string(STRING_WITH_LEN("backup_id"))); //op_str.c_ptr(), op_str.length()));
+  field_list.push_back(new Item_empty_string(STRING_WITH_LEN("backup_id")));
   protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
 
   /*
     Send field data.
   */
   protocol->prepare_for_resend();
-  llstr(context.op_id(),buf);
+  llstr(context.op_id(), buf);
   protocol->store(buf, system_charset_info);
   protocol->write();
 
@@ -322,11 +320,9 @@ bool Backup_restore_ctx::is_running= FAL
 pthread_mutex_t Backup_restore_ctx::run_lock;
 backup::Mem_allocator *Backup_restore_ctx::mem_alloc= NULL;
 
-// access the DDL blocker instance
-extern DDL_blocker_class *DDL_blocker;
 
-Backup_restore_ctx::Backup_restore_ctx(THD *thd):
- m_state(CREATED), m_thd(thd), m_thd_options(thd->options),
+Backup_restore_ctx::Backup_restore_ctx(THD *thd)
+ :m_state(CREATED), m_thd(thd), m_thd_options(thd->options),
  m_error(0), m_remove_loc(FALSE), m_stream(NULL), m_catalog(NULL)
 {
   /*
@@ -349,8 +345,11 @@ Backup_restore_ctx::~Backup_restore_ctx(
   
   It is checked if another operation is in progress and if yes then
   error is reported. Otherwise the current operation is registered so that
-  no other can be started. Also, a memory allocator for backup stream library
-  is initialized.
+  no other can be started. All preparations common to backup and restore 
+  operations are done. In particular, all changes to meta data are blocked
+  with DDL blocker.
+
+  @returns 0 on success, error code otherwise.
  */ 
 int Backup_restore_ctx::prepare(LEX_STRING location)
 {
@@ -399,7 +398,7 @@ int Backup_restore_ctx::prepare(LEX_STRI
 
   if (bad_filename)
   {
-    fatal_error(ER_BAD_PATH,location.str);
+    fatal_error(ER_BAD_PATH, location.str);
     return m_error;
   }
 
@@ -420,7 +419,7 @@ int Backup_restore_ctx::prepare(LEX_STRI
 
   // Freeze all meta-data. 
 
-  if (!DDL_blocker->block_DDL(m_thd))
+  if (obs::ddl_blocker_enable(m_thd))
   {
     fatal_error(ER_DDL_BLOCK);
     return m_error;
@@ -438,6 +437,12 @@ int Backup_restore_ctx::prepare(LEX_STRI
   which objects to backup. NULL if an error was detected.
   
   @note This function reports errors.
+
+  @note It is important that changes of meta-data are blocked as part of the
+  preparations. The set of server objects and their definitions should not
+  change after the backup context has been prepared and before the actual backup
+  is performed using @c do_backup() method. In particular, meta-data should be 
+  frozen when 
  */ 
 Backup_info* Backup_restore_ctx::prepare_for_backup(LEX_STRING location)
 {
@@ -458,18 +463,19 @@ Backup_info* Backup_restore_ctx::prepare
   report_start(when);
   
   /*
-    Do preparations common to backup and restore operations.
+    Do preparations common to backup and restore operations. After call
+    to prepare() all meta-data changes are blocked.
    */ 
   if (prepare(location))
     return NULL;
-  
+
   backup::String path(location);
   
   /*
     Open output stream.
    */
 
-  OStream *s= new OStream(*this, path);
+  Output_stream *s= new Output_stream(*this, path);
   
   if (!s)
   {
@@ -479,7 +485,7 @@ Backup_info* Backup_restore_ctx::prepare
   
   if (!s->open())
   {
-    fatal_error(ER_BACKUP_WRITE_LOC,path.ptr());
+    fatal_error(ER_BACKUP_WRITE_LOC, path.ptr());
     return NULL;
   }
 
@@ -536,7 +542,8 @@ Restore_info* Backup_restore_ctx::prepar
   report_start(when);
 
   /*
-    Do preparations common to backup and restore operations.
+    Do preparations common to backup and restore operations. After this call
+    changes of meta-data are blocked.
    */ 
   if (prepare(location))
     return NULL;
@@ -546,7 +553,7 @@ Restore_info* Backup_restore_ctx::prepar
    */
 
   backup::String path(location);
-  IStream *s= new IStream(*this, path);
+  Input_stream *s= new Input_stream(*this, path);
   
   if (!s)
   {
@@ -556,7 +563,7 @@ Restore_info* Backup_restore_ctx::prepar
   
   if (!s->open())
   {
-    fatal_error(ER_BACKUP_READ_LOC,path.ptr());
+    fatal_error(ER_BACKUP_READ_LOC, path.ptr());
     return NULL;
   }
 
@@ -581,7 +588,7 @@ Restore_info* Backup_restore_ctx::prepar
   m_catalog= info;
 
   /*
-    Read catalogue from input stream.
+    Read catalogue from the input stream.
    */
 
   if (read_header(*info, *s))
@@ -619,7 +626,7 @@ Restore_info* Backup_restore_ctx::prepar
   This should reverse all settings made when context was created and prepared.
   If it was requested, the backup/restore location is removed. Also, the backup
   stream memory allocator is shut down. Any other allocated resources are 
-  deleted in the destructor.
+  deleted in the destructor. Changes to meta-data are unblocked.
   
   @returns 0 or error code if error was detected.
   
@@ -636,7 +643,7 @@ int Backup_restore_ctx::close()
 
   // unfreeze meta-data
 
-  DDL_blocker->unblock_DDL();
+  obs::ddl_blocker_disable();
 
   // restore thread options
 
@@ -685,7 +692,7 @@ int Backup_restore_ctx::close()
   // We report completion of the operation only if no errors were detected.
 
   if (!m_error)
-    report_stop(when,TRUE);
+    report_stop(when, TRUE);
 
   m_state= CLOSED;
   return m_error;
@@ -695,6 +702,8 @@ int Backup_restore_ctx::close()
   Create backup archive.
   
   @pre @c prepare_for_backup() method was called.
+
+  @returns 0 on success, error code otherwise.
 */
 int Backup_restore_ctx::do_backup()
 {
@@ -709,8 +718,8 @@ int Backup_restore_ctx::do_backup()
   
   using namespace backup;
 
-  OStream &s= *static_cast<OStream*>(m_stream);
-  Backup_info &info= *static_cast<Backup_info*>(m_catalog);
+  Output_stream &s= *static_cast<Output_stream*>(m_stream);
+  Backup_info   &info= *static_cast<Backup_info*>(m_catalog);
 
   BACKUP_BREAKPOINT("backup_meta");
 
@@ -752,6 +761,8 @@ int Backup_restore_ctx::do_backup()
   Restore objects saved in backup image.
 
   @pre @c prepare_for_restore() method was called.
+
+  @returns 0 on success, error code otherwise.
 */
 int Backup_restore_ctx::do_restore()
 {
@@ -765,12 +776,12 @@ int Backup_restore_ctx::do_restore()
 
   using namespace backup;
 
-  IStream &s= *static_cast<IStream*>(m_stream);
+  Input_stream &s= *static_cast<Input_stream*>(m_stream);
   Restore_info &info= *static_cast<Restore_info*>(m_catalog);
 
   report_stats_pre(info);
 
-  DBUG_PRINT("restore",("Restoring meta-data"));
+  DBUG_PRINT("restore", ("Restoring meta-data"));
 
   disable_fkey_constraints();
 
@@ -817,10 +828,10 @@ struct Mem_allocator::node
   node *next;
 };
 
-Mem_allocator::Mem_allocator(): first(NULL)
+Mem_allocator::Mem_allocator() :first(NULL)
 {}
 
-/// Deletes all allocated segments which have not been freed.
+/// Deletes all allocated segments which have not been freed explicitly.
 Mem_allocator::~Mem_allocator()
 {
   node *n= first;
@@ -828,7 +839,7 @@ Mem_allocator::~Mem_allocator()
   while (n)
   {
     first= n->next;
-    my_free(n,MYF(0));
+    my_free(n, MYF(0));
     n= first;
   }
 }
@@ -836,13 +847,13 @@ Mem_allocator::~Mem_allocator()
 /**
   Allocate memory segment of given size.
 
-  Extra memory is allocated for a @c node structure which holds pointers
+  Extra memory is allocated for @c node structure which holds pointers
   to previous and next segment in the segments list. This is used when
   deallocating allocated memory in the destructor.
 */
 void* Mem_allocator::alloc(size_t howmuch)
 {
-  void *ptr= my_malloc(sizeof(node)+howmuch, MYF(0));
+  void *ptr= my_malloc(sizeof(node) + howmuch, MYF(0));
 
   if (!ptr)
     return NULL;
@@ -883,7 +894,7 @@ void Mem_allocator::free(void *ptr)
   if (n->next)
     n->next->prev= n->prev;
 
-  my_free(n,MYF(0));
+  my_free(n, MYF(0));
 }
 
 } // backup namespace
@@ -898,8 +909,9 @@ void Mem_allocator::free(void *ptr)
 /**
   Memory allocator for backup stream library.
 
-  @pre @c prepare_stream_memory() has been called (i.e., the Mem_allocator
-  instance is created.
+  @pre A backup/restore context has been created and prepared for the 
+  operation (one of @c Backup_restore_ctx::prepare_for_backup() or 
+  @c Backup_restore_ctx::prepare_for_restore() have been called).
  */
 extern "C"
 bstream_byte* bstream_alloc(unsigned long int size)
@@ -924,21 +936,21 @@ void bstream_free(bstream_byte *ptr)
 }
 
 /**
-  Prepare @c Restore_info object for populating it with items read from
-  backup image's catalogue.
+  Prepare restore catalogue for populating it with items read from
+  backup image.
 
   At this point we know the list of table data snapshots present in the image
   (it was read from image's header). Here we create @c Snapshot_info object
   for each of them.
 
-  @todo Report errors.
+  @rerturns 0 on success, error code otherwise.
 */
 extern "C"
 int bcat_reset(st_bstream_image_header *catalogue)
 {
   using namespace backup;
 
-  uint no;
+  uint n;
 
   DBUG_ASSERT(catalogue);
   Restore_info *info= static_cast<Restore_info*>(catalogue);
@@ -950,11 +962,11 @@ int bcat_reset(st_bstream_image_header *
     in m_snap[] array.
    */ 
 
-  for (no=0; no < info->snap_count(); ++no)
+  for (n=0; n < info->snap_count(); ++n)
   {
-    st_bstream_snapshot_info *snap= &info->snapshot[no];
+    st_bstream_snapshot_info *snap= &info->snapshot[n];
 
-    DBUG_PRINT("restore",("Creating info for snapshot no %d",no));
+    DBUG_PRINT("restore",("Creating info for snapshot no. %d", n));
 
     switch (snap->type) {
 
@@ -966,42 +978,45 @@ int bcat_reset(st_bstream_image_header *
 
       if (!se || !hton)
       {
-        info->m_ctx.fatal_error(ER_BACKUP_CANT_FIND_SE,name_lex.str);
+        info->m_ctx.fatal_error(ER_BACKUP_CANT_FIND_SE, name_lex.str);
         return BSTREAM_ERROR;
       }
 
       if (!hton->get_backup_engine)
       {
-        info->m_ctx.fatal_error(ER_BACKUP_NO_NATIVE_BE,name_lex.str);
+        info->m_ctx.fatal_error(ER_BACKUP_NO_NATIVE_BE, name_lex.str);
         return BSTREAM_ERROR;
       }
 
-      info->m_snap[no]= new Native_snapshot(info->m_ctx, snap->version, se); // reports errors
+      info->m_snap[n]= new Native_snapshot(info->m_ctx, snap->version, se);
+                                                              // reports errors
       break;
     }
 
     case BI_CS:
-      info->m_snap[no]= new CS_snapshot(info->m_ctx, snap->version); // reports errors
+      info->m_snap[n]= new CS_snapshot(info->m_ctx, snap->version);
+                                                              // reports errors
       break;
 
     case BI_DEFAULT:
-      info->m_snap[no]= new Default_snapshot(info->m_ctx, snap->version); // reports errors
+      info->m_snap[n]= new Default_snapshot(info->m_ctx, snap->version);
+                                                              // reports errors
       break;
 
     default:
       // note: we use convention that snapshots are counted starting from 1.
-      info->m_ctx.fatal_error(ER_BACKUP_UNKNOWN_BE,no+1);
+      info->m_ctx.fatal_error(ER_BACKUP_UNKNOWN_BE, n + 1);
       return BSTREAM_ERROR;
     }
 
-    if (!info->m_snap[no])
+    if (!info->m_snap[n])
     {
       info->m_ctx.fatal_error(ER_OUT_OF_RESOURCES);
       return BSTREAM_ERROR;
     }
 
-    info->m_snap[no]->m_no= no+1;
-    info->m_ctx.report_driver(info->m_snap[no]->name());
+    info->m_snap[n]->m_num= n + 1;
+    info->m_ctx.report_driver(info->m_snap[n]->name());
   }
 
   return BSTREAM_OK;
@@ -1025,7 +1040,8 @@ int bcat_close(st_bstream_image_header *
   @todo Report errors.
 */
 extern "C"
-int bcat_add_item(st_bstream_image_header *catalogue, struct st_bstream_item_info *item)
+int bcat_add_item(st_bstream_image_header *catalogue, 
+                  struct st_bstream_item_info *item)
 {
   using namespace backup;
 
@@ -1042,7 +1058,7 @@ int bcat_add_item(st_bstream_image_heade
 
   case BSTREAM_IT_DB:
   {
-    Image_info::Db *db= info->add_db(name_str,item->pos); // reports errors
+    Image_info::Db *db= info->add_db(name_str, item->pos); // reports errors
 
     if (!db)
       return BSTREAM_ERROR;
@@ -1054,9 +1070,9 @@ int bcat_add_item(st_bstream_image_heade
   {
     st_bstream_table_info *it= (st_bstream_table_info*)item;
 
-    DBUG_PRINT("restore",(" table's snapshot no is %d",it->snap_no));
+    DBUG_PRINT("restore",(" table's snapshot no. is %d", it->snap_num));
 
-    Snapshot_info *snap= info->m_snap[it->snap_no];
+    Snapshot_info *snap= info->m_snap[it->snap_num];
 
     if (!snap)
     {
@@ -1065,8 +1081,8 @@ int bcat_add_item(st_bstream_image_heade
         to create one of the snapshots listed in image's header we would stop
         with error earlier.
        */
-      DBUG_ASSERT(it->snap_no >= info->snap_count());
-      info->m_ctx.fatal_error(ER_BACKUP_WRONG_TABLE_BE,it->snap_no+1);
+      DBUG_ASSERT(it->snap_num >= info->snap_count());
+      info->m_ctx.fatal_error(ER_BACKUP_WRONG_TABLE_BE, it->snap_num + 1);
       return BSTREAM_ERROR;
     }
 
@@ -1075,9 +1091,10 @@ int bcat_add_item(st_bstream_image_heade
     if (!db)
       return BSTREAM_ERROR;
 
-    DBUG_PRINT("restore",(" table's database is %s",db->name().ptr()));
+    DBUG_PRINT("restore",(" table's database is %s", db->name().ptr()));
 
-    Image_info::Table *tbl= info->add_table(*db,name_str, *snap, item->pos); // reports error
+    Image_info::Table *tbl= info->add_table(*db, name_str, *snap, item->pos); 
+                                                             // reports errors
     
     if (!tbl)
       return BSTREAM_ERROR;
@@ -1122,7 +1139,7 @@ void* bcat_iterator_get(st_bstream_image
     return &null_iter;
 
   case BSTREAM_IT_GLOBAL:   // all global objects
-    // only global items (for which meta-data is stored) are databases
+    // note: only global items (for which meta-data is stored) are databases
   case BSTREAM_IT_DB:       // all databases
   {
     Backup_info::Db_iterator *it= info->get_dbs();
@@ -1206,7 +1223,8 @@ void  bcat_iterator_free(st_bstream_imag
   database.
  */
 extern "C"
-void* bcat_db_iterator_get(st_bstream_image_header *catalogue, struct st_bstream_db_info *dbi)
+void* bcat_db_iterator_get(st_bstream_image_header *catalogue,
+                           st_bstream_db_info *dbi)
 {
   DBUG_ASSERT(catalogue);
   DBUG_ASSERT(dbi);
@@ -1234,8 +1252,8 @@ void* bcat_db_iterator_get(st_bstream_im
 extern "C"
 struct st_bstream_dbitem_info*
 bcat_db_iterator_next(st_bstream_image_header *catalogue,
-                        struct st_bstream_db_info *db,
-                        void *iter)
+                      st_bstream_db_info *db,
+                      void *iter)
 {
   const backup::Image_info::Obj *ptr= (*(backup::Image_info::Iterator*)iter)++;
 
@@ -1244,8 +1262,8 @@ bcat_db_iterator_next(st_bstream_image_h
 
 extern "C"
 void  bcat_db_iterator_free(st_bstream_image_header *catalogue,
-                              struct st_bstream_db_info *db,
-                              void *iter)
+                            st_bstream_db_info *db,
+                            void *iter)
 {
   delete (backup::Image_info::DbObj_iterator*)iter;
 }
@@ -1314,13 +1332,13 @@ int bcat_create_item(st_bstream_image_he
 
   if (!sobj)
   {
-    info->m_ctx.fatal_error(create_err,obj->describe(buf));
+    info->m_ctx.fatal_error(create_err, obj->describe(buf));
     return BSTREAM_ERROR;
   }
 
   if (sobj->execute(::current_thd))
   {
-    info->m_ctx.fatal_error(create_err,obj->describe(buf));
+    info->m_ctx.fatal_error(create_err, obj->describe(buf));
     return BSTREAM_ERROR;
   }
   
@@ -1331,8 +1349,8 @@ int bcat_create_item(st_bstream_image_he
   Get serialization string for a given object.
   
   The catalogue should contain @c Image_info::Obj instance corresponding to the
-  object described by @c item. This instance should contain pointer to @c obs::Obj 
-  instance which can be used for getting the serialization string.
+  object described by @c item. This instance should contain pointer to 
+  @c obs::Obj instance which can be used for getting the serialization string.
  */ 
 extern "C"
 int bcat_get_item_create_query(st_bstream_image_header *catalogue,
@@ -1356,7 +1374,7 @@ int bcat_get_item_create_query(st_bstrea
   case BSTREAM_IT_TABLE:  meta_err= ER_BACKUP_GET_META_TABLE; break;
   
   /*
-   This can't happen - the item was obtained from the backup kernel.
+    This can't happen - the item was obtained from the backup kernel.
   */
   default: DBUG_ASSERT(FALSE);
   }
@@ -1380,11 +1398,12 @@ int bcat_get_item_create_query(st_bstrea
   
   ::String *buf= &(info->serialization_buf);
   buf->length(0);
+
   if (obj->m_obj_ptr->serialize(::current_thd, buf))
   {
     Image_info::Obj::describe_buf dbuf;
 
-    info->m_ctx.fatal_error(meta_err,obj->describe(dbuf));
+    info->m_ctx.fatal_error(meta_err, obj->describe(dbuf));
     return BSTREAM_ERROR;    
   }
 
@@ -1417,27 +1436,22 @@ int bcat_get_item_create_data(st_bstream
 
 namespace backup {
 
-// Flag used for testing error reporting
-#ifdef DBUG_BACKUP
-bool test_error_flag= FALSE;
-#endif
-
 /// Build linked @c TABLE_LIST list from a list stored in @c Table_list object.
-
-/*
-  FIXME: build list with the same order as in input
-  Actually, should work fine with reversed list as long as we use the reversed
-  list both in table writing and reading.
- */
 TABLE_LIST *build_table_list(const Table_list &tables, thr_lock_type lock)
 {
   TABLE_LIST *tl= NULL;
 
+  /*
+    FIXME: build list with the same order as in input
+    Actually, should work fine with reversed list as long as we use the reversed
+    list both in table writing and reading.
+   */
+
   for( uint tno=0; tno < tables.count() ; tno++ )
   {
     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));
+    bzero(ptr, sizeof(TABLE_LIST));
 
     Table_ref tbl= tables[tno];
 
diff -Nrup a/sql/backup/logger.cc b/sql/backup/logger.cc
--- a/sql/backup/logger.cc	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/logger.cc	2008-02-27 21:04:09 +01:00
@@ -39,7 +39,7 @@ int Logger::write_message(log_level::val
 
    if (m_state == READY || m_state == RUNNING)
    {
-     my_snprintf(buf,sizeof(buf),"%s: %s", 
+     my_snprintf(buf, sizeof(buf), "%s: %s", 
                  m_type == BACKUP ? "Backup" : "Restore" , msg);
      out= buf;
    }
@@ -48,9 +48,9 @@ int Logger::write_message(log_level::val
    case log_level::ERROR:
      if (m_save_errors)
        errors.push_front(new MYSQL_ERROR(::current_thd, error_code,
-                                         MYSQL_ERROR::WARN_LEVEL_ERROR,msg));
+                                         MYSQL_ERROR::WARN_LEVEL_ERROR, msg));
      sql_print_error(out);
-     DBUG_PRINT("backup_log",("[ERROR] %s",out));
+     DBUG_PRINT("backup_log",("[ERROR] %s", out));
      
      if (m_state == READY || m_state == RUNNING)
        report_ob_error(m_op_id, error_code);
@@ -59,12 +59,12 @@ int Logger::write_message(log_level::val
 
    case log_level::WARNING:
      sql_print_warning(out);
-     DBUG_PRINT("backup_log",("[Warning] %s",out));
+     DBUG_PRINT("backup_log",("[Warning] %s", out));
      return 0;
 
    case log_level::INFO:
      sql_print_information(out);
-     DBUG_PRINT("backup_log",("[Info] %s",out));
+     DBUG_PRINT("backup_log",("[Info] %s", out));
      return 0;
 
    default: return ERROR;
@@ -84,7 +84,7 @@ int Logger::write_message(log_level::val
  */
 int Logger::v_report_error(log_level::value level, int error_code, va_list args)
 {
-  return v_write_message(level,error_code,ER_SAFE(error_code),args);
+  return v_write_message(level, error_code, ER_SAFE(error_code), args);
 }
 
 /**
@@ -99,12 +99,13 @@ int Logger::v_write_message(log_level::v
 {
   char buf[ERRMSGSIZE + 20];
 
-  my_vsnprintf(buf,sizeof(buf),format,args);
-  return write_message(level,error_code,buf);
+  my_vsnprintf(buf, sizeof(buf), format, args);
+  return write_message(level, error_code, buf);
 }
 
 /**
-  Report statistics from backup/restore catalogue before the main operation starts.
+  Report statistics from backup/restore catalogue before the main operation
+  starts.
  */ 
 void Logger::report_stats_pre(const Image_info &info)
 {
@@ -114,7 +115,8 @@ void Logger::report_stats_pre(const Imag
 }
 
 /**
-  Report statistics from backup/restore catalogue after the operation is completed.
+  Report statistics from backup/restore catalogue after the operation is
+  completed.
  */ 
 void Logger::report_stats_post(const Image_info &info)
 {
diff -Nrup a/sql/backup/logger.h b/sql/backup/logger.h
--- a/sql/backup/logger.h	2008-02-18 13:04:24 +01:00
+++ b/sql/backup/logger.h	2008-02-27 21:04:10 +01:00
@@ -78,8 +78,8 @@ class Logger
    */ 
   ulong m_op_id;
 
-  int v_report_error(log_level::value,int,va_list);
-  int v_write_message(log_level::value,int, const char*,va_list);
+  int v_report_error(log_level::value, int, va_list);
+  int v_write_message(log_level::value, int, const char*, va_list);
   int write_message(log_level::value level , int error_code, const char *msg);
 
  private:
@@ -89,8 +89,8 @@ class Logger
 };
 
 inline
-Logger::Logger(): 
-  m_type(BACKUP), m_state(CREATED), m_op_id(0), m_save_errors(FALSE)
+Logger::Logger() 
+  :m_type(BACKUP), m_state(CREATED), m_op_id(0), m_save_errors(FALSE)
 {}
 
 inline
@@ -133,7 +133,7 @@ int Logger::write_message(log_level::val
 {
   va_list args;
 
-  va_start(args,msg);
+  va_start(args, msg);
   int res= v_write_message(level, 0, msg, args);
   va_end(args);
 
@@ -146,7 +146,7 @@ int Logger::report_error(int error_code,
 {
   va_list args;
 
-  va_start(args,error_code);
+  va_start(args, error_code);
   int res= v_report_error(log_level::ERROR, error_code, args);
   va_end(args);
 
@@ -159,7 +159,7 @@ int Logger::report_error(log_level::valu
 {
   va_list args;
 
-  va_start(args,error_code);
+  va_start(args, error_code);
   int res= v_report_error(level, error_code, args);
   va_end(args);
 
@@ -172,7 +172,7 @@ int Logger::report_error(const char *for
 {
   va_list args;
 
-  va_start(args,format);
+  va_start(args, format);
   int res= v_write_message(log_level::ERROR, 0, format, args);
   va_end(args);
 
diff -Nrup a/sql/backup/restore_info.h b/sql/backup/restore_info.h
--- a/sql/backup/restore_info.h	2008-02-19 18:00:39 +01:00
+++ b/sql/backup/restore_info.h	2008-02-27 21:04:10 +01:00
@@ -10,9 +10,10 @@ class Restore_info;
 namespace backup {
 
 class Logger;
-class IStream;
+class Input_stream;
 
-int restore_table_data(THD*, backup::Logger&, Restore_info&, backup::IStream&);
+int restore_table_data(THD*, backup::Logger&, Restore_info&, 
+                       backup::Input_stream&);
 
 } // backup namespace
 
@@ -21,11 +22,11 @@ int restore_table_data(THD*, backup::Log
   Specialization of @c Image_info which is in restore operation.
 
   An instance of this class is created by 
-  @c Backup_restore_ctx::prepare_for_restore() method, which fills the catalogue
-  with data read from a backup image.
+  @c Backup_restore_ctx::prepare_for_restore() method, which reads the 
+  catalogue from a backup image.
   
-  Currently it is not possible to select objects which will be restored. Thus
-  this class can only be used to examine what is going to be restored.
+  Currently it is not possible to select which objects will be restored. This
+  class can only be used to examine what is going to be restored.
  */
 
 class Restore_info: public backup::Image_info
@@ -42,14 +43,14 @@ class Restore_info: public backup::Image
  private:
 
   friend int backup::restore_table_data(THD*, backup::Logger&, Restore_info&, 
-                                        backup::IStream&);
+                                        backup::Input_stream&);
   friend int ::bcat_add_item(st_bstream_image_header*,
                              struct st_bstream_item_info*);
 };
 
 inline
-Restore_info::Restore_info(Backup_restore_ctx &ctx):
-  m_ctx(ctx)
+Restore_info::Restore_info(Backup_restore_ctx &ctx)
+  :m_ctx(ctx)
 {}
 
 inline
@@ -58,8 +59,8 @@ Restore_info::~Restore_info()
   /*
     Delete Snapshot_info instances - they are created in bcat_reset(). 
    */
-  for (uint no=0; no < snap_count(); ++no)
-    delete m_snap[no];
+  for (ushort n=0; n < snap_count(); ++n)
+    delete m_snap[n];
 }
 
 inline
diff -Nrup a/sql/backup/stream.cc b/sql/backup/stream.cc
--- a/sql/backup/stream.cc	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/stream.cc	2008-02-27 21:04:10 +01:00
@@ -29,7 +29,7 @@ extern "C" int stream_write(void *instan
   int fd;
   int res;
 
-  DBUG_ENTER("backup::IStream::write");
+  DBUG_ENTER("backup::stream_write");
 
   DBUG_ASSERT(instance);
   DBUG_ASSERT(buf);
@@ -71,7 +71,7 @@ extern "C" int stream_read(void *instanc
   int fd;
   size_t howmuch;
 
-  DBUG_ENTER("backup::IStream::read");
+  DBUG_ENTER("backup::stream_read");
 
   DBUG_ASSERT(instance);
   DBUG_ASSERT(buf);
@@ -113,8 +113,8 @@ extern "C" int stream_read(void *instanc
 }
 
 
-Stream::Stream(Logger &log, const ::String &name, int flags):
-  m_path(name), m_flags(flags), m_block_size(0), m_log(log)
+Stream::Stream(Logger &log, const ::String &name, int flags)
+  :m_path(name), m_flags(flags), m_block_size(0), m_log(log)
 {
   bzero(&stream, sizeof(stream));
   bzero(&buf, sizeof(buf));
@@ -127,7 +127,7 @@ Stream::Stream(Logger &log, const ::Stri
 bool Stream::open()
 {
   close();
-  m_fd= my_open(m_path.c_ptr(),m_flags,MYF(0));
+  m_fd= my_open(m_path.c_ptr(), m_flags, MYF(0));
   return m_fd >= 0;
 }
 
@@ -135,19 +135,19 @@ void Stream::close()
 {
   if (m_fd >= 0)
   {
-    my_close(m_fd,MYF(0));
+    my_close(m_fd, MYF(0));
     m_fd= -1;
   }
 }
 
 bool Stream::rewind()
 {
-  return m_fd >= 0 && my_seek(m_fd,0,SEEK_SET,MYF(0)) == 0;
+  return m_fd >= 0 && my_seek(m_fd, 0, SEEK_SET, MYF(0)) == 0;
 }
 
 
-OStream::OStream(Logger &log, const ::String &name):
-  Stream(log, name, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC)
+Output_stream::Output_stream(Logger &log, const ::String &name)
+  :Stream(log, name, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC)
 {
   stream.write= stream_write;
   m_block_size=0; // use default block size provided by the backup stram library
@@ -160,13 +160,13 @@ OStream::OStream(Logger &log, const ::St
 
   @return Number of bytes written or -1 if error.
 */
-int OStream::write_magic_and_version()
+int Output_stream::write_magic_and_version()
 {
   byte buf[10];
 
   DBUG_ASSERT(m_fd >= 0);
 
-  memmove(buf,backup_magic_bytes,8);
+  memmove(buf, backup_magic_bytes, 8);
   // format version = 1
   buf[8]= 0x01;
   buf[9]= 0x00;
@@ -182,7 +182,7 @@ int OStream::write_magic_and_version()
 /**
   Initialize backup stream after the underlying stream has been opened.
  */ 
-bool OStream::init()
+bool Output_stream::init()
 {
   // write magic bytes and format version
   int len= write_magic_and_version();
@@ -195,7 +195,7 @@ bool OStream::init()
 
   bytes= 0;
   
-  if (BSTREAM_OK != bstream_open_wr(this,m_block_size,len))
+  if (BSTREAM_OK != bstream_open_wr(this, m_block_size, len))
   {
     m_log.report_error(ER_BACKUP_OPEN_WR);
     return FALSE;
@@ -212,7 +212,7 @@ bool OStream::init()
 
   @todo Report errors.
 */
-bool OStream::open()
+bool Output_stream::open()
 {
   close();
 
@@ -229,9 +229,9 @@ bool OStream::open()
 
   If @c destroy is TRUE, the stream object is deleted.
 */
-void OStream::close()
+void Output_stream::close()
 {
-  if (m_fd<0)
+  if (m_fd < 0)
     return;
 
   bstream_close(this);
@@ -245,7 +245,7 @@ void OStream::close()
   @retval TRUE  operation succeeded
   @retval FALSE operation failed
 */
-bool OStream::rewind()
+bool Output_stream::rewind()
 {
   bstream_close(this);
 
@@ -258,8 +258,8 @@ bool OStream::rewind()
 }
 
 
-IStream::IStream(Logger &log, const ::String &name):
-  Stream(log, name, O_RDONLY)
+Input_stream::Input_stream(Logger &log, const ::String &name)
+  :Stream(log, name, O_RDONLY)
 {
   stream.read= stream_read;
 }
@@ -272,7 +272,7 @@ IStream::IStream(Logger &log, const ::St
 
   @return Number of bytes read or -1 if error.
 */
-int IStream::check_magic_and_version()
+int Input_stream::check_magic_and_version()
 {
   byte buf[10];
 
@@ -283,7 +283,7 @@ int IStream::check_magic_and_version()
   if (ret)
     return -1; // couldn't read magic bytes
 
-  if (memcmp(buf,backup_magic_bytes,8))
+  if (memcmp(buf, backup_magic_bytes, 8))
     return -1; // wrong magic bytes
 
   unsigned int ver = buf[8] + (buf[9]<<8);
@@ -297,7 +297,7 @@ int IStream::check_magic_and_version()
 /**
   Initialize backup stream after the underlying stream has been opened.
  */ 
-bool IStream::init()
+bool Input_stream::init()
 {
   int len= check_magic_and_version();
 
@@ -309,7 +309,7 @@ bool IStream::init()
 
   bytes= 0;
 
-  if (BSTREAM_OK != bstream_open_rd(this,len))
+  if (BSTREAM_OK != bstream_open_rd(this, len))
   {
     m_log.report_error(ER_BACKUP_OPEN_RD);
     return FALSE;
@@ -326,7 +326,7 @@ bool IStream::init()
 
   @todo Report errors.
 */
-bool IStream::open()
+bool Input_stream::open()
 {
   close();
 
@@ -343,9 +343,9 @@ bool IStream::open()
 
   If @c destroy is TRUE, the stream object is deleted.
 */
-void IStream::close()
+void Input_stream::close()
 {
-  if (m_fd<0)
+  if (m_fd < 0)
     return;
 
   bstream_close(this);
@@ -358,7 +358,7 @@ void IStream::close()
   @retval TRUE  operation succeeded
   @retval FALSE operation failed
 */
-bool IStream::rewind()
+bool Input_stream::rewind()
 {
   bstream_close(this);
 
@@ -368,7 +368,7 @@ bool IStream::rewind()
 }
 
 /// Move to next chunk in the stream.
-int IStream::next_chunk()
+int Input_stream::next_chunk()
 {
   return bstream_next_chunk(this);
 }
diff -Nrup a/sql/backup/stream.h b/sql/backup/stream.h
--- a/sql/backup/stream.h	2008-02-19 18:00:38 +01:00
+++ b/sql/backup/stream.h	2008-02-27 21:04:10 +01:00
@@ -56,11 +56,11 @@ struct fd_stream: public backup_stream
   int m_fd;
   size_t bytes;
   
-  fd_stream(): m_fd(-1), bytes(0) {}
+  fd_stream() :m_fd(-1), bytes(0) {}
 };
 
 /**
-  Base for @c OStream and @c IStream.
+  Base for @c Output_stream and @c Input_stream.
 
   It stores file descriptor and provides basic methods for operating on
   it. It also inherits from (and correctly fills) the backup_stream structure
@@ -91,17 +91,17 @@ class Stream: public fd_stream
   size_t  m_block_size;
   Logger  m_log;
 
-  friend int stream_write(void*,bstream_blob*,bstream_blob);
-  friend int stream_read(void*,bstream_blob*,bstream_blob);
+  friend int stream_write(void*, bstream_blob*, bstream_blob);
+  friend int stream_read(void*, bstream_blob*, bstream_blob);
 };
 
 /// Used to write to backup stream.
-class OStream:
+class Output_stream:
   public Stream
 {
  public:
 
-  OStream(Logger&, const ::String&);
+  Output_stream(Logger&, const ::String&);
 
   bool open();
   void close();
@@ -114,12 +114,12 @@ class OStream:
 };
 
 /// Used to read from backup stream.
-class IStream:
+class Input_stream:
   public Stream
 {
  public:
 
-  IStream(Logger&, const ::String &name);
+  Input_stream(Logger&, const ::String &name);
 
   bool open();
   void close();
@@ -140,25 +140,31 @@ class IStream:
 
 inline
 result_t
-write_preamble(const Image_info &info, OStream &s)
+write_preamble(const Image_info &info, Output_stream &s)
 {
-  const st_bstream_image_header *hdr= static_cast<const st_bstream_image_header*>(&info);
+  const st_bstream_image_header *hdr;
+
+  hdr= static_cast<const st_bstream_image_header*>(&info);
   int ret= bstream_wr_preamble(&s, const_cast<st_bstream_image_header*>(hdr));
+
   return ret == BSTREAM_ERROR ? ERROR : OK;
 }
 
 inline
 result_t
-write_summary(const Image_info &info, OStream &s)
+write_summary(const Image_info &info, Output_stream &s)
 {
-  const st_bstream_image_header *hdr= static_cast<const st_bstream_image_header*>(&info);
+  const st_bstream_image_header *hdr;
+
+  hdr= static_cast<const st_bstream_image_header*>(&info);
   int ret= bstream_wr_summary(&s, const_cast<st_bstream_image_header*>(hdr));
+
   return ret == BSTREAM_ERROR ? ERROR : OK;
 }
 
 inline
 result_t
-read_header(Image_info &info, IStream &s)
+read_header(Image_info &info, Input_stream &s)
 {
   int ret= bstream_rd_header(&s, static_cast<st_bstream_image_header*>(&info));
   return ret == BSTREAM_ERROR ? ERROR : OK;
@@ -166,7 +172,7 @@ read_header(Image_info &info, IStream &s
 
 inline
 result_t
-read_catalog(Image_info &info, IStream &s)
+read_catalog(Image_info &info, Input_stream &s)
 {
   int ret= bstream_rd_catalogue(&s, static_cast<st_bstream_image_header*>(&info));
   return ret == BSTREAM_ERROR ? ERROR : OK;
@@ -174,7 +180,7 @@ read_catalog(Image_info &info, IStream &
 
 inline
 result_t
-read_meta_data(Image_info &info, IStream &s)
+read_meta_data(Image_info &info, Input_stream &s)
 {
   int ret= bstream_rd_meta_data(&s, static_cast<st_bstream_image_header*>(&info));
   return ret == BSTREAM_ERROR ? ERROR : OK;
@@ -182,7 +188,7 @@ read_meta_data(Image_info &info, IStream
 
 inline
 result_t
-read_summary(Image_info &info, IStream &s)
+read_summary(Image_info &info, Input_stream &s)
 {
   int ret= bstream_rd_summary(&s, static_cast<st_bstream_image_header*>(&info));
   return ret == BSTREAM_ERROR ? ERROR : OK;
diff -Nrup a/sql/backup/stream_v1.c b/sql/backup/stream_v1.c
--- a/sql/backup/stream_v1.c	2007-12-03 21:28:16 +01:00
+++ b/sql/backup/stream_v1.c	2008-02-27 21:04:10 +01:00
@@ -891,10 +891,10 @@ int bstream_rd_item_type(backup_stream *
 
   [optional item data] is used only for tables:
 
-  [optional item data (table)]= [ flags:1 ! snapshot no:1 ! optional extra data ]
+  [optional item data (table)]= [ flags:1 ! snapshot no.:1 ! optional extra data ]
   @endverbatim
 
-  [snapshot no] tells which snapshot contains tables data.
+  [snapshot no.] tells which snapshot contains tables data.
 
   Presence of extra data is indicated by a flag.
   @verbatim
@@ -936,7 +936,7 @@ int bstream_wr_db_catalogue(backup_strea
     if (item->base.type == BSTREAM_IT_TABLE)
     {
       CHECK_WR_RES(bstream_wr_byte(s,0x00)); /* flags: we don't use extra data */
-      CHECK_WR_RES(bstream_wr_byte(s,((struct st_bstream_table_info*)item)->snap_no));
+      CHECK_WR_RES(bstream_wr_byte(s,((struct st_bstream_table_info*)item)->snap_num));
       CHECK_WR_RES(bstream_wr_num(s,item->base.pos));
     }
   }
@@ -994,7 +994,7 @@ int bstream_rd_db_catalogue(backup_strea
         return BSTREAM_ERROR;
 
       CHECK_RD_OK(bstream_rd_byte(s,&flags)); /* flags are ignored currently */
-      CHECK_RD_OK(bstream_rd_byte(s,&ti.snap_no));
+      CHECK_RD_OK(bstream_rd_byte(s,&ti.snap_num));
       CHECK_RD_RES(bstream_rd_num(s,&ti.base.base.pos));
     }
 
@@ -1305,10 +1305,10 @@ int bstream_rd_meta_data(backup_stream *
   in which part of catalogue the entry lies.
   @verbatim
 
-  [item position (global)]= [db no]
-  [item position (table)]= [ snap no ! pos in snapshot's table list ]
-  [item position (other per-db item)]= [ pos in db item list ! db no ]
-  [item position (per-table item)] = [ pos in table's item list ! db no ! table pos ]
+  [item position (global)]= [db no.]
+  [item position (table)]= [ snap no. ! pos in snapshot's table list ]
+  [item position (other per-db item)]= [ pos in db item list ! db no. ]
+  [item position (per-table item)] = [ pos in table's item list ! db no. ! table pos ]
   @endverbatim
 
   Note that table is identified by its position inside the snapshot to which it
@@ -1343,7 +1343,7 @@ int bstream_wr_meta_item(backup_stream *
 
   if (kind == TABLE_ITEM)
   {
-    CHECK_WR_RES(bstream_wr_byte(s,((struct st_bstream_table_info*)item)->snap_no));
+    CHECK_WR_RES(bstream_wr_byte(s,((struct st_bstream_table_info*)item)->snap_num));
     return ret;
   }
 
@@ -1427,7 +1427,7 @@ int bstream_rd_meta_item(backup_stream *
     if (ret != BSTREAM_OK)
       return BSTREAM_ERROR;
 
-    CHECK_RD_RES(bstream_rd_byte(s,&item_buf.table.snap_no));
+    CHECK_RD_RES(bstream_rd_byte(s,&item_buf.table.snap_num));
       return ret;
   }
 
@@ -1577,7 +1577,7 @@ int read_and_create_items(backup_stream 
 
   [table data]= [ table data chunk | ... | table data chunk ]
 
-  [table data chunk]= [ snapshot no:1 ! seq no:2 ! flags:1 ! table no ! data ]
+  [table data chunk]= [ snapshot no.:1 ! seq no.:2 ! flags:1 ! table no. ! data ]
   @endverbatim
 
   Data chunks of each snapshot are numbered by consecutive numbers. This can be
@@ -1599,10 +1599,10 @@ int bstream_wr_data_chunk(backup_stream 
 
   ASSERT(chunk);
 
-  CHECK_WR_RES(bstream_wr_byte(s,chunk->snap_no + 1));
+  CHECK_WR_RES(bstream_wr_byte(s,chunk->snap_num + 1));
   CHECK_WR_RES(bstream_wr_int2(s,0)); /* sequence number - not used now */
   CHECK_WR_RES(bstream_wr_byte(s,chunk->flags));
-  CHECK_WR_RES(bstream_wr_num(s,chunk->table_no));
+  CHECK_WR_RES(bstream_wr_num(s,chunk->table_num));
   CHECK_WR_RES(bstream_write_blob(s,chunk->data));
   CHECK_WR_RES(bstream_end_chunk(s));
 
@@ -1644,27 +1644,27 @@ int bstream_rd_data_chunk(backup_stream 
   blob *envelope;
   blob to_read;
   unsigned long int howmuch;
-  unsigned int seq_no;
+  unsigned int seq_num;
   int ret= BSTREAM_OK;
 
   ASSERT(chunk);
 
-  CHECK_RD_RES(bstream_rd_byte(s,&chunk->snap_no));
+  CHECK_RD_RES(bstream_rd_byte(s,&chunk->snap_num));
 
   /*
     Saved snapshot numbers start from 1 - if we read 0 it means that this is not
     a table data chunk
   */
-  if (chunk->snap_no == 0)
+  if (chunk->snap_num == 0)
     return BSTREAM_EOC;
   else if (ret != BSTREAM_OK)
     return BSTREAM_ERROR;
 
-  (chunk->snap_no)--;
+  (chunk->snap_num)--;
 
-  CHECK_RD_OK(bstream_rd_int2(s,&seq_no));  /* FIxME: handle sequence numbers */
+  CHECK_RD_OK(bstream_rd_int2(s,&seq_num));  /* FIxME: handle sequence numbers */
   CHECK_RD_OK(bstream_rd_byte(s,&chunk->flags));
-  CHECK_RD_OK(bstream_rd_num(s,&chunk->table_no));
+  CHECK_RD_OK(bstream_rd_num(s,&chunk->table_num));
 
   /*
     read rest of the chunk data into provided buffer or the internal buffer
diff -Nrup a/sql/backup/stream_v1.h b/sql/backup/stream_v1.h
--- a/sql/backup/stream_v1.h	2007-11-29 20:57:01 +01:00
+++ b/sql/backup/stream_v1.h	2008-02-27 21:04:10 +01:00
@@ -164,7 +164,12 @@ struct st_bstream_image_header
 
   /** number of table data snapshots in the image */
   unsigned short int        snap_count;
-  /** descriptions of table data snapshots */
+
+  /** 
+    Descriptions of table data snapshots.
+    
+    We have at most 256 snapshots because their number is stored using one byte. 
+   */
   struct st_bstream_snapshot_info snapshot[256];
 };
 
@@ -257,7 +262,7 @@ struct st_bstream_dbitem_info
 struct st_bstream_table_info
 {
   struct st_bstream_dbitem_info  base;  /**< data common to all per-db items */
-  unsigned short int  snap_no;  /**< snapshot where table's data is stored */
+  unsigned short int  snap_num;  /**< snapshot where table's data is stored */
 };
 
 /**
@@ -292,10 +297,10 @@ struct st_bstream_titem_info
 */
 struct st_bstream_data_chunk
 {
-  unsigned long int  table_no;  /**< table to which this data belongs */
+  unsigned long int  table_num;  /**< table to which this data belongs */
   bstream_blob       data;      /**< the data */
   unsigned short int flags;     /**< flags to be saved together with the chunk */
-  unsigned short int snap_no;   /**< which snapshot this chunk belongs to */
+  unsigned short int snap_num;   /**< which snapshot this chunk belongs to */
 };
 
 /** Indicates that given chunk is the last chunk of data for a given table */
diff -Nrup a/sql/si_objects.cc b/sql/si_objects.cc
--- a/sql/si_objects.cc	2008-01-31 16:15:24 +01:00
+++ b/sql/si_objects.cc	2008-02-27 21:04:07 +01:00
@@ -2485,14 +2485,15 @@ bool check_db_existence(const String *db
 
    @param[in] thd  current thread
 
-   @retval my_bool success = TRUE, error = FALSE
+   @retval FALSE on success.
+   @retval TRUE on error.
   */
 bool ddl_blocker_enable(THD *thd)
 {
   DBUG_ENTER("ddl_blocker_enable()");
   if (!DDL_blocker->block_DDL(thd))
-    DBUG_RETURN(FALSE);
-  DBUG_RETURN(TRUE);
+    DBUG_RETURN(TRUE);
+  DBUG_RETURN(FALSE);
 }
 
 /**
diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h
--- a/sql/sql_lex.h	2008-01-10 22:52:38 +01:00
+++ b/sql/sql_lex.h	2008-02-27 21:04:08 +01:00
@@ -117,7 +117,6 @@ enum enum_sql_command {
   SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
   SQLCOM_SHOW_CREATE_TRIGGER,
   SQLCOM_ALTER_DB_UPGRADE,
-  SQLCOM_SHOW_ARCHIVE,
   SQLCOM_BACKUP, SQLCOM_RESTORE,
 #ifdef BACKUP_TEST
   SQLCOM_BACKUP_TEST,
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2008-01-10 22:52:39 +01:00
+++ b/sql/sql_parse.cc	2008-02-27 21:04:08 +01:00
@@ -1979,12 +1979,6 @@ mysql_execute_command(THD *thd)
 #endif
 #endif
 
-  case SQLCOM_SHOW_ARCHIVE:
-#ifdef EMBEDDED_LIBRARY
-    // Note: online backup code doesn't compile as embedded library yet.
-    my_error(ER_NOT_SUPPORTED_YET, MYF(0), "SHOW ARCHIVE");
-    goto error;
-#endif
   case SQLCOM_BACKUP:
 #ifdef EMBEDDED_LIBRARY
     my_error(ER_NOT_SUPPORTED_YET, MYF(0), "BACKUP");
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2008-01-28 15:01:09 +01:00
+++ b/sql/sql_yacc.yy	2008-02-27 21:04:08 +01:00
@@ -9376,11 +9376,6 @@ show_param:
             Lex->spname= $3;
             Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT;
           }
-        | BACKUP_SYM TEXT_STRING_sys
-          {
-            Lex->sql_command = SQLCOM_SHOW_ARCHIVE;
-            Lex->backup_dir = $2; 
-          }
         ;
 
 show_engine_param:
Thread
bk commit into 6.0 tree (rafal:1.2768) WL#4212rsomla27 Feb