23 #include <ndb_global.h>
25 #include "../src/kernel/blocks/backup/BackupFormat.hpp"
27 #include <util/ndbzio.h>
28 #include <util/UtilBuffer.hpp>
30 #include <ndb_version.h>
38 TCM_ATTRIBUTE_PROMOTION = 0x1,
43 TCM_EXCLUDE_MISSING_COLUMNS = 0x2,
48 TCM_ATTRIBUTE_DEMOTION = 0x4
53 isDrop6(Uint32 version)
55 return (getMajor(version) == 5 && getMinor(version) == 2);
60 typedef void* (*AttrConvertFunc)(
const void *old_data,
72 Uint16 * u_int16_value;
75 Uint32 * u_int32_value;
78 Uint64 * u_int64_value;
99 Uint32 m_nullBitIndex;
100 AttrConvertFunc convertFunc;
102 bool truncation_detected;
109 Uint32 getSizeInWords()
const {
return (
size * arraySize + 31)/ 32;}
110 Uint32 getSizeInBytes()
const {
112 return (
size / 8) * arraySize;
126 class TableS *m_currentTable;
128 bool prepareRecord(
TableS &);
138 delete [] allAttrData;
142 int getNoOfAttributes()
const;
143 TableS * getTable()
const;
162 Uint32 schemaVersion;
163 Uint32 backupVersion;
170 Uint32 m_noOfNullable;
171 Uint32 m_nullBitmaskSize;
174 Uint64 m_max_auto_val;
181 Uint32 m_main_column_id;
184 Uint64 m_noOfRecords;
197 Uint32 getLocalId()
const {
200 Uint64 getNoOfRecords()
const {
201 return m_noOfRecords;
215 void setBackupVersion(Uint32 version) {
216 backupVersion = version;
219 Uint32 getBackupVersion()
const {
220 return backupVersion;
223 const char * getTableName()
const {
227 int getNoOfAttributes()
const {
228 return allAttributesDesc.size();
231 bool have_auto_inc()
const {
232 return m_auto_val_attrib != 0;
235 bool have_auto_inc(Uint32
id)
const {
236 return (m_auto_val_attrib ? m_auto_val_attrib->attrId ==
id :
false);
239 Uint64 get_max_auto_val()
const {
240 return m_max_auto_val;
243 void update_max_auto_val(
const char *data,
int size) {
255 memcpy(&val.u32,data,4);
259 v= uint3korr((
unsigned char*)data);
262 memcpy(&val.u16,data,2);
266 memcpy(&val.u8,data,1);
272 if(v > m_max_auto_val)
276 bool get_auto_data(
const TupleS &
tuple, Uint32 * syskey, Uint64 * nextid)
const;
282 return allAttributesDesc[attributeId];
286 return allAttributesDesc[attributeId];
289 bool getSysTable()
const {
293 const TableS *getMainTable()
const {
299 bool isSYSTAB_0()
const {
304 bool isBroken()
const {
305 return m_broken || (m_main_table && m_main_table->isBroken());
315 char m_path[PATH_MAX];
316 char m_fileName[PATH_MAX];
317 bool m_hostByteOrder;
326 Uint32 m_buffer_data_left;
335 void (* free_data_callback)();
336 virtual void reset_buffers() {}
339 void setCtlFile(Uint32 nodeId, Uint32 backupId,
const char * path);
340 void setDataFile(
const BackupFile & bf, Uint32 no);
341 void setLogFile(
const BackupFile & bf, Uint32 no);
343 Uint32 buffer_get_ptr(
void **p_buf_ptr, Uint32 size, Uint32 nmemb);
344 Uint32 buffer_read(
void *ptr, Uint32 size, Uint32 nmemb);
345 Uint32 buffer_get_ptr_ahead(
void **p_buf_ptr, Uint32 size, Uint32 nmemb);
346 Uint32 buffer_read_ahead(
void *ptr, Uint32 size, Uint32 nmemb);
348 void setName(
const char * path,
const char *
name);
350 BackupFile(
void (* free_data_callback)() = 0);
355 bool validateFooter();
357 const char * getPath()
const {
return m_path;}
358 const char * getFilename()
const {
return m_fileName;}
359 Uint32 getNodeId()
const {
return m_nodeId;}
364 Uint64 get_file_size()
const {
return m_file_size; }
365 Uint64 get_file_pos()
const {
return m_file_pos; }
381 bool readMetaFileHeader();
382 bool readMetaTableDesc();
383 bool markSysTables();
387 bool readFragmentInfo();
388 Uint32 readMetaTableList();
393 bool parseTableDescriptor(
const Uint32 * data, Uint32 len);
403 Uint32 getNoOfTables()
const {
return allTables.size();}
405 const TableS * operator[](
int i)
const {
return allTables[
i];}
406 TableS * getTable(Uint32 tableId)
const;
408 Uint32 getNoOfObjects()
const {
return m_objects.size();}
409 Uint32 getObjType(Uint32 i)
const {
return m_objects[
i].m_objType; }
410 void* getObjPtr(Uint32 i)
const {
return m_objects[
i].m_objPtr; }
412 Uint32 getStopGCP()
const;
413 Uint32 getNdbVersion()
const {
return m_fileHeader.NdbVersion; };
427 void (* free_data_callback)());
431 bool readFragmentHeader(
int & res, Uint32 *fragmentId);
432 bool validateFragmentFooter();
435 TableS *getCurrentTable();
439 void free_bitfield_storage();
440 void reset_bitfield_storage();
441 Uint32* get_bitfield_storage(Uint32 len);
442 Uint32 get_free_bitfield_storage()
const;
444 Uint32 m_row_bitfield_len;
445 Uint32* m_bitfield_storage_ptr;
446 Uint32* m_bitfield_storage_curr_ptr;
447 Uint32 m_bitfield_storage_len;
450 virtual void reset_buffers() { reset_bitfield_storage();}
452 int readTupleData_old(Uint32 *buf_ptr, Uint32 dataLength);
455 int readVarData(Uint32 *buf_ptr, Uint32 *ptr, Uint32 dataLength);
456 int readVarData_drop6(Uint32 *buf_ptr, Uint32 *ptr, Uint32 dataLength);
473 if (m_values_e.size() > 0) {
474 attr = m_values_e[m_values_e.size()-1];
475 m_values_e.erase(m_values_e.size()-1);
481 m_values.push_back(attr);
485 for(Uint32
i= 0;
i < m_values.size();
i++)
486 m_values_e.push_back(m_values[
i]);
493 for(i= 0; i< m_values.size(); i++)
495 for(i= 0; i< m_values_e.size(); i++)
496 delete m_values_e[i];
498 Uint32 size()
const {
return m_values.size(); }
499 const AttributeS * operator[](
int i)
const {
return m_values[
i];}
513 const LogEntry * getNextLogEntry(
int & res);
516 NdbOut& operator<<(NdbOut& ndbout,
const TableS&);
517 NdbOut& operator<<(NdbOut& ndbout,
const TupleS&);
518 NdbOut& operator<<(NdbOut& ndbout,
const LogEntry&);
521 bool readSYSTAB_0(
const TupleS & tup, Uint32 * syskey, Uint64 * nextid);