summaryrefslogtreecommitdiff
path: root/storage/ndb/tools
diff options
context:
space:
mode:
authortomas@whalegate.ndb.mysql.com <>2007-11-06 10:27:56 +0100
committertomas@whalegate.ndb.mysql.com <>2007-11-06 10:27:56 +0100
commit47a245559c55f649b1ba15fe6f9ecc2a668557c0 (patch)
treea9784de144f443250c230c1e3857c9b0f56a6589 /storage/ndb/tools
parentbfc80edec513d50d87e0b58972196315a36eb58d (diff)
downloadmariadb-git-47a245559c55f649b1ba15fe6f9ecc2a668557c0.tar.gz
break out tuple data read
Diffstat (limited to 'storage/ndb/tools')
-rw-r--r--storage/ndb/tools/restore/Restore.cpp156
-rw-r--r--storage/ndb/tools/restore/Restore.hpp4
2 files changed, 88 insertions, 72 deletions
diff --git a/storage/ndb/tools/restore/Restore.cpp b/storage/ndb/tools/restore/Restore.cpp
index a7d8a9d10d9..f599bb21978 100644
--- a/storage/ndb/tools/restore/Restore.cpp
+++ b/storage/ndb/tools/restore/Restore.cpp
@@ -534,6 +534,88 @@ TupleS::prepareRecord(TableS & tab){
return true;
}
+int
+RestoreDataIterator::readTupleData(Uint32 *buf_ptr, Uint32 *ptr,
+ Uint32 dataLength)
+{
+ 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);
+
+ // 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))
+ {
+ attr_data->null = true;
+ attr_data->void_value = NULL;
+ continue;
+ }
+ }
+
+ 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;
+
+ //if (m_currentTable->getTableId() >= 2) { ndbout << "var off=" << ptr-buf_ptr << " attrId=" << attrId << endl; }
+
+ /**
+ * Compute array size
+ */
+ const Uint32 arraySize = sz / (attr_desc->size / 8);
+ assert(arraySize <= attr_desc->arraySize);
+
+ //convert the length of blob(v1) and text(v1)
+ if(!m_hostByteOrder
+ && (attr_desc->m_column->getType() == NdbDictionary::Column::Blob
+ || attr_desc->m_column->getType() == NdbDictionary::Column::Text)
+ && attr_desc->m_column->getArrayType() == NdbDictionary::Column::ArrayTypeFixed)
+ {
+ char* p = (char*)&attr_data->u_int64_value[0];
+ Uint64 x;
+ memcpy(&x, p, sizeof(Uint64));
+ x = Twiddle64(x);
+ memcpy(p, &x, sizeof(Uint64));
+ }
+
+ //convert datetime type
+ if(!m_hostByteOrder
+ && attr_desc->m_column->getType() == NdbDictionary::Column::Datetime)
+ {
+ char* p = (char*)&attr_data->u_int64_value[0];
+ Uint64 x;
+ memcpy(&x, p, sizeof(Uint64));
+ x = Twiddle64(x);
+ memcpy(p, &x, sizeof(Uint64));
+ }
+
+ if(!Twiddle(attr_desc, attr_data, attr_desc->arraySize))
+ {
+ return -1;
+ }
+
+ ptr += ((sz + 3) >> 2) + 2;
+ }
+
+ assert(ptr == buf_ptr + dataLength);
+
+ return 0;
+}
+
const TupleS *
RestoreDataIterator::getNextTuple(int & res)
{
@@ -630,78 +712,8 @@ RestoreDataIterator::getNextTuple(int & res)
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);
-
- // 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)){
- attr_data->null = true;
- attr_data->void_value = NULL;
- continue;
- }
- }
-
- 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;
-
- //if (m_currentTable->getTableId() >= 2) { ndbout << "var off=" << ptr-buf_ptr << " attrId=" << attrId << endl; }
-
- /**
- * Compute array size
- */
- const Uint32 arraySize = sz / (attr_desc->size / 8);
- assert(arraySize <= attr_desc->arraySize);
-
- //convert the length of blob(v1) and text(v1)
- if(!m_hostByteOrder
- && (attr_desc->m_column->getType() == NdbDictionary::Column::Blob
- || attr_desc->m_column->getType() == NdbDictionary::Column::Text)
- && attr_desc->m_column->getArrayType() == NdbDictionary::Column::ArrayTypeFixed)
- {
- char* p = (char*)&attr_data->u_int64_value[0];
- Uint64 x;
- memcpy(&x, p, sizeof(Uint64));
- x = Twiddle64(x);
- memcpy(p, &x, sizeof(Uint64));
- }
-
- //convert datetime type
- if(!m_hostByteOrder
- && attr_desc->m_column->getType() == NdbDictionary::Column::Datetime)
- {
- char* p = (char*)&attr_data->u_int64_value[0];
- Uint64 x;
- memcpy(&x, p, sizeof(Uint64));
- x = Twiddle64(x);
- memcpy(p, &x, sizeof(Uint64));
- }
-
- if(!Twiddle(attr_desc, attr_data, attr_desc->arraySize))
- {
- res = -1;
- return NULL;
- }
-
- ptr += ((sz + 3) >> 2) + 2;
- }
-
- assert(ptr == buf_ptr + dataLength);
+ if ((res = readTupleData(buf_ptr, ptr, dataLength)))
+ return NULL;
m_count ++;
res = 0;
diff --git a/storage/ndb/tools/restore/Restore.hpp b/storage/ndb/tools/restore/Restore.hpp
index 5455fa17aa0..f6de9245509 100644
--- a/storage/ndb/tools/restore/Restore.hpp
+++ b/storage/ndb/tools/restore/Restore.hpp
@@ -355,6 +355,10 @@ public:
bool validateFragmentFooter();
const TupleS *getNextTuple(int & res);
+
+private:
+
+ int readTupleData(Uint32 *buf_ptr, Uint32 *ptr, Uint32 dataLength);
};
class LogEntry {