diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2006-06-27 11:22:42 +0200 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2006-06-27 11:22:42 +0200 |
commit | 6848be9cc2de93a840352db953ef9d88b600c01d (patch) | |
tree | 6996a3c97fd5e7cd58e54c130547fe0dc451a05d /storage/ndb/tools | |
parent | 98ba03d22653612d7da73696de6df0b137e21182 (diff) | |
parent | 0335013f17743299cf32731e1db986170672acbe (diff) | |
download | mariadb-git-6848be9cc2de93a840352db953ef9d88b600c01d.tar.gz |
Merge poseidon.ndb.mysql.com:/home/tomas/mysql-5.0-main
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
mysql-test/mysql-test-run.sh:
Auto merged
storage/ndb/include/kernel/signaldata/BackupContinueB.hpp:
Auto merged
storage/ndb/include/kernel/signaldata/BackupImpl.hpp:
Auto merged
storage/ndb/include/kernel/signaldata/BackupSignalData.hpp:
Auto merged
storage/ndb/include/ndbapi/NdbDictionary.hpp:
Auto merged
storage/ndb/src/common/debugger/signaldata/BackupImpl.cpp:
Auto merged
storage/ndb/src/common/debugger/signaldata/BackupSignalData.cpp:
Auto merged
storage/ndb/src/common/debugger/signaldata/LqhFrag.cpp:
Auto merged
storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp:
Auto merged
storage/ndb/src/kernel/blocks/backup/BackupInit.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dbtup/DbtupPageMap.cpp:
Auto merged
storage/ndb/src/mgmsrv/MgmtSrvr.cpp:
Auto merged
storage/ndb/src/mgmsrv/MgmtSrvr.hpp:
Auto merged
sql/ha_ndbcluster.cc:
manual merge
storage/ndb/include/kernel/GlobalSignalNumbers.h:
manual merge
storage/ndb/include/kernel/signaldata/DictTabInfo.hpp:
manual merge
storage/ndb/include/kernel/signaldata/LqhFrag.hpp:
manual merge
storage/ndb/include/kernel/signaldata/TupFrag.hpp:
manual merge
storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp:
manual merge
storage/ndb/src/kernel/blocks/backup/Backup.cpp:
manual merge
storage/ndb/src/kernel/blocks/backup/Backup.hpp:
manual merge
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
manual merge
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
manual merge
storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp:
manual merge
storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp:
manual merge
storage/ndb/src/kernel/blocks/dbtup/Dbtup.hpp:
manual merge
storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp:
manual merge
storage/ndb/src/ndbapi/NdbDictionary.cpp:
manual merge
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
manual merge
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp:
manual merge
storage/ndb/tools/restore/Restore.cpp:
manual merge
storage/ndb/tools/restore/Restore.hpp:
manual merge
storage/ndb/tools/restore/consumer_restore.cpp:
manual merge
Diffstat (limited to 'storage/ndb/tools')
-rw-r--r-- | storage/ndb/tools/restore/Restore.cpp | 58 | ||||
-rw-r--r-- | storage/ndb/tools/restore/Restore.hpp | 15 | ||||
-rw-r--r-- | storage/ndb/tools/restore/consumer_restore.cpp | 10 |
3 files changed, 82 insertions, 1 deletions
diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp index 7762785ef61..ef535cf9e26 100644 --- a/storage/ndb/tools/restore/Restore.cpp +++ b/storage/ndb/tools/restore/Restore.cpp @@ -85,7 +85,12 @@ RestoreMetaData::RestoreMetaData(const char* path, Uint32 nodeId, Uint32 bNo) { RestoreMetaData::~RestoreMetaData(){ for(Uint32 i= 0; i < allTables.size(); i++) - delete allTables[i]; + { + TableS *table = allTables[i]; + for(Uint32 j= 0; j < table->m_fragmentInfo.size(); j++) + delete table->m_fragmentInfo[j]; + delete table; + } allTables.clear(); } @@ -118,6 +123,9 @@ RestoreMetaData::loadContent() return 0; if(!readGCPEntry()) return 0; + + if(!readFragmentInfo()) + return 0; return 1; } @@ -353,6 +361,52 @@ RestoreMetaData::readGCPEntry() { return true; } +bool +RestoreMetaData::readFragmentInfo() +{ + BackupFormat::CtlFile::FragmentInfo fragInfo; + TableS * table = 0; + Uint32 tableId = RNIL; + + while (buffer_read(&fragInfo, 4, 2) == 2) + { + fragInfo.SectionType = ntohl(fragInfo.SectionType); + fragInfo.SectionLength = ntohl(fragInfo.SectionLength); + + if (fragInfo.SectionType != BackupFormat::FRAGMENT_INFO) + { + err << "readFragmentInfo invalid section type: " << + fragInfo.SectionType << endl; + return false; + } + + if (buffer_read(&fragInfo.TableId, (fragInfo.SectionLength-2)*4, 1) != 1) + { + err << "readFragmentInfo invalid section length: " << + fragInfo.SectionLength << endl; + return false; + } + + fragInfo.TableId = ntohl(fragInfo.TableId); + if (fragInfo.TableId != tableId) + { + tableId = fragInfo.TableId; + table = getTable(tableId); + } + + FragmentInfo * tmp = new FragmentInfo; + tmp->fragmentNo = ntohl(fragInfo.FragmentNo); + tmp->noOfRecords = ntohl(fragInfo.NoOfRecordsLow) + + (((Uint64)ntohl(fragInfo.NoOfRecordsHigh)) << 32); + tmp->filePosLow = ntohl(fragInfo.FilePosLow); + tmp->filePosHigh = ntohl(fragInfo.FilePosHigh); + + table->m_fragmentInfo.push_back(tmp); + table->m_noOfRecords += tmp->noOfRecords; + } + return true; +} + TableS::TableS(Uint32 version, NdbTableImpl* tableImpl) : m_dictTable(tableImpl) { @@ -360,6 +414,7 @@ TableS::TableS(Uint32 version, NdbTableImpl* tableImpl) m_noOfNullable = m_nullBitmaskSize = 0; m_auto_val_id= ~(Uint32)0; m_max_auto_val= 0; + m_noOfRecords= 0; backupVersion = version; isSysTable = false; @@ -1161,4 +1216,5 @@ operator<<(NdbOut& ndbout, const TableS & table){ template class Vector<TableS*>; template class Vector<AttributeS*>; template class Vector<AttributeDesc*>; +template class Vector<FragmentInfo*>; template class Vector<DictObject>; diff --git a/storage/ndb/tools/restore/Restore.hpp b/storage/ndb/tools/restore/Restore.hpp index 8698d0943e2..e824f1bbdc0 100644 --- a/storage/ndb/tools/restore/Restore.hpp +++ b/storage/ndb/tools/restore/Restore.hpp @@ -114,6 +114,14 @@ public: AttributeData * getData(int i) const; }; // class TupleS +struct FragmentInfo +{ + Uint32 fragmentNo; + Uint64 noOfRecords; + Uint32 filePosLow; + Uint32 filePosHigh; +}; + class TableS { friend class TupleS; @@ -136,6 +144,9 @@ class TableS { bool isSysTable; + Uint64 m_noOfRecords; + Vector<FragmentInfo *> m_fragmentInfo; + void createAttr(NdbDictionary::Column *column); public: @@ -146,6 +157,9 @@ public: Uint32 getTableId() const { return m_dictTable->getTableId(); } + Uint32 getNoOfRecords() const { + return m_noOfRecords; + } /* void setMysqlTableName(char * tableName) { strpcpy(mysqlTableName, tableName); @@ -286,6 +300,7 @@ class RestoreMetaData : public BackupFile { bool markSysTables(); bool readGCPEntry(); + bool readFragmentInfo(); Uint32 readMetaTableList(); Uint32 m_startGCP; diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index 6b0d42ee0d2..b6a5728b0c4 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -709,6 +709,16 @@ BackupRestore::table(const TableS & table){ copy.setFragmentData((const void *)ng_array, no_parts << 1); } + /* + update min and max rows to reflect the table, this to + ensure that memory is allocated properly in the ndb kernel + */ + copy.setMinRows(table.getNoOfRecords()); + if (table.getNoOfRecords() > copy.getMaxRows()) + { + copy.setMaxRows(table.getNoOfRecords()); + } + if (dict->createTable(copy) == -1) { err << "Create table " << table.getTableName() << " failed: " |