Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-03-26 10:01:43+02:00, tomas@stripped +1 -0
Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
into whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
MERGE: 1.1810.2374.93
storage/ndb/tools/restore/Restore.cpp@stripped, 2007-03-26 10:01:41+02:00, tomas@stripped +0 -5
manual merge
MERGE: 1.22.11.2
storage/ndb/tools/restore/Restore.cpp@stripped, 2007-03-26 09:58:32+02:00, tomas@stripped +0 -0
Merge rename: ndb/tools/restore/Restore.cpp -> storage/ndb/tools/restore/Restore.cpp
# 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: tomas
# Host: whalegate.ndb.mysql.com
# Root: /home/tomas/mysql-5.1-new-ndb/RESYNC
--- 1.22.11.1/ndb/tools/restore/Restore.cpp 2007-03-26 09:57:59 +02:00
+++ 1.50/storage/ndb/tools/restore/Restore.cpp 2007-03-26 10:01:41 +02:00
@@ -15,6 +15,7 @@
#include "Restore.hpp"
#include <NdbTCP.h>
+#include <NdbMem.h>
#include <OutputStream.hpp>
#include <Bitmask.hpp>
@@ -22,7 +23,10 @@
#include <trigger_definitions.h>
#include <SimpleProperties.hpp>
#include <signaldata/DictTabInfo.hpp>
+#include <ndb_limits.h>
+#include <NdbAutoPtr.hpp>
+#include "../../../../sql/ha_ndbcluster_tables.h"
extern NdbRecordPrintFormat g_ndbrecord_print_format;
Uint16 Twiddle16(Uint16 in); // Byte shift 16-bit data
@@ -156,27 +160,137 @@
bool
RestoreMetaData::readMetaTableDesc() {
- Uint32 sectionInfo[2];
+ Uint32 sectionInfo[3];
// Read section header
- if (buffer_read(§ionInfo, 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(§ionInfo, 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
@@ -191,7 +305,18 @@
strcmp(tableName, "SYSTAB_0") == 0 ||
strcmp(tableName, "NDB$EVENTS_0") == 0 ||
strcmp(tableName, "sys/def/SYSTAB_0") == 0 ||
- strcmp(tableName, "sys/def/NDB$EVENTS_0") == 0)
+ strcmp(tableName, "sys/def/NDB$EVENTS_0") == 0 ||
+ /*
+ The following is for old MySQL versions,
+ before we changed the database name of the tables from
+ "cluster_replication" -> "cluster" -> "mysql"
+ */
+ strcmp(tableName, "cluster_replication/def/" OLD_NDB_APPLY_TABLE) == 0 ||
+ strcmp(tableName, OLD_NDB_REP_DB "/def/" OLD_NDB_APPLY_TABLE) == 0 ||
+ strcmp(tableName, OLD_NDB_REP_DB "/def/" OLD_NDB_SCHEMA_TABLE) == 0 ||
+ strcmp(tableName, NDB_REP_DB "/def/" NDB_APPLY_TABLE) == 0 ||
+ strcmp(tableName, NDB_REP_DB "/def/" NDB_SCHEMA_TABLE)== 0 )
+
table->isSysTable = true;
}
for (i = 0; i < getNoOfTables(); i++) {
@@ -319,13 +444,15 @@
delete allAttributesDesc[i];
}
+
// Parse dictTabInfo buffer and pushback to to vector storage
bool
RestoreMetaData::parseTableDescriptor(const Uint32 * data, Uint32 len)
{
NdbTableImpl* tableImpl = 0;
- int ret = NdbDictInterface::parseTableInfo(&tableImpl, data, len, false);
-
+ int ret = NdbDictInterface::parseTableInfo(&tableImpl, data, len, false,
+ m_fileHeader.NdbVersion);
+
if (ret != 0) {
err << "parseTableInfo " << " failed" << endl;
return false;
@@ -334,7 +461,6 @@
return false;
debug << "parseTableInfo " << tableImpl->getName() << " done" << endl;
-
TableS * table = new TableS(m_fileHeader.NdbVersion, tableImpl);
if(table == NULL) {
return false;
@@ -438,7 +564,9 @@
res = -1;
return NULL;
}
-
+
+ //if (m_currentTable->getTableId() >= 2) { for (uint ii=0; ii<dataLenBytes; ii+=4) ndbout << "*" << hex << *(Uint32*)( (char*)_buf_ptr+ii ); ndbout << endl; }
+
Uint32 *buf_ptr = (Uint32*)_buf_ptr, *ptr = buf_ptr;
ptr += m_currentTable->m_nullBitmaskSize;
Uint32 i;
@@ -478,6 +606,8 @@
attr_data->void_value = ptr;
attr_data->size = 4*sz;
+ //if (m_currentTable->getTableId() >= 2) { ndbout << "fix i=" << i << " off=" << ptr-buf_ptr << " attrId=" << attrId << endl; }
+
if(!Twiddle(attr_desc, attr_data))
{
res = -1;
@@ -487,13 +617,28 @@
ptr += sz;
}
+ // init to NULL
for(i = 0; i < m_currentTable->m_variableAttribs.size(); i++){
const Uint32 attrId = m_currentTable->m_variableAttribs[i]->attrId;
AttributeData * attr_data = m_tuple.getData(attrId);
+
+ attr_data->null = true;
+ attr_data->void_value = NULL;
+ }
+
+ while (ptr + 2 < buf_ptr + dataLength) {
+ typedef BackupFormat::DataFile::VariableData VarData;
+ VarData * data = (VarData *)ptr;
+ Uint32 sz = ntohl(data->Sz);
+ Uint32 attrId = ntohl(data->Id); // column_no
+
+ AttributeData * attr_data = m_tuple.getData(attrId);
const AttributeDesc * attr_desc = m_tuple.getDesc(attrId);
- if(attr_desc->m_column->getNullable()){
+ // just a reminder - remove when backwards compat implemented
+ if(m_currentTable->backupVersion < MAKE_VERSION(5,1,3) &&
+ attr_desc->m_column->getNullable()){
const Uint32 ind = attr_desc->m_nullBitIndex;
if(BitmaskImpl::get(m_currentTable->m_nullBitmaskSize,
buf_ptr,ind)){
@@ -503,32 +648,33 @@
}
}
- assert(ptr < buf_ptr + dataLength);
-
- typedef BackupFormat::DataFile::VariableData VarData;
- VarData * data = (VarData *)ptr;
- Uint32 sz = ntohl(data->Sz);
- Uint32 id = ntohl(data->Id);
- assert(id == attrId);
+ if (m_currentTable->backupVersion < MAKE_VERSION(5,1,3))
+ {
+ sz *= 4;
+ }
attr_data->null = false;
attr_data->void_value = &data->Data[0];
- attr_data->size = sz*4;
+ attr_data->size = sz;
+
+ //if (m_currentTable->getTableId() >= 2) { ndbout << "var off=" << ptr-buf_ptr << " attrId=" << attrId << endl; }
/**
* Compute array size
*/
- const Uint32 arraySize = (4 * sz) / (attr_desc->size / 8);
- assert(arraySize >= attr_desc->arraySize);
+ const Uint32 arraySize = sz / (attr_desc->size / 8);
+ assert(arraySize <= attr_desc->arraySize);
if(!Twiddle(attr_desc, attr_data, attr_desc->arraySize))
{
res = -1;
return NULL;
}
-
- ptr += (sz + 2);
+
+ ptr += ((sz + 3) >> 2) + 2;
}
+ assert(ptr == buf_ptr + dataLength);
+
m_count ++;
res = 0;
return &m_tuple;
@@ -721,7 +867,7 @@
return true;
}
-bool RestoreDataIterator::readFragmentHeader(int & ret)
+bool RestoreDataIterator::readFragmentHeader(int & ret, Uint32 *fragmentId)
{
BackupFormat::DataFile::FragmentHeader Header;
@@ -764,7 +910,7 @@
m_count = 0;
ret = 0;
-
+ *fragmentId = Header.FragmentNo;
return true;
} // RestoreDataIterator::getNextFragment
@@ -817,16 +963,20 @@
return;
}
- if(!d->m_column->getNullable())
+ if (d->m_column->getArrayType() == NDB_ARRAYTYPE_FIXED &&
+ ! d->m_column->getNullable())
{
m_fixedAttribs.push_back(d);
return;
}
- /* Nullable attr*/
- d->m_nullBitIndex = m_noOfNullable;
- m_noOfNullable++;
- m_nullBitmaskSize = (m_noOfNullable + 31) / 32;
+ // just a reminder - does not solve backwards compat
+ if (backupVersion < MAKE_VERSION(5,1,3))
+ {
+ d->m_nullBitIndex = m_noOfNullable;
+ m_noOfNullable++;
+ m_nullBitmaskSize = (m_noOfNullable + 31) / 32;
+ }
m_variableAttribs.push_back(d);
} // TableS::createAttr
@@ -883,12 +1033,15 @@
const LogEntry *
RestoreLogIterator::getNextLogEntry(int & res) {
// Read record length
- typedef BackupFormat::LogFile::LogEntry LogE;
-
- LogE * logE= 0;
- Uint32 len= ~0;
const Uint32 stopGCP = m_metaData.getStopGCP();
+ Uint32 tableId;
+ Uint32 triggerEvent;
+ Uint32 frag_id;
+ Uint32 *attr_data;
+ Uint32 attr_data_len;
do {
+ Uint32 len;
+ Uint32 *logEntryPtr;
if (buffer_read_ahead(&len, sizeof(Uint32), 1) != 1){
res= -1;
return 0;
@@ -896,7 +1049,7 @@
len= ntohl(len);
Uint32 data_len = sizeof(Uint32) + len*4;
- if (buffer_get_ptr((void **)(&logE), 1, data_len) != data_len) {
+ if (buffer_get_ptr((void **)(&logEntryPtr), 1, data_len) != data_len) {
res= -2;
return 0;
}
@@ -906,20 +1059,46 @@
return 0;
}
- logE->TableId= ntohl(logE->TableId);
- logE->TriggerEvent= ntohl(logE->TriggerEvent);
-
- const bool hasGcp= (logE->TriggerEvent & 0x10000) != 0;
- logE->TriggerEvent &= 0xFFFF;
+ if (unlikely(m_metaData.getFileHeader().NdbVersion < NDBD_FRAGID_VERSION))
+ {
+ /*
+ FragId was introduced in LogEntry in version
+ 5.1.6
+ We set FragId to 0 in older versions (these versions
+ do not support restore of user defined partitioned
+ tables.
+ */
+ typedef BackupFormat::LogFile::LogEntry_no_fragid LogE_no_fragid;
+ LogE_no_fragid * logE_no_fragid= (LogE_no_fragid *)logEntryPtr;
+ tableId= ntohl(logE_no_fragid->TableId);
+ triggerEvent= ntohl(logE_no_fragid->TriggerEvent);
+ frag_id= 0;
+ attr_data= &logE_no_fragid->Data[0];
+ attr_data_len= len - ((offsetof(LogE_no_fragid, Data) >> 2) - 1);
+ }
+ else /* normal case */
+ {
+ typedef BackupFormat::LogFile::LogEntry LogE;
+ LogE * logE= (LogE *)logEntryPtr;
+ tableId= ntohl(logE->TableId);
+ triggerEvent= ntohl(logE->TriggerEvent);
+ frag_id= ntohl(logE->FragId);
+ attr_data= &logE->Data[0];
+ attr_data_len= len - ((offsetof(LogE, Data) >> 2) - 1);
+ }
+ const bool hasGcp= (triggerEvent & 0x10000) != 0;
+ triggerEvent &= 0xFFFF;
+
if(hasGcp){
- len--;
- m_last_gci = ntohl(logE->Data[len-2]);
+ // last attr_data is gci info
+ attr_data_len--;
+ m_last_gci = ntohl(*(attr_data + attr_data_len));
}
} while(m_last_gci > stopGCP + 1);
-
- m_logEntry.m_table = m_metaData.getTable(logE->TableId);
- switch(logE->TriggerEvent){
+
+ m_logEntry.m_table = m_metaData.getTable(tableId);
+ switch(triggerEvent){
case TriggerEvent::TE_INSERT:
m_logEntry.m_type = LogEntry::LE_INSERT;
break;
@@ -937,9 +1116,10 @@
const TableS * tab = m_logEntry.m_table;
m_logEntry.clear();
- AttributeHeader * ah = (AttributeHeader *)&logE->Data[0];
- AttributeHeader *end = (AttributeHeader *)&logE->Data[len - 2];
+ AttributeHeader * ah = (AttributeHeader *)attr_data;
+ AttributeHeader *end = (AttributeHeader *)(attr_data + attr_data_len);
AttributeS * attr;
+ m_logEntry.m_frag_id = frag_id;
while(ah < end){
attr= m_logEntry.add_attr();
if(attr == NULL) {
@@ -948,6 +1128,9 @@
return 0;
}
+ if(unlikely(!m_hostByteOrder))
+ *(Uint32*)ah = Twiddle32(*(Uint32*)ah);
+
attr->Desc = (* tab)[ah->getAttributeId()];
assert(attr->Desc != 0);
@@ -983,7 +1166,7 @@
NdbRecAttr tmprec(0);
tmprec.setup(desc.m_column, 0);
- tmprec.receive_data((Uint32*)data.void_value, (data.size+3)/4);
+ tmprec.receive_data((Uint32*)data.void_value, data.size);
ndbrecattr_print_formatted(ndbout, tmprec, g_ndbrecord_print_format);
return ndbout;
@@ -1049,4 +1232,4 @@
template class Vector<AttributeS*>;
template class Vector<AttributeDesc*>;
template class Vector<FragmentInfo*>;
-
+template class Vector<DictObject>;
| Thread |
|---|
| • bk commit into 5.1 tree (tomas:1.2519) | tomas | 26 Mar |