List:Commits« Previous MessageNext Message »
From:jonas Date:January 9 2006 1:28pm
Subject:bk commit into 5.1 tree (jonas:1.1989)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1989 06/01/09 14:28:19 jonas@stripped +11 -0
  ndb dd - wl#3013
    make ndb_restore handle dd objects

  storage/ndb/tools/restore/restore_main.cpp
    1.36 06/01/09 14:28:17 jonas@stripped +23 -0
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/tools/restore/consumer_restore.hpp
    1.11 06/01/09 14:28:16 jonas@stripped +5 -0
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/tools/restore/consumer_restore.cpp
    1.22 06/01/09 14:28:16 jonas@stripped +146 -1
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/tools/restore/consumer.hpp
    1.7 06/01/09 14:28:16 jonas@stripped +1 -0
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/tools/restore/Restore.hpp
    1.22 06/01/09 14:28:16 jonas@stripped +11 -0
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/tools/restore/Restore.cpp
    1.31 06/01/09 14:28:16 jonas@stripped +116 -6
    Add psrsing of dd objects

  storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
    1.40 06/01/09 14:28:16 jonas@stripped +13 -5
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
    1.99 06/01/09 14:28:16 jonas@stripped +99 -29
    Create copy contructor for dd object
    Make parseFile{group} static so that it can be used from ndb_restore

  storage/ndb/src/ndbapi/NdbDictionary.cpp
    1.46 06/01/09 14:28:16 jonas@stripped +80 -0
    Add objectId method to dd-objects

  storage/ndb/include/util/Vector.hpp
    1.6 06/01/09 14:28:16 jonas@stripped +27 -0
    New utility methods on Vector

  storage/ndb/include/ndbapi/NdbDictionary.hpp
    1.62 06/01/09 14:28:16 jonas@stripped +47 -1
    Add objectId method to dd-objects

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/51-dd

--- 1.61/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-01-04 11:45:45 +01:00
+++ 1.62/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-01-09 14:28:16 +01:00
@@ -93,7 +93,9 @@
      * Get version of object
      */
     virtual int getObjectVersion() const = 0;
-
+    
+    virtual int getObjectId() const = 0;
+    
     /**
      * Object type
      */
@@ -753,6 +755,7 @@
     void setTablespace(const char * name);
     void setTablespace(const class Tablespace &);
     const char * getTablespace() const;
+    Uint32 getTablespaceId() const;
 
     /**
      * Get table object type
@@ -770,6 +773,11 @@
     virtual int getObjectVersion() const;
 
     /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
+    /**
      * Set frm file to store with this table
      */ 
     void setFrm(const void* data, Uint32 len);
@@ -898,6 +906,11 @@
      */
     virtual int getObjectVersion() const;
 
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
     /** @} *******************************************************************/
 
     /** 
@@ -1168,6 +1181,11 @@
      */
     virtual int getObjectVersion() const;
 
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
     void print();
 #endif
@@ -1194,6 +1212,7 @@
   class LogfileGroup : public Object {
   public:
     LogfileGroup();
+    LogfileGroup(const LogfileGroup&);
     virtual ~LogfileGroup();
 
     void setName(const char * name);
@@ -1217,6 +1236,11 @@
      */
     virtual int getObjectVersion() const;
 
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
   private:
     friend class NdbDictionaryImpl;
     friend class NdbLogfileGroupImpl;
@@ -1230,6 +1254,7 @@
   class Tablespace : public Object {
   public:
     Tablespace();
+    Tablespace(const Tablespace&);
     virtual ~Tablespace();
 
     void setName(const char * name);
@@ -1243,7 +1268,9 @@
 
     void setDefaultLogfileGroup(const char * name);
     void setDefaultLogfileGroup(const class LogfileGroup&);
+
     const char * getDefaultLogfileGroup() const;
+    Uint32 getDefaultLogfileGroupId() const;
     
     /**
      * Get object status
@@ -1255,6 +1282,11 @@
      */
     virtual int getObjectVersion() const;
 
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
   private:
     friend class NdbTablespaceImpl;
     class NdbTablespaceImpl & m_impl;
@@ -1264,6 +1296,7 @@
   class Datafile : public Object {
   public:
     Datafile();
+    Datafile(const Datafile&);
     virtual ~Datafile();
 
     void setPath(const char * name);
@@ -1276,6 +1309,7 @@
     void setTablespace(const char * name);
     void setTablespace(const class Tablespace &);
     const char * getTablespace() const;
+    Uint32 getTablespaceId() const;
 
     void setNode(Uint32 nodeId);
     Uint32 getNode() const;
@@ -1292,6 +1326,11 @@
      */
     virtual int getObjectVersion() const;
 
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
+
   private:
     friend class NdbDatafileImpl;
     class NdbDatafileImpl & m_impl;
@@ -1301,6 +1340,7 @@
   class Undofile : public Object {
   public:
     Undofile();
+    Undofile(const Undofile&);
     virtual ~Undofile();
 
     void setPath(const char * path);
@@ -1312,6 +1352,7 @@
     void setLogfileGroup(const char * name);
     void setLogfileGroup(const class LogfileGroup &);
     const char * getLogfileGroup() const;
+    Uint32 getLogfileGroupId() const;
 
     void setNode(Uint32 nodeId);
     Uint32 getNode() const;
@@ -1327,6 +1368,11 @@
      * Get object version
      */
     virtual int getObjectVersion() const;
+
+    /**
+     * Get object id
+     */
+    virtual int getObjectId() const;
 
   private:
     friend class NdbUndofileImpl;

--- 1.5/storage/ndb/include/util/Vector.hpp	2005-04-08 02:43:54 +02:00
+++ 1.6/storage/ndb/include/util/Vector.hpp	2006-01-09 14:28:16 +01:00
@@ -31,6 +31,8 @@
   unsigned size() const { return m_size; };
   
   void push_back(const T &);
+  void push(const T&, unsigned pos);
+  T& set(T&, unsigned pos, T& fill_obj);
   T& back();
   
   void erase(unsigned index);
@@ -102,6 +104,31 @@
   }
   m_items[m_size] = t;
   m_size++;
+}
+
+template<class T>
+void
+Vector<T>::push(const T & t, unsigned pos)
+{
+  push_back(t);
+  if (pos < m_size - 1)
+  {
+    for(unsigned i = m_size - 1; i > pos; i--)
+    {
+      m_items[i] = m_items[i-1];
+    }
+    m_items[pos] = t;
+  }
+}
+
+template<class T>
+T&
+Vector<T>::set(T & t, unsigned pos, T& fill_obj)
+{
+  fill(pos, fill_obj);
+  T& ret = m_items[pos];
+  m_items[pos] = t;
+  return ret;
 }
 
 template<class T>

--- 1.30/storage/ndb/tools/restore/Restore.cpp	2005-11-07 12:19:10 +01:00
+++ 1.31/storage/ndb/tools/restore/Restore.cpp	2006-01-09 14:28:16 +01:00
@@ -140,27 +140,137 @@
 bool
 RestoreMetaData::readMetaTableDesc() {
   
-  Uint32 sectionInfo[2];
+  Uint32 sectionInfo[3];
   
   // Read section header 
-  if (buffer_read(&sectionInfo, sizeof(sectionInfo), 1) != 1){
+  Uint32 sz = sizeof(sectionInfo) >> 2;
+  if (m_fileHeader.NdbVersion < NDBD_ROWID_VERSION)
+  {
+    sz = 2;
+    sectionInfo[2] = htonl(DictTabInfo::UserTable);
+  }
+  if (buffer_read(&sectionInfo, 4*sz, 1) != 1){
     err << "readMetaTableDesc read header error" << endl;
     return false;
   } // if
   sectionInfo[0] = ntohl(sectionInfo[0]);
   sectionInfo[1] = ntohl(sectionInfo[1]);
+  sectionInfo[2] = ntohl(sectionInfo[2]);
   
   assert(sectionInfo[0] == BackupFormat::TABLE_DESCRIPTION);
   
   // Read dictTabInfo buffer
-  const Uint32 len = (sectionInfo[1] - 2);
+  const Uint32 len = (sectionInfo[1] - sz);
   void *ptr;
   if (buffer_get_ptr(&ptr, 4, len) != len){
     err << "readMetaTableDesc read error" << endl;
     return false;
   } // if
   
-  return parseTableDescriptor((Uint32*)ptr, len);	     
+  int errcode = 0;
+  DictObject obj = { sectionInfo[2], 0 };
+  switch(obj.m_objType){
+  case DictTabInfo::SystemTable:
+  case DictTabInfo::UserTable:
+  case DictTabInfo::UniqueHashIndex:
+  case DictTabInfo::OrderedIndex:
+    return parseTableDescriptor((Uint32*)ptr, len);	     
+    break;
+  case DictTabInfo::Tablespace:
+  {
+    NdbDictionary::Tablespace * dst = new NdbDictionary::Tablespace;
+    errcode = 
+      NdbDictInterface::parseFilegroupInfo(NdbTablespaceImpl::getImpl(* dst), 
+					   (Uint32*)ptr, len);
+    if (errcode)
+      delete dst;
+    obj.m_objPtr = dst;
+    debug << hex << obj.m_objPtr << " " 
+	   << dec << dst->getObjectId() << " " << dst->getName() << endl;
+    break;
+  }
+  case DictTabInfo::LogfileGroup:
+  {
+    NdbDictionary::LogfileGroup * dst = new NdbDictionary::LogfileGroup;
+    errcode = 
+      NdbDictInterface::parseFilegroupInfo(NdbLogfileGroupImpl::getImpl(* dst),
+					   (Uint32*)ptr, len);
+    if (errcode)
+      delete dst;
+    obj.m_objPtr = dst;
+    debug << hex << obj.m_objPtr << " " 
+	   << dec << dst->getObjectId() << " " << dst->getName() << endl;
+    break;
+  }
+  case DictTabInfo::Datafile:
+  {
+    NdbDictionary::Datafile * dst = new NdbDictionary::Datafile;
+    errcode = 
+      NdbDictInterface::parseFileInfo(NdbDatafileImpl::getImpl(* dst), 
+				      (Uint32*)ptr, len);
+    if (errcode)
+      delete dst;
+    obj.m_objPtr = dst;
+    debug << hex << obj.m_objPtr << " "
+	   << dec << dst->getObjectId() << " " << dst->getPath() << endl;
+    break;
+  }
+  case DictTabInfo::Undofile:
+  {
+    NdbDictionary::Undofile * dst = new NdbDictionary::Undofile;
+    errcode = 
+      NdbDictInterface::parseFileInfo(NdbUndofileImpl::getImpl(* dst), 
+				      (Uint32*)ptr, len);
+    if (errcode)
+      delete dst;
+    obj.m_objPtr = dst;
+    debug << hex << obj.m_objPtr << " " 
+	   << dec << dst->getObjectId() << " " << dst->getPath() << endl;
+    break;
+  }
+  default:
+    err << "Unsupported table type!! " << sectionInfo[2] << endl;
+    return false;
+  }
+  if (errcode)
+  {
+    err << "Unable to parse dict info..." 
+	<< sectionInfo[2] << " " << errcode << endl;
+    return false;
+  }
+
+  /**
+   * DD objects need to be sorted...
+   */
+  for(Uint32 i = 0; i<m_objects.size(); i++)
+  {
+    switch(sectionInfo[2]){
+    case DictTabInfo::Tablespace:
+      if (DictTabInfo::isFile(m_objects[i].m_objType))
+      {
+	m_objects.push(obj, i);
+	goto end;
+      }
+      break;
+    case DictTabInfo::LogfileGroup:
+    {
+      if (DictTabInfo::isFile(m_objects[i].m_objType) ||
+	  m_objects[i].m_objType == DictTabInfo::Tablespace)
+      {
+	m_objects.push(obj, i);
+	goto end;
+      }
+      break;
+    }
+    default:
+      m_objects.push_back(obj);
+      goto end;
+    }
+  }
+  m_objects.push_back(obj);
+  
+end:
+  return true;
 }
 
 bool
@@ -217,7 +327,7 @@
 {
   NdbTableImpl* tableImpl = 0;
   int ret = NdbDictInterface::parseTableInfo(&tableImpl, data, len, false);
-
+  
   if (ret != 0) {
     err << "parseTableInfo " << " failed" << endl;
     return false;
@@ -960,4 +1070,4 @@
 template class Vector<TableS*>;
 template class Vector<AttributeS*>;
 template class Vector<AttributeDesc*>;
-
+template class Vector<DictObject>;

--- 1.21/storage/ndb/tools/restore/Restore.hpp	2005-06-13 15:16:12 +02:00
+++ 1.22/storage/ndb/tools/restore/Restore.hpp	2006-01-09 14:28:16 +01:00
@@ -267,6 +267,11 @@
   bool Twiddle(const AttributeDesc *  attr_desc, AttributeData * attr_data, Uint32 arraySize = 0);
 };
 
+struct DictObject {
+  Uint32 m_objType;
+  void * m_objPtr;
+};
+
 class RestoreMetaData : public BackupFile {
 
   Vector<TableS *> allTables;
@@ -281,6 +286,8 @@
   
   bool parseTableDescriptor(const Uint32 * data, Uint32 len);
 
+  Vector<DictObject> m_objects;
+  
 public:
   RestoreMetaData(const char * path, Uint32 nodeId, Uint32 bNo);
   virtual ~RestoreMetaData();
@@ -292,6 +299,10 @@
   const TableS * operator[](int i) const { return allTables[i];}
   TableS * getTable(Uint32 tableId) const;
 
+  Uint32 getNoOfObjects() const { return m_objects.size();}
+  Uint32 getObjType(Uint32 i) const { return m_objects[i].m_objType; }
+  void* getObjPtr(Uint32 i) const { return m_objects[i].m_objPtr; }
+  
   Uint32 getStopGCP() const;
 }; // RestoreMetaData
 

--- 1.35/storage/ndb/tools/restore/restore_main.cpp	2005-09-06 10:30:20 +02:00
+++ 1.36/storage/ndb/tools/restore/restore_main.cpp	2006-01-09 14:28:17 +01:00
@@ -50,6 +50,7 @@
 static int _print_log = 0;
 static int _restore_data = 0;
 static int _restore_meta = 0;
+static int _no_restore_disk = 0;
   
 static struct my_option my_long_options[] =
 {
@@ -71,6 +72,10 @@
     "Restore meta data into NDB Cluster using NDBAPI",
     (gptr*) &_restore_meta, (gptr*) &_restore_meta,  0,
     GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
+  { "no-restore-disk-objects", 'd',
+    "Dont restore disk objects (tablespace/logfilegroups etc)",
+    (gptr*) &_no_restore_disk, (gptr*) &_no_restore_disk,  0,
+    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
   { "parallelism", 'p',
     "No of parallel transactions during restore of data."
     "(parallelism can be 1 to 1024)", 
@@ -187,6 +192,11 @@
     restore->m_restore_meta = true;
   }
 
+  if (_no_restore_disk)
+  {
+    restore->m_no_restore_disk = true;
+  }
+  
   {
     BackupConsumer * c = printer;
     g_consumers.push_back(c);
@@ -303,6 +313,19 @@
 
   }
 
+  for(i = 0; i<metaData.getNoOfObjects(); i++)
+  {
+    for(Uint32 j= 0; j < g_consumers.size(); j++)
+      if (!g_consumers[j]->object(metaData.getObjType(i),
+				  metaData.getObjPtr(i)))
+      {
+	ndbout_c("Restore: Failed to restore table: %s. "
+		 "Exiting...", 
+		 metaData[i]->getTableName());
+	exitHandler(NDBT_FAILED);
+      } 
+  }
+  
   for(i = 0; i<metaData.getNoOfTables(); i++)
   {
     if (checkSysTable(metaData[i]->getTableName()))

--- 1.45/storage/ndb/src/ndbapi/NdbDictionary.cpp	2006-01-04 11:45:45 +01:00
+++ 1.46/storage/ndb/src/ndbapi/NdbDictionary.cpp	2006-01-09 14:28:16 +01:00
@@ -466,6 +466,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::Table::getObjectId() const {
+  return m_impl.m_id;
+}
+
 bool
 NdbDictionary::Table::equal(const NdbDictionary::Table & col) const {
   return m_impl.equal(col.m_impl);
@@ -497,6 +502,12 @@
   return pNdb->getDictionary()->createTable(* this);
 }
 
+Uint32
+NdbDictionary::Table::getTablespaceId() const 
+{
+  return m_impl.m_tablespace_id;
+}
+
 void 
 NdbDictionary::Table::setTablespace(const char * name){
   m_impl.m_tablespace_id = ~0;
@@ -665,6 +676,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::Index::getObjectId() const {
+  return m_impl.m_id;
+}
+
 
 /*****************************************************************
  * Event facade
@@ -787,6 +803,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::Event::getObjectId() const {
+  return m_impl.m_id;
+}
+
 void NdbDictionary::Event::print()
 {
   m_impl.print();
@@ -805,6 +826,12 @@
 {
 }
 
+NdbDictionary::Tablespace::Tablespace(const NdbDictionary::Tablespace & org)
+  : Object(org), m_impl(* new NdbTablespaceImpl(* this))
+{
+  m_impl.assign(org.m_impl);
+}
+
 NdbDictionary::Tablespace::~Tablespace(){
   NdbTablespaceImpl * tmp = &m_impl;  
   if(this != tmp){
@@ -862,6 +889,11 @@
   return m_impl.m_logfile_group_name.c_str();
 }
 
+Uint32
+NdbDictionary::Tablespace::getDefaultLogfileGroupId() const {
+  return m_impl.m_logfile_group_id;
+}
+
 NdbDictionary::Object::Status
 NdbDictionary::Tablespace::getObjectStatus() const {
   return m_impl.m_status;
@@ -872,6 +904,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::Tablespace::getObjectId() const {
+  return m_impl.m_id;
+}
+
 /*****************************************************************
  * LogfileGroup facade
  */
@@ -885,6 +922,12 @@
 {
 }
 
+NdbDictionary::LogfileGroup::LogfileGroup(const NdbDictionary::LogfileGroup & org)
+  : Object(org), m_impl(* new NdbLogfileGroupImpl(* this)) 
+{
+  m_impl.assign(org.m_impl);
+}
+
 NdbDictionary::LogfileGroup::~LogfileGroup(){
   NdbLogfileGroupImpl * tmp = &m_impl;  
   if(this != tmp){
@@ -936,6 +979,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::LogfileGroup::getObjectId() const {
+  return m_impl.m_id;
+}
+
 /*****************************************************************
  * Datafile facade
  */
@@ -949,6 +997,12 @@
 {
 }
 
+NdbDictionary::Datafile::Datafile(const NdbDictionary::Datafile & org)
+  : Object(org), m_impl(* new NdbDatafileImpl(* this)) 
+{
+  m_impl.assign(org.m_impl);
+}
+
 NdbDictionary::Datafile::~Datafile(){
   NdbDatafileImpl * tmp = &m_impl;  
   if(this != tmp){
@@ -1000,6 +1054,11 @@
   return m_impl.m_filegroup_name.c_str();
 }
 
+Uint32
+NdbDictionary::Datafile::getTablespaceId() const {
+  return m_impl.m_filegroup_id;
+}
+
 NdbDictionary::Object::Status
 NdbDictionary::Datafile::getObjectStatus() const {
   return m_impl.m_status;
@@ -1010,6 +1069,11 @@
   return m_impl.m_version;
 }
 
+int 
+NdbDictionary::Datafile::getObjectId() const {
+  return m_impl.m_id;
+}
+
 /*****************************************************************
  * Undofile facade
  */
@@ -1023,6 +1087,12 @@
 {
 }
 
+NdbDictionary::Undofile::Undofile(const NdbDictionary::Undofile & org)
+  : Object(org), m_impl(* new NdbUndofileImpl(* this))
+{
+  m_impl.assign(org.m_impl);
+}
+
 NdbDictionary::Undofile::~Undofile(){
   NdbUndofileImpl * tmp = &m_impl;  
   if(this != tmp){
@@ -1070,6 +1140,11 @@
   return m_impl.m_filegroup_name.c_str();
 }
 
+Uint32
+NdbDictionary::Undofile::getLogfileGroupId() const {
+  return m_impl.m_filegroup_id;
+}
+
 NdbDictionary::Object::Status
 NdbDictionary::Undofile::getObjectStatus() const {
   return m_impl.m_status;
@@ -1078,6 +1153,11 @@
 int 
 NdbDictionary::Undofile::getObjectVersion() const {
   return m_impl.m_version;
+}
+
+int 
+NdbDictionary::Undofile::getObjectId() const {
+  return m_impl.m_id;
 }
 
 /*****************************************************************

--- 1.98/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-01-04 11:45:45 +01:00
+++ 1.99/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-01-09 14:28:16 +01:00
@@ -3431,6 +3431,24 @@
 NdbTablespaceImpl::~NdbTablespaceImpl(){
 }
 
+void
+NdbTablespaceImpl::assign(const NdbTablespaceImpl& org)
+{
+  m_id = org.m_id;
+  m_version = org.m_version;
+  m_status = org.m_status;
+  m_type = org.m_type;
+
+  m_name.assign(org.m_name);
+  m_grow_spec = org.m_grow_spec;
+  m_extent_size = org.m_extent_size;
+  m_undo_free_words = org.m_undo_free_words;
+  m_logfile_group_id = org.m_logfile_group_id;
+  m_logfile_group_version = org.m_logfile_group_version;
+  m_logfile_group_name.assign(org.m_logfile_group_name);
+  m_undo_free_words = org.m_undo_free_words;
+}
+
 NdbLogfileGroupImpl::NdbLogfileGroupImpl() : 
   NdbDictionary::LogfileGroup(* this), 
   NdbFilegroupImpl(NdbDictionary::Object::LogfileGroup), m_facade(this)
@@ -3446,6 +3464,24 @@
 NdbLogfileGroupImpl::~NdbLogfileGroupImpl(){
 }
 
+void
+NdbLogfileGroupImpl::assign(const NdbLogfileGroupImpl& org)
+{
+  m_id = org.m_id;
+  m_version = org.m_version;
+  m_status = org.m_status;
+  m_type = org.m_type;
+
+  m_name.assign(org.m_name);
+  m_grow_spec = org.m_grow_spec;
+  m_extent_size = org.m_extent_size;
+  m_undo_free_words = org.m_undo_free_words;
+  m_logfile_group_id = org.m_logfile_group_id;
+  m_logfile_group_version = org.m_logfile_group_version;
+  m_logfile_group_name.assign(org.m_logfile_group_name);
+  m_undo_free_words = org.m_undo_free_words;
+}
+
 NdbFileImpl::NdbFileImpl(NdbDictionary::Object::Type t)
   : NdbDictObjectImpl(t)
 {
@@ -3470,6 +3506,22 @@
 NdbDatafileImpl::~NdbDatafileImpl(){
 }
 
+void
+NdbDatafileImpl::assign(const NdbDatafileImpl& org)
+{
+  m_id = org.m_id;
+  m_version = org.m_version;
+  m_status = org.m_status;
+  m_type = org.m_type;
+
+  m_size = org.m_size;
+  m_free = org.m_free;
+  m_filegroup_id = org.m_filegroup_id;
+  m_filegroup_version = org.m_filegroup_version;
+  m_path.assign(org.m_path);
+  m_filegroup_name.assign(org.m_filegroup_name);
+}
+
 NdbUndofileImpl::NdbUndofileImpl() : 
   NdbDictionary::Undofile(* this), 
   NdbFileImpl(NdbDictionary::Object::Undofile), m_facade(this)
@@ -3485,6 +3537,22 @@
 NdbUndofileImpl::~NdbUndofileImpl(){
 }
 
+void
+NdbUndofileImpl::assign(const NdbUndofileImpl& org)
+{
+  m_id = org.m_id;
+  m_version = org.m_version;
+  m_status = org.m_status;
+  m_type = org.m_type;
+
+  m_size = org.m_size;
+  m_free = org.m_free;
+  m_filegroup_id = org.m_filegroup_id;
+  m_filegroup_version = org.m_filegroup_version;
+  m_path.assign(org.m_path);
+  m_filegroup_name.assign(org.m_filegroup_name);
+}
+
 int 
 NdbDictionaryImpl::createDatafile(const NdbDatafileImpl & file, bool force){
   DBUG_ENTER("NdbDictionaryImpl::createDatafile");
@@ -3842,6 +3910,16 @@
                          m_error.code));
     DBUG_RETURN(m_error.code);
   }
+
+  if(dst.m_type == NdbDictionary::Object::Tablespace)
+  {
+    NdbDictionary::LogfileGroup tmp;
+    get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
+		  NdbDictionary::Object::LogfileGroup,
+		  dst.m_logfile_group_id);
+    dst.m_logfile_group_name.assign(tmp.getName());
+  }
+  
   if(dst.m_type == type)
   {
     DBUG_RETURN(0);
@@ -3881,14 +3959,6 @@
   dst.m_undo_free_words= ((Uint64)fg.LF_UndoFreeWordsHi << 32)
     | (fg.LF_UndoFreeWordsLo);
 
-  if(dst.m_type==NdbDictionary::Object::Tablespace)
-  {
-    NdbDictionary::LogfileGroup tmp;
-    get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
-		  NdbDictionary::Object::LogfileGroup,
-		  dst.m_logfile_group_id);
-    dst.m_logfile_group_name.assign(tmp.getName());
-  }
   return 0;
 }
 
@@ -3983,6 +4053,26 @@
     DBUG_RETURN(m_error.code);
   }
 
+  if(dst.m_type == NdbDictionary::Object::Undofile)
+  {
+    NdbDictionary::LogfileGroup tmp;
+    get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
+		  NdbDictionary::Object::LogfileGroup,
+		  dst.m_filegroup_id);
+    dst.m_filegroup_name.assign(tmp.getName());
+  }
+  else if(dst.m_type == NdbDictionary::Object::Datafile)
+  {
+    NdbDictionary::Tablespace tmp;
+    get_filegroup(NdbTablespaceImpl::getImpl(tmp),
+		  NdbDictionary::Object::Tablespace,
+		  dst.m_filegroup_id);
+    dst.m_filegroup_name.assign(tmp.getName());
+    dst.m_free *= tmp.getExtentSize();
+  }
+  else
+    dst.m_filegroup_name.assign("Not Yet Implemented");
+  
   if(dst.m_type == type)
   {
     DBUG_RETURN(0);
@@ -4014,29 +4104,9 @@
   dst.m_size= ((Uint64)f.FileSizeHi << 32) | (f.FileSizeLo);
   dst.m_path.assign(f.FileName);
 
-  if(dst.m_type==NdbDictionary::Object::Undofile)
-  {
-    NdbDictionary::LogfileGroup tmp;
-    get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
-		  NdbDictionary::Object::LogfileGroup,
-		  f.FilegroupId);
-    dst.m_filegroup_name.assign(tmp.getName());
-  }
-  else if(dst.m_type==NdbDictionary::Object::Datafile)
-  {
-    NdbDictionary::Tablespace tmp;
-    get_filegroup(NdbTablespaceImpl::getImpl(tmp),
-		  NdbDictionary::Object::Tablespace,
-		  f.FilegroupId);
-    dst.m_filegroup_name.assign(tmp.getName());
-    dst.m_free= f.FileFreeExtents * tmp.getExtentSize();
-  }
-  else
-    dst.m_filegroup_name.assign("Not Yet Implemented");
-
   dst.m_filegroup_id= f.FilegroupId;
   dst.m_filegroup_version= f.FilegroupVersion;
-
+  dst.m_free=  f.FileFreeExtents;
   return 0;
 }
 

--- 1.39/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-01-04 11:45:45 +01:00
+++ 1.40/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-01-09 14:28:16 +01:00
@@ -304,6 +304,8 @@
   NdbTablespaceImpl(NdbDictionary::Tablespace &);
   ~NdbTablespaceImpl();
 
+  void assign(const NdbTablespaceImpl&);
+
   static NdbTablespaceImpl & getImpl(NdbDictionary::Tablespace & t);
   static const NdbTablespaceImpl & getImpl(const NdbDictionary::Tablespace &);
   NdbDictionary::Tablespace * m_facade;
@@ -316,6 +318,8 @@
   NdbLogfileGroupImpl(NdbDictionary::LogfileGroup &);
   ~NdbLogfileGroupImpl();
 
+  void assign(const NdbLogfileGroupImpl&);
+
   static NdbLogfileGroupImpl & getImpl(NdbDictionary::LogfileGroup & t);
   static const NdbLogfileGroupImpl& getImpl(const 
 					    NdbDictionary::LogfileGroup&);
@@ -339,6 +343,8 @@
   NdbDatafileImpl(NdbDictionary::Datafile &);
   ~NdbDatafileImpl();
 
+  void assign(const NdbDatafileImpl&);
+
   static NdbDatafileImpl & getImpl(NdbDictionary::Datafile & t);
   static const NdbDatafileImpl & getImpl(const NdbDictionary::Datafile & t);
   NdbDictionary::Datafile * m_facade;
@@ -350,6 +356,8 @@
   NdbUndofileImpl(NdbDictionary::Undofile &);
   ~NdbUndofileImpl();
 
+  void assign(const NdbUndofileImpl&);
+
   static NdbUndofileImpl & getImpl(NdbDictionary::Undofile & t);
   static const NdbUndofileImpl & getImpl(const NdbDictionary::Undofile & t);
   NdbDictionary::Undofile * m_facade;
@@ -405,12 +413,12 @@
 			    const Uint32 * data, Uint32 len,
 			    bool fullyQualifiedNames);
 
-  int parseFileInfo(NdbFileImpl &dst,
-		    const Uint32 * data, Uint32 len);
-
-  int parseFilegroupInfo(NdbFilegroupImpl &dst,
-			 const Uint32 * data, Uint32 len);
+  static int parseFileInfo(NdbFileImpl &dst,
+			   const Uint32 * data, Uint32 len);
 
+  static int parseFilegroupInfo(NdbFilegroupImpl &dst,
+				const Uint32 * data, Uint32 len);
+  
   int create_file(const NdbFileImpl &, const NdbFilegroupImpl&, bool overwrite = false);
   int drop_file(const NdbFileImpl &);
   int create_filegroup(const NdbFilegroupImpl &);

--- 1.6/storage/ndb/tools/restore/consumer.hpp	2005-04-08 02:44:35 +02:00
+++ 1.7/storage/ndb/tools/restore/consumer.hpp	2006-01-09 14:28:16 +01:00
@@ -23,6 +23,7 @@
 public:
   virtual ~BackupConsumer() { }
   virtual bool init() { return true;}
+  virtual bool object(Uint32 tableType, const void*) { return true;}
   virtual bool table(const TableS &){return true;}
   virtual bool endOfTables() { return true; }
   virtual void tuple(const TupleS &){}

--- 1.21/storage/ndb/tools/restore/consumer_restore.cpp	2005-11-07 12:19:10 +01:00
+++ 1.22/storage/ndb/tools/restore/consumer_restore.cpp	2006-01-09 14:28:16 +01:00
@@ -152,6 +152,141 @@
   return ret;
 }
 
+#include <signaldata/DictTabInfo.hpp>
+
+bool
+BackupRestore::object(Uint32 type, const void * ptr)
+{
+  if (!m_restore_meta)
+    return true;
+  
+  NdbDictionary::Dictionary* dict = m_ndb->getDictionary();
+  switch(type){
+  case DictTabInfo::Tablespace:
+  {
+    NdbDictionary::Tablespace old(*(NdbDictionary::Tablespace*)ptr);
+
+    Uint32 id = old.getObjectId();
+
+    if (!m_no_restore_disk)
+    {
+      NdbDictionary::LogfileGroup * lg = m_logfilegroups[old.getDefaultLogfileGroupId()];
+      old.setDefaultLogfileGroup(* lg);
+      int ret = dict->createTablespace(old);
+      if (ret)
+      {
+	NdbError errobj= dict->getNdbError();
+	err << "Failed to create tablespace \"" << old.getName() << "\": "
+	    << errobj << endl;
+	return false;
+      }
+      debug << "Created tablespace: " << old.getName() << endl;
+    }
+    
+    NdbDictionary::Tablespace curr = dict->getTablespace(old.getName());
+    NdbError errobj = dict->getNdbError();
+    if(errobj.classification == ndberror_cl_none)
+    {
+      NdbDictionary::Tablespace* currptr = new NdbDictionary::Tablespace(curr);
+      NdbDictionary::Tablespace * null = 0;
+      m_tablespaces.set(currptr, id, null);
+      debug << "Retreived tablspace: " << currptr->getName() 
+	    << " oldid: " << id << " newid: " << currptr->getObjectId() 
+	    << " " << (void*)currptr << endl;
+      return true;
+    }
+    
+    err << "Failed to retrieve tablespace \"" << old.getName() << "\": "
+	<< errobj << endl;
+    
+    return false;
+    break;
+  }
+  case DictTabInfo::LogfileGroup:
+  {
+    NdbDictionary::LogfileGroup old(*(NdbDictionary::LogfileGroup*)ptr);
+    
+    Uint32 id = old.getObjectId();
+    
+    if (!m_no_restore_disk)
+    {
+      int ret = dict->createLogfileGroup(old);
+      if (ret)
+      {
+	NdbError errobj= dict->getNdbError();
+	err << "Failed to create logfile group \"" << old.getName() << "\": "
+	    << errobj << endl;
+	return false;
+      }
+      debug << "Created logfile group: " << old.getName() << endl;
+    }
+    
+    NdbDictionary::LogfileGroup curr = dict->getLogfileGroup(old.getName());
+    NdbError errobj = dict->getNdbError();
+    if(errobj.classification == ndberror_cl_none)
+    {
+      NdbDictionary::LogfileGroup* currptr = 
+	new NdbDictionary::LogfileGroup(curr);
+      NdbDictionary::LogfileGroup * null = 0;
+      m_logfilegroups.set(currptr, id, null);
+      debug << "Retreived logfile group: " << currptr->getName() 
+	    << " oldid: " << id << " newid: " << currptr->getObjectId() 
+	    << " " << (void*)currptr << endl;
+      return true;
+    }
+    
+    err << "Failed to retrieve logfile group \"" << old.getName() << "\": "
+	<< errobj << endl;
+    
+    return false;
+    break;
+  }
+  case DictTabInfo::Datafile:
+  {
+    if (!m_no_restore_disk)
+    {
+      NdbDictionary::Datafile old(*(NdbDictionary::Datafile*)ptr);
+      NdbDictionary::Tablespace * ts = m_tablespaces[old.getTablespaceId()];
+      debug << "Connecting datafile " << old.getPath() 
+	    << " to tablespace: oldid: " << old.getTablespaceId() 
+	    << " newid: " << ts->getObjectId() << endl;
+      old.setTablespace(* ts);
+      if (dict->createDatafile(old))
+      {
+	err << "Failed to create datafile \"" << old.getPath() << "\": "
+	    << dict->getNdbError() << endl;
+	return false;
+      }
+    }
+    return true;
+    break;
+  }
+  case DictTabInfo::Undofile:
+  {
+    if (!m_no_restore_disk)
+    {
+      NdbDictionary::Undofile old(*(NdbDictionary::Undofile*)ptr);
+      NdbDictionary::LogfileGroup * lg = 
+	m_logfilegroups[old.getLogfileGroupId()];
+      debug << "Connecting undofile " << old.getPath() 
+	    << " to logfile group: oldid: " << old.getLogfileGroupId() 
+	    << " newid: " << lg->getObjectId() 
+	    << " " << (void*)lg << endl;
+      old.setLogfileGroup(* lg);
+      if (dict->createUndofile(old))
+      {
+	err << "Failed to create undofile \"" << old.getPath() << "\": "
+	    << dict->getNdbError() << endl;
+	return false;
+      }
+    }
+    return true;
+    break;
+  }
+  }
+  return true;
+}
+
 bool
 BackupRestore::table(const TableS & table){
   if (!m_restore && !m_restore_meta)
@@ -186,7 +321,15 @@
     NdbDictionary::Table copy(*table.m_dictTable);
 
     copy.setName(split[2].c_str());
-
+    if (copy.getTablespaceId() != RNIL)
+    {
+      Uint32 id = copy.getTablespaceId();
+      debug << "Connecting " << name << " to tablespace oldid: " << id << flush;
+      NdbDictionary::Tablespace* ts = m_tablespaces[copy.getTablespaceId()];
+      debug << " newid: " << ts->getObjectId() << endl;
+      copy.setTablespace(* ts);
+    }
+    
     if (dict->createTable(copy) == -1) 
     {
       err << "Create table " << table.getTableName() << " failed: "
@@ -713,3 +856,5 @@
 
 template class Vector<NdbDictionary::Table*>;
 template class Vector<const NdbDictionary::Table*>;
+template class Vector<NdbDictionary::Tablespace*>;
+template class Vector<NdbDictionary::LogfileGroup*>;

--- 1.10/storage/ndb/tools/restore/consumer_restore.hpp	2005-04-08 02:44:36 +02:00
+++ 1.11/storage/ndb/tools/restore/consumer_restore.hpp	2006-01-09 14:28:16 +01:00
@@ -39,6 +39,7 @@
     m_logCount = m_dataCount = 0;
     m_restore = false;
     m_restore_meta = false;
+    m_no_restore_disk = false;
     m_parallelism = parallelism;
     m_callback = 0;
     m_free_callback = 0;
@@ -49,6 +50,7 @@
   virtual ~BackupRestore();
   virtual bool init();
   virtual void release();
+  virtual bool object(Uint32 type, const void* ptr);
   virtual bool table(const TableS &);
   virtual bool endOfTables();
   virtual void tuple(const TupleS &);
@@ -66,6 +68,7 @@
   Ndb_cluster_connection * m_cluster_connection;
   bool m_restore;
   bool m_restore_meta;
+  bool m_no_restore_disk;
   Uint32 m_logCount;
   Uint32 m_dataCount;
 
@@ -88,6 +91,8 @@
   const NdbDictionary::Table* get_table(const NdbDictionary::Table* );
 
   Vector<const NdbDictionary::Table*> m_indexes;
+  Vector<NdbDictionary::Tablespace*> m_tablespaces;    // Index by id
+  Vector<NdbDictionary::LogfileGroup*> m_logfilegroups;// Index by id
 };
 
 #endif
Thread
bk commit into 5.1 tree (jonas:1.1989)jonas9 Jan