Commit f8f1b203 authored by knielsen@ymer.(none)'s avatar knielsen@ymer.(none)

NDB temporary tables.

Temporary tables are not written to disk by DDL operations. This makes
DDL much faster (useful for tests), but tables are lost after system
restart.

New commit, since this feature will not be available in 5.1.
parent 365b69dc
...@@ -208,7 +208,10 @@ public: ...@@ -208,7 +208,10 @@ public:
NotUnique = 4251, NotUnique = 4251,
AllocationError = 4252, AllocationError = 4252,
CreateIndexTableFailed = 4253, CreateIndexTableFailed = 4253,
DuplicateAttributes = 4258 DuplicateAttributes = 4258,
TableIsTemporary = 776,
TableIsNotTemporary = 777,
NoLoggingTemporaryIndex = 778,
}; };
CreateIndxConf m_conf; CreateIndxConf m_conf;
......
...@@ -97,7 +97,8 @@ public: ...@@ -97,7 +97,8 @@ public:
VarsizeBitfieldNotSupported = 757, VarsizeBitfieldNotSupported = 757,
NotATablespace = 758, NotATablespace = 758,
InvalidTablespaceVersion = 759, InvalidTablespaceVersion = 759,
OutOfStringBuffer = 773 OutOfStringBuffer = 773,
NoLoggingTemporaryTable = 778,
}; };
private: private:
......
...@@ -30,7 +30,7 @@ class DiAddTabReq { ...@@ -30,7 +30,7 @@ class DiAddTabReq {
*/ */
friend class Dbdih; friend class Dbdih;
public: public:
STATIC_CONST( SignalLength = 9 ); STATIC_CONST( SignalLength = 10 );
SECTION( FRAGMENTATION = 0 ); SECTION( FRAGMENTATION = 0 );
SECTION( TS_RANGE = 0 ); SECTION( TS_RANGE = 0 );
...@@ -40,10 +40,11 @@ private: ...@@ -40,10 +40,11 @@ private:
Uint32 fragType; Uint32 fragType;
Uint32 kValue; Uint32 kValue;
Uint32 noOfReplicas; //Currently not used Uint32 noOfReplicas; //Currently not used
Uint32 storedTable; Uint32 loggedTable;
Uint32 tableType; Uint32 tableType;
Uint32 schemaVersion; Uint32 schemaVersion;
Uint32 primaryTableId; Uint32 primaryTableId;
Uint32 temporaryTable;
}; };
class DiAddTabRef { class DiAddTabRef {
......
...@@ -118,6 +118,8 @@ public: ...@@ -118,6 +118,8 @@ public:
FrmLen = 26, FrmLen = 26,
FrmData = 27, FrmData = 27,
TableTemporaryFlag = 28, //Default not Temporary
FragmentCount = 128, // No of fragments in table (!fragment replicas) FragmentCount = 128, // No of fragments in table (!fragment replicas)
FragmentDataLen = 129, FragmentDataLen = 129,
FragmentData = 130, // CREATE_FRAGMENTATION reply FragmentData = 130, // CREATE_FRAGMENTATION reply
...@@ -278,7 +280,7 @@ public: ...@@ -278,7 +280,7 @@ public:
// Object store for translating from/to API // Object store for translating from/to API
enum ObjectStore { enum ObjectStore {
StoreUndefined = 0, StoreUndefined = 0,
StoreTemporary = 1, StoreNotLogged = 1,
StorePermanent = 2 StorePermanent = 2
}; };
...@@ -297,6 +299,7 @@ public: ...@@ -297,6 +299,7 @@ public:
char PrimaryTable[MAX_TAB_NAME_SIZE]; // Only used when "index" char PrimaryTable[MAX_TAB_NAME_SIZE]; // Only used when "index"
Uint32 PrimaryTableId; Uint32 PrimaryTableId;
Uint32 TableLoggedFlag; Uint32 TableLoggedFlag;
Uint32 TableTemporaryFlag;
Uint32 NoOfKeyAttr; Uint32 NoOfKeyAttr;
Uint32 NoOfAttributes; Uint32 NoOfAttributes;
Uint32 NoOfNullable; Uint32 NoOfNullable;
......
...@@ -39,10 +39,16 @@ public: ...@@ -39,10 +39,16 @@ public:
BitmaskImpl::setField(1, &data, 12, 8, val); BitmaskImpl::setField(1, &data, 12, 8, val);
} }
static Uint32 getTableStore(Uint32 data) { static Uint32 getTableStore(Uint32 data) {
return BitmaskImpl::getField(1, &data, 20, 4); return BitmaskImpl::getField(1, &data, 20, 3);
} }
static void setTableStore(Uint32& data, Uint32 val) { static void setTableStore(Uint32& data, Uint32 val) {
BitmaskImpl::setField(1, &data, 20, 4, val); BitmaskImpl::setField(1, &data, 20, 3, val);
}
static Uint32 getTableTemp(Uint32 data) {
return BitmaskImpl::getField(1, &data, 23, 1);
}
static void setTableTemp(Uint32& data, Uint32 val) {
BitmaskImpl::setField(1, &data, 23, 1, val);
} }
static Uint32 getTableState(Uint32 data) { static Uint32 getTableState(Uint32 data) {
return BitmaskImpl::getField(1, &data, 24, 4); return BitmaskImpl::getField(1, &data, 24, 4);
...@@ -161,6 +167,12 @@ public: ...@@ -161,6 +167,12 @@ public:
void setTableState(unsigned pos, Uint32 val) { void setTableState(unsigned pos, Uint32 val) {
ListTablesData::setTableState(tableData[pos], val); ListTablesData::setTableState(tableData[pos], val);
} }
static Uint32 getTableTemp(Uint32 data) {
return ListTablesData::getTableTemp(data);
}
void setTableTemp(unsigned pos, Uint32 val) {
ListTablesData::setTableTemp(tableData[pos], val);
}
}; };
#endif #endif
...@@ -85,4 +85,10 @@ ...@@ -85,4 +85,10 @@
#define NDB_STORAGETYPE_MEMORY 0 #define NDB_STORAGETYPE_MEMORY 0
#define NDB_STORAGETYPE_DISK 1 #define NDB_STORAGETYPE_DISK 1
/*
* Table temporary status.
*/
#define NDB_TEMP_TAB_PERMANENT 0
#define NDB_TEMP_TAB_TEMPORARY 1
#endif #endif
...@@ -136,7 +136,7 @@ public: ...@@ -136,7 +136,7 @@ public:
*/ */
enum Store { enum Store {
StoreUndefined = 0, ///< Undefined StoreUndefined = 0, ///< Undefined
StoreTemporary = 1, ///< Object or data deleted on system restart StoreNotLogged = 1, ///< Object or data deleted on system restart
StorePermanent = 2 ///< Permanent. logged to disk StorePermanent = 2 ///< Permanent. logged to disk
}; };
...@@ -917,6 +917,9 @@ public: ...@@ -917,6 +917,9 @@ public:
int createTableInDb(Ndb*, bool existingEqualIsOk = true) const ; int createTableInDb(Ndb*, bool existingEqualIsOk = true) const ;
int getReplicaCount() const ; int getReplicaCount() const ;
bool getTemporary();
void setTemporary(bool);
#endif #endif
private: private:
...@@ -1104,6 +1107,9 @@ public: ...@@ -1104,6 +1107,9 @@ public:
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
void setStoredIndex(bool x) { setLogging(x); } void setStoredIndex(bool x) { setLogging(x); }
bool getStoredIndex() const { return getLogging(); } bool getStoredIndex() const { return getLogging(); }
bool getTemporary();
void setTemporary(bool);
#endif #endif
/** @} *******************************************************************/ /** @} *******************************************************************/
...@@ -1564,7 +1570,8 @@ public: ...@@ -1564,7 +1570,8 @@ public:
unsigned id; ///< Id of object unsigned id; ///< Id of object
Object::Type type; ///< Type of object Object::Type type; ///< Type of object
Object::State state; ///< State of object Object::State state; ///< State of object
Object::Store store; ///< How object is stored Object::Store store; ///< How object is logged
Uint32 temp; ///< Temporary status of object
char * database; ///< In what database the object resides char * database; ///< In what database the object resides
char * schema; ///< What schema the object is defined in char * schema; ///< What schema the object is defined in
char * name; ///< Name of object char * name; ///< Name of object
...@@ -1573,6 +1580,7 @@ public: ...@@ -1573,6 +1580,7 @@ public:
type(Object::TypeUndefined), type(Object::TypeUndefined),
state(Object::StateUndefined), state(Object::StateUndefined),
store(Object::StoreUndefined), store(Object::StoreUndefined),
temp(NDB_TEMP_TAB_PERMANENT),
database(0), database(0),
schema(0), schema(0),
name(0) { name(0) {
......
...@@ -26,6 +26,7 @@ DictTabInfo::TableMapping[] = { ...@@ -26,6 +26,7 @@ DictTabInfo::TableMapping[] = {
DTIMAPS(Table, PrimaryTable, PrimaryTable, 0, MAX_TAB_NAME_SIZE), DTIMAPS(Table, PrimaryTable, PrimaryTable, 0, MAX_TAB_NAME_SIZE),
DTIMAP(Table, PrimaryTableId, PrimaryTableId), DTIMAP(Table, PrimaryTableId, PrimaryTableId),
DTIMAP2(Table, TableLoggedFlag, TableLoggedFlag, 0, 1), DTIMAP2(Table, TableLoggedFlag, TableLoggedFlag, 0, 1),
DTIMAP2(Table, TableTemporaryFlag, TableTemporaryFlag, 0, 1),
DTIMAP2(Table, TableKValue, TableKValue, 6, 6), DTIMAP2(Table, TableKValue, TableKValue, 6, 6),
DTIMAP2(Table, MinLoadFactor, MinLoadFactor, 0, 90), DTIMAP2(Table, MinLoadFactor, MinLoadFactor, 0, 90),
DTIMAP2(Table, MaxLoadFactor, MaxLoadFactor, 25, 110), DTIMAP2(Table, MaxLoadFactor, MaxLoadFactor, 25, 110),
...@@ -122,6 +123,7 @@ DictTabInfo::Table::init(){ ...@@ -122,6 +123,7 @@ DictTabInfo::Table::init(){
memset(PrimaryTable, 0, sizeof(PrimaryTable));//PrimaryTable[0] = 0; // Only used when "index" memset(PrimaryTable, 0, sizeof(PrimaryTable));//PrimaryTable[0] = 0; // Only used when "index"
PrimaryTableId = RNIL; PrimaryTableId = RNIL;
TableLoggedFlag = 1; TableLoggedFlag = 1;
TableTemporaryFlag = 0;
NoOfKeyAttr = 0; NoOfKeyAttr = 0;
NoOfAttributes = 0; NoOfAttributes = 0;
NoOfNullable = 0; NoOfNullable = 0;
......
...@@ -238,7 +238,8 @@ public: ...@@ -238,7 +238,8 @@ public:
{ {
TR_Logged = 0x1, TR_Logged = 0x1,
TR_RowGCI = 0x2, TR_RowGCI = 0x2,
TR_RowChecksum = 0x4 TR_RowChecksum = 0x4,
TR_Temporary = 0x8
}; };
Uint16 m_bits; Uint16 m_bits;
...@@ -1238,7 +1239,8 @@ private: ...@@ -1238,7 +1239,8 @@ private:
CreateIndxReq m_request; CreateIndxReq m_request;
AttributeList m_attrList; AttributeList m_attrList;
char m_indexName[MAX_TAB_NAME_SIZE]; char m_indexName[MAX_TAB_NAME_SIZE];
bool m_storedIndex; bool m_loggedIndex;
bool m_temporaryIndex;
// coordinator DICT // coordinator DICT
Uint32 m_coordinatorRef; Uint32 m_coordinatorRef;
bool m_isMaster; bool m_isMaster;
...@@ -2194,7 +2196,8 @@ private: ...@@ -2194,7 +2196,8 @@ private:
// Read/Write Schema and Table files // Read/Write Schema and Table files
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
void updateSchemaState(Signal* signal, Uint32 tableId, void updateSchemaState(Signal* signal, Uint32 tableId,
SchemaFile::TableEntry*, Callback*); SchemaFile::TableEntry*, Callback*,
bool savetodisk = 1);
void startWriteSchemaFile(Signal* signal); void startWriteSchemaFile(Signal* signal);
void openSchemaFile(Signal* signal, void openSchemaFile(Signal* signal,
Uint32 fileNo, Uint32 fileNo,
......
...@@ -54,7 +54,8 @@ struct SchemaFile { ...@@ -54,7 +54,8 @@ struct SchemaFile {
TABLE_ADD_COMMITTED = 2, TABLE_ADD_COMMITTED = 2,
DROP_TABLE_STARTED = 3, DROP_TABLE_STARTED = 3,
DROP_TABLE_COMMITTED = 4, DROP_TABLE_COMMITTED = 4,
ALTER_TABLE_COMMITTED = 5 ALTER_TABLE_COMMITTED = 5,
TEMPORARY_TABLE_COMMITTED = 6
}; };
// entry size 32 bytes // entry size 32 bytes
......
...@@ -469,11 +469,17 @@ public: ...@@ -469,11 +469,17 @@ public:
NORMAL_HASH = 2, NORMAL_HASH = 2,
USER_DEFINED = 3 USER_DEFINED = 3
}; };
enum Storage {
ST_NOLOGGING = 0, // Table is not logged, but survives SR
ST_NORMAL = 1, // Normal table, logged and durable
ST_TEMPORARY = 2 // Table is lost after SR, not logged
};
CopyStatus tabCopyStatus; CopyStatus tabCopyStatus;
UpdateState tabUpdateState; UpdateState tabUpdateState;
TabLcpStatus tabLcpStatus; TabLcpStatus tabLcpStatus;
TabStatus tabStatus; TabStatus tabStatus;
Method method; Method method;
Storage tabStorage;
Uint32 pageRef[8]; Uint32 pageRef[8];
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -506,7 +512,6 @@ public: ...@@ -506,7 +512,6 @@ public:
Uint8 kvalue; Uint8 kvalue;
Uint8 noOfBackups; Uint8 noOfBackups;
Uint8 noPages; Uint8 noPages;
Uint8 storedTable; /* 0 IF THE TABLE IS A TEMPORARY TABLE */
Uint16 tableType; Uint16 tableType;
Uint16 primaryTableId; Uint16 primaryTableId;
}; };
......
...@@ -5507,7 +5507,7 @@ void Dbdih::removeNodeFromTable(Signal* signal, ...@@ -5507,7 +5507,7 @@ void Dbdih::removeNodeFromTable(Signal* signal,
//const Uint32 lcpId = SYSFILE->latestLCP_ID; //const Uint32 lcpId = SYSFILE->latestLCP_ID;
const bool lcpOngoingFlag = (tabPtr.p->tabLcpStatus== TabRecord::TLS_ACTIVE); const bool lcpOngoingFlag = (tabPtr.p->tabLcpStatus== TabRecord::TLS_ACTIVE);
const bool temporary = !tabPtr.p->storedTable; const bool unlogged = (tabPtr.p->tabStorage != TabRecord::ST_NORMAL);
FragmentstorePtr fragPtr; FragmentstorePtr fragPtr;
for(Uint32 fragNo = 0; fragNo < tabPtr.p->totalfragments; fragNo++){ for(Uint32 fragNo = 0; fragNo < tabPtr.p->totalfragments; fragNo++){
...@@ -5528,7 +5528,7 @@ void Dbdih::removeNodeFromTable(Signal* signal, ...@@ -5528,7 +5528,7 @@ void Dbdih::removeNodeFromTable(Signal* signal,
jam(); jam();
found = true; found = true;
noOfRemovedReplicas++; noOfRemovedReplicas++;
removeNodeFromStored(nodeId, fragPtr, replicaPtr, temporary); removeNodeFromStored(nodeId, fragPtr, replicaPtr, unlogged);
if(replicaPtr.p->lcpOngoingFlag){ if(replicaPtr.p->lcpOngoingFlag){
jam(); jam();
/** /**
...@@ -6796,7 +6796,12 @@ void Dbdih::execDIADDTABREQ(Signal* signal) ...@@ -6796,7 +6796,12 @@ void Dbdih::execDIADDTABREQ(Signal* signal)
/* BUT THEY DO NOT HAVE ANY INFORMATION ABOUT ANY TABLE*/ /* BUT THEY DO NOT HAVE ANY INFORMATION ABOUT ANY TABLE*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
tabPtr.p->tabStatus = TabRecord::TS_CREATING; tabPtr.p->tabStatus = TabRecord::TS_CREATING;
tabPtr.p->storedTable = req->storedTable; if(req->loggedTable)
tabPtr.p->tabStorage= TabRecord::ST_NORMAL;
else if(req->temporaryTable)
tabPtr.p->tabStorage= TabRecord::ST_TEMPORARY;
else
tabPtr.p->tabStorage= TabRecord::ST_NOLOGGING;
tabPtr.p->kvalue = req->kValue; tabPtr.p->kvalue = req->kValue;
switch ((DictTabInfo::FragmentType)fragType) switch ((DictTabInfo::FragmentType)fragType)
...@@ -6961,7 +6966,7 @@ Dbdih::sendAddFragreq(Signal* signal, ConnectRecordPtr connectPtr, ...@@ -6961,7 +6966,7 @@ Dbdih::sendAddFragreq(Signal* signal, ConnectRecordPtr connectPtr,
ndbrequire(replicaPtr.p->procNode == getOwnNodeId()); ndbrequire(replicaPtr.p->procNode == getOwnNodeId());
Uint32 requestInfo = 0; Uint32 requestInfo = 0;
if(!tabPtr.p->storedTable){ if(tabPtr.p->tabStorage != TabRecord::ST_NORMAL){
requestInfo |= LqhFragReq::TemporaryTable; requestInfo |= LqhFragReq::TemporaryTable;
} }
...@@ -8391,9 +8396,9 @@ void Dbdih::initLcpLab(Signal* signal, Uint32 senderRef, Uint32 tableId) ...@@ -8391,9 +8396,9 @@ void Dbdih::initLcpLab(Signal* signal, Uint32 senderRef, Uint32 tableId)
continue; continue;
} }
if (tabPtr.p->storedTable == 0) { if (tabPtr.p->tabStorage != TabRecord::ST_NORMAL) {
/** /**
* Temporary table * Table is not logged
*/ */
jam(); jam();
tabPtr.p->tabLcpStatus = TabRecord::TLS_COMPLETED; tabPtr.p->tabLcpStatus = TabRecord::TLS_COMPLETED;
...@@ -8881,10 +8886,10 @@ void Dbdih::readPagesIntoTableLab(Signal* signal, Uint32 tableId) ...@@ -8881,10 +8886,10 @@ void Dbdih::readPagesIntoTableLab(Signal* signal, Uint32 tableId)
rf.rwfTabPtr.p->kvalue = readPageWord(&rf); rf.rwfTabPtr.p->kvalue = readPageWord(&rf);
rf.rwfTabPtr.p->mask = readPageWord(&rf); rf.rwfTabPtr.p->mask = readPageWord(&rf);
rf.rwfTabPtr.p->method = (TabRecord::Method)readPageWord(&rf); rf.rwfTabPtr.p->method = (TabRecord::Method)readPageWord(&rf);
/* ---------------------------------- */ /* ------------- */
/* Type of table, 2 = temporary table */ /* Type of table */
/* ---------------------------------- */ /* ------------- */
rf.rwfTabPtr.p->storedTable = readPageWord(&rf); rf.rwfTabPtr.p->tabStorage = (TabRecord::Storage)(readPageWord(&rf));
Uint32 noOfFrags = rf.rwfTabPtr.p->totalfragments; Uint32 noOfFrags = rf.rwfTabPtr.p->totalfragments;
ndbrequire(noOfFrags > 0); ndbrequire(noOfFrags > 0);
...@@ -8975,7 +8980,7 @@ void Dbdih::packTableIntoPagesLab(Signal* signal, Uint32 tableId) ...@@ -8975,7 +8980,7 @@ void Dbdih::packTableIntoPagesLab(Signal* signal, Uint32 tableId)
writePageWord(&wf, tabPtr.p->kvalue); writePageWord(&wf, tabPtr.p->kvalue);
writePageWord(&wf, tabPtr.p->mask); writePageWord(&wf, tabPtr.p->mask);
writePageWord(&wf, tabPtr.p->method); writePageWord(&wf, tabPtr.p->method);
writePageWord(&wf, tabPtr.p->storedTable); writePageWord(&wf, tabPtr.p->tabStorage);
signal->theData[0] = DihContinueB::ZPACK_FRAG_INTO_PAGES; signal->theData[0] = DihContinueB::ZPACK_FRAG_INTO_PAGES;
signal->theData[1] = tabPtr.i; signal->theData[1] = tabPtr.i;
...@@ -9180,7 +9185,7 @@ void Dbdih::startFragment(Signal* signal, Uint32 tableId, Uint32 fragId) ...@@ -9180,7 +9185,7 @@ void Dbdih::startFragment(Signal* signal, Uint32 tableId, Uint32 fragId)
continue; continue;
} }
if(tabPtr.p->storedTable == 0){ if(tabPtr.p->tabStorage != TabRecord::ST_NORMAL){
jam(); jam();
TloopCount++; TloopCount++;
tableId++; tableId++;
...@@ -9805,7 +9810,7 @@ void Dbdih::calculateKeepGciLab(Signal* signal, Uint32 tableId, Uint32 fragId) ...@@ -9805,7 +9810,7 @@ void Dbdih::calculateKeepGciLab(Signal* signal, Uint32 tableId, Uint32 fragId)
}//if }//if
ptrCheckGuard(tabPtr, ctabFileSize, tabRecord); ptrCheckGuard(tabPtr, ctabFileSize, tabRecord);
if (tabPtr.p->tabStatus != TabRecord::TS_ACTIVE || if (tabPtr.p->tabStatus != TabRecord::TS_ACTIVE ||
tabPtr.p->storedTable == 0) { tabPtr.p->tabStorage != TabRecord::ST_NORMAL) {
if (TloopCount > 100) { if (TloopCount > 100) {
jam(); jam();
signal->theData[0] = DihContinueB::ZCALCULATE_KEEP_GCI; signal->theData[0] = DihContinueB::ZCALCULATE_KEEP_GCI;
...@@ -10723,6 +10728,14 @@ void Dbdih::allNodesLcpCompletedLab(Signal* signal) ...@@ -10723,6 +10728,14 @@ void Dbdih::allNodesLcpCompletedLab(Signal* signal)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
void Dbdih::tableUpdateLab(Signal* signal, TabRecordPtr tabPtr) { void Dbdih::tableUpdateLab(Signal* signal, TabRecordPtr tabPtr) {
FileRecordPtr filePtr; FileRecordPtr filePtr;
if(tabPtr.p->tabStorage == TabRecord::ST_TEMPORARY) {
// For temporary tables we do not write to disk. Mark both copies 0 and 1
// as done, and go straight to the after-close code.
filePtr.i = tabPtr.p->tabFile[1];
ptrCheckGuard(filePtr, cfileFileSize, fileRecord);
tableCloseLab(signal, filePtr);
return;
}
filePtr.i = tabPtr.p->tabFile[0]; filePtr.i = tabPtr.p->tabFile[0];
ptrCheckGuard(filePtr, cfileFileSize, fileRecord); ptrCheckGuard(filePtr, cfileFileSize, fileRecord);
createFileRw(signal, filePtr); createFileRw(signal, filePtr);
...@@ -11758,7 +11771,7 @@ void Dbdih::initTable(TabRecordPtr tabPtr) ...@@ -11758,7 +11771,7 @@ void Dbdih::initTable(TabRecordPtr tabPtr)
tabPtr.p->kvalue = 0; tabPtr.p->kvalue = 0;
tabPtr.p->hashpointer = (Uint32)-1; tabPtr.p->hashpointer = (Uint32)-1;
tabPtr.p->mask = 0; tabPtr.p->mask = 0;
tabPtr.p->storedTable = 1; tabPtr.p->tabStorage = TabRecord::ST_NORMAL;
tabPtr.p->tabErrorCode = 0; tabPtr.p->tabErrorCode = 0;
tabPtr.p->schemaVersion = (Uint32)-1; tabPtr.p->schemaVersion = (Uint32)-1;
tabPtr.p->tabRemoveNode = RNIL; tabPtr.p->tabRemoveNode = RNIL;
......
...@@ -632,6 +632,16 @@ NdbDictionary::Table::getReplicaCount() const { ...@@ -632,6 +632,16 @@ NdbDictionary::Table::getReplicaCount() const {
return m_impl.m_replicaCount; return m_impl.m_replicaCount;
} }
bool
NdbDictionary::Table::getTemporary() {
return m_impl.m_temporary;
}
void
NdbDictionary::Table::setTemporary(bool val) {
m_impl.m_temporary = val;
}
int int
NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const { NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const {
const NdbDictionary::Table * pTab = const NdbDictionary::Table * pTab =
...@@ -808,6 +818,16 @@ NdbDictionary::Index::setLogging(bool val){ ...@@ -808,6 +818,16 @@ NdbDictionary::Index::setLogging(bool val){
m_impl.m_logging = val; m_impl.m_logging = val;
} }
bool
NdbDictionary::Index::getTemporary(){
return m_impl.m_temporary;
}
void
NdbDictionary::Index::setTemporary(bool val){
m_impl.m_temporary = val;
}
bool bool
NdbDictionary::Index::getLogging() const { NdbDictionary::Index::getLogging() const {
return m_impl.m_logging; return m_impl.m_logging;
......
...@@ -452,6 +452,7 @@ NdbTableImpl::init(){ ...@@ -452,6 +452,7 @@ NdbTableImpl::init(){
m_primaryTable.clear(); m_primaryTable.clear();
m_default_no_part_flag = 1; m_default_no_part_flag = 1;
m_logging= true; m_logging= true;
m_temporary = false;
m_row_gci = true; m_row_gci = true;
m_row_checksum = true; m_row_checksum = true;
m_kvalue= 6; m_kvalue= 6;
...@@ -571,6 +572,12 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const ...@@ -571,6 +572,12 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const
DBUG_RETURN(false); DBUG_RETURN(false);
} }
if(m_temporary != obj.m_temporary)
{
DBUG_PRINT("info",("m_temporary %d != %d",m_temporary,obj.m_temporary));
DBUG_RETURN(false);
}
if(m_row_gci != obj.m_row_gci) if(m_row_gci != obj.m_row_gci)
{ {
DBUG_PRINT("info",("m_row_gci %d != %d",m_row_gci,obj.m_row_gci)); DBUG_PRINT("info",("m_row_gci %d != %d",m_row_gci,obj.m_row_gci));
...@@ -711,6 +718,7 @@ NdbTableImpl::assign(const NdbTableImpl& org) ...@@ -711,6 +718,7 @@ NdbTableImpl::assign(const NdbTableImpl& org)
m_max_rows = org.m_max_rows; m_max_rows = org.m_max_rows;
m_default_no_part_flag = org.m_default_no_part_flag; m_default_no_part_flag = org.m_default_no_part_flag;
m_logging = org.m_logging; m_logging = org.m_logging;
m_temporary = org.m_temporary;
m_row_gci = org.m_row_gci; m_row_gci = org.m_row_gci;
m_row_checksum = org.m_row_checksum; m_row_checksum = org.m_row_checksum;
m_kvalue = org.m_kvalue; m_kvalue = org.m_kvalue;
...@@ -1080,6 +1088,7 @@ void NdbIndexImpl::init() ...@@ -1080,6 +1088,7 @@ void NdbIndexImpl::init()
m_id= RNIL; m_id= RNIL;
m_type= NdbDictionary::Object::TypeUndefined; m_type= NdbDictionary::Object::TypeUndefined;
m_logging= true; m_logging= true;
m_temporary= false;
m_table= NULL; m_table= NULL;
} }
...@@ -2006,7 +2015,7 @@ objectStateMapping[] = { ...@@ -2006,7 +2015,7 @@ objectStateMapping[] = {
static const static const
ApiKernelMapping ApiKernelMapping
objectStoreMapping[] = { objectStoreMapping[] = {
{ DictTabInfo::StoreTemporary, NdbDictionary::Object::StoreTemporary }, { DictTabInfo::StoreNotLogged, NdbDictionary::Object::StoreNotLogged },
{ DictTabInfo::StorePermanent, NdbDictionary::Object::StorePermanent }, { DictTabInfo::StorePermanent, NdbDictionary::Object::StorePermanent },
{ -1, -1 } { -1, -1 }
}; };
...@@ -2085,6 +2094,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, ...@@ -2085,6 +2094,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
impl->m_default_no_part_flag = tableDesc->DefaultNoPartFlag; impl->m_default_no_part_flag = tableDesc->DefaultNoPartFlag;
impl->m_linear_flag = tableDesc->LinearHashFlag; impl->m_linear_flag = tableDesc->LinearHashFlag;
impl->m_logging = tableDesc->TableLoggedFlag; impl->m_logging = tableDesc->TableLoggedFlag;
impl->m_temporary = tableDesc->TableTemporaryFlag;
impl->m_row_gci = tableDesc->RowGCIFlag; impl->m_row_gci = tableDesc->RowGCIFlag;
impl->m_row_checksum = tableDesc->RowChecksumFlag; impl->m_row_checksum = tableDesc->RowChecksumFlag;
impl->m_kvalue = tableDesc->TableKValue; impl->m_kvalue = tableDesc->TableKValue;
...@@ -2527,6 +2537,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, ...@@ -2527,6 +2537,7 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
tmpTab->FragmentCount= impl.m_fragmentCount; tmpTab->FragmentCount= impl.m_fragmentCount;
tmpTab->TableLoggedFlag = impl.m_logging; tmpTab->TableLoggedFlag = impl.m_logging;
tmpTab->TableTemporaryFlag = impl.m_temporary;
tmpTab->RowGCIFlag = impl.m_row_gci; tmpTab->RowGCIFlag = impl.m_row_gci;
tmpTab->RowChecksumFlag = impl.m_row_checksum; tmpTab->RowChecksumFlag = impl.m_row_checksum;
tmpTab->TableKValue = impl.m_kvalue; tmpTab->TableKValue = impl.m_kvalue;
...@@ -3045,6 +3056,7 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst, ...@@ -3045,6 +3056,7 @@ NdbDictInterface::create_index_obj_from_table(NdbIndexImpl** dst,
idx->m_tableName.assign(prim->m_externalName); idx->m_tableName.assign(prim->m_externalName);
NdbDictionary::Object::Type type = idx->m_type = tab->m_indexType; NdbDictionary::Object::Type type = idx->m_type = tab->m_indexType;
idx->m_logging = tab->m_logging; idx->m_logging = tab->m_logging;
idx->m_temporary = tab->m_temporary;
// skip last attribute (NDB$PK or NDB$TNODE) // skip last attribute (NDB$PK or NDB$TNODE)
const Uint32 distKeys = prim->m_noOfDistributionKeys; const Uint32 distKeys = prim->m_noOfDistributionKeys;
...@@ -3136,6 +3148,7 @@ NdbDictInterface::createIndex(Ndb & ndb, ...@@ -3136,6 +3148,7 @@ NdbDictInterface::createIndex(Ndb & ndb,
ndb.internalize_index_name(&table, impl.getName())); ndb.internalize_index_name(&table, impl.getName()));
w.add(DictTabInfo::TableName, internalName.c_str()); w.add(DictTabInfo::TableName, internalName.c_str());
w.add(DictTabInfo::TableLoggedFlag, impl.m_logging); w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
w.add(DictTabInfo::TableTemporaryFlag, impl.m_temporary);
NdbApiSignal tSignal(m_reference); NdbApiSignal tSignal(m_reference);
tSignal.theReceiversBlockNumber = DBDICT; tSignal.theReceiversBlockNumber = DBDICT;
...@@ -4119,6 +4132,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list, ...@@ -4119,6 +4132,7 @@ NdbDictInterface::listObjects(NdbDictionary::Dictionary::List& list,
getApiConstant(ListTablesConf::getTableState(d), objectStateMapping, 0); getApiConstant(ListTablesConf::getTableState(d), objectStateMapping, 0);
element.store = (NdbDictionary::Object::Store) element.store = (NdbDictionary::Object::Store)
getApiConstant(ListTablesConf::getTableStore(d), objectStoreMapping, 0); getApiConstant(ListTablesConf::getTableStore(d), objectStoreMapping, 0);
element.temp = ListTablesConf::getTableTemp(d);
// table or index name // table or index name
Uint32 n = (data[pos++] + 3) >> 2; Uint32 n = (data[pos++] + 3) >> 2;
BaseString databaseName; BaseString databaseName;
......
...@@ -198,6 +198,7 @@ public: ...@@ -198,6 +198,7 @@ public:
Uint32 m_default_no_part_flag; Uint32 m_default_no_part_flag;
bool m_linear_flag; bool m_linear_flag;
bool m_logging; bool m_logging;
bool m_temporary;
bool m_row_gci; bool m_row_gci;
bool m_row_checksum; bool m_row_checksum;
int m_kvalue; int m_kvalue;
...@@ -273,6 +274,7 @@ public: ...@@ -273,6 +274,7 @@ public:
Vector<int> m_key_ids; Vector<int> m_key_ids;
bool m_logging; bool m_logging;
bool m_temporary;
NdbTableImpl * m_table; NdbTableImpl * m_table;
......
...@@ -421,6 +421,9 @@ ErrorBundle ErrorCodes[] = { ...@@ -421,6 +421,9 @@ ErrorBundle ErrorCodes[] = {
{ 773, DMEC, SE, "Out of string memory, please modify StringMemory config parameter" }, { 773, DMEC, SE, "Out of string memory, please modify StringMemory config parameter" },
{ 775, DMEC, SE, "Create file is not supported when Diskless=1" }, { 775, DMEC, SE, "Create file is not supported when Diskless=1" },
{ 776, DMEC, AE, "Index created on temporary table must itself be temporary" },
{ 777, DMEC, AE, "Cannot create a temporary index on a non-temporary table" },
{ 778, DMEC, AE, "A temporary table or index must be specified as not logging" },
/** /**
* FunctionNotImplemented * FunctionNotImplemented
...@@ -611,7 +614,7 @@ ErrorBundle ErrorCodes[] = { ...@@ -611,7 +614,7 @@ ErrorBundle ErrorCodes[] = {
{ 4272, DMEC, AE, "Table definition has undefined column" }, { 4272, DMEC, AE, "Table definition has undefined column" },
{ 4273, DMEC, IE, "No blob table in dict cache" }, { 4273, DMEC, IE, "No blob table in dict cache" },
{ 4274, DMEC, IE, "Corrupted main table PK in blob operation" }, { 4274, DMEC, IE, "Corrupted main table PK in blob operation" },
{ 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" } { 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" },
}; };
static static
......
...@@ -32,6 +32,7 @@ static Ndb* ndb = 0; ...@@ -32,6 +32,7 @@ static Ndb* ndb = 0;
static const NdbDictionary::Dictionary * dic = 0; static const NdbDictionary::Dictionary * dic = 0;
static int _unqualified = 0; static int _unqualified = 0;
static int _parsable = 0; static int _parsable = 0;
static int show_temp_status = 0;
static void static void
fatal(char const* fmt, ...) fatal(char const* fmt, ...)
...@@ -80,10 +81,20 @@ list(const char * tabname, ...@@ -80,10 +81,20 @@ list(const char * tabname,
if (!_parsable) if (!_parsable)
{ {
if (ndb->usingFullyQualifiedNames()) if (ndb->usingFullyQualifiedNames())
{
if (show_temp_status)
ndbout_c("%-5s %-20s %-8s %-7s %-4s %-12s %-8s %s", "id", "type", "state", "logging", "temp", "database", "schema", "name");
else
ndbout_c("%-5s %-20s %-8s %-7s %-12s %-8s %s", "id", "type", "state", "logging", "database", "schema", "name"); ndbout_c("%-5s %-20s %-8s %-7s %-12s %-8s %s", "id", "type", "state", "logging", "database", "schema", "name");
}
else
{
if (show_temp_status)
ndbout_c("%-5s %-20s %-8s %-7s %-4s %s", "id", "type", "state", "logging", "temp", "name");
else else
ndbout_c("%-5s %-20s %-8s %-7s %s", "id", "type", "state", "logging", "name"); ndbout_c("%-5s %-20s %-8s %-7s %s", "id", "type", "state", "logging", "name");
} }
}
for (unsigned i = 0; i < list.count; i++) { for (unsigned i = 0; i < list.count; i++) {
NdbDictionary::Dictionary::List::Element& elt = list.elements[i]; NdbDictionary::Dictionary::List::Element& elt = list.elements[i];
char type[100]; char type[100];
...@@ -162,32 +173,71 @@ list(const char * tabname, ...@@ -162,32 +173,71 @@ list(const char * tabname,
strcpy(store, "-"); strcpy(store, "-");
else { else {
switch (elt.store) { switch (elt.store) {
case NdbDictionary::Object::StoreTemporary: case NdbDictionary::Object::StoreNotLogged:
strcpy(store, "No"); strcpy(store, "No");
break; break;
case NdbDictionary::Object::StorePermanent: case NdbDictionary::Object::StorePermanent:
strcpy(store, "Yes"); strcpy(store, "Yes");
break; break;
default: default:
sprintf(state, "%d", (int)elt.store); sprintf(store, "%d", (int)elt.store);
break;
}
}
char temp[100];
if (show_temp_status)
{
if (! isTable)
strcpy(temp, "-");
else {
switch (elt.temp) {
case NDB_TEMP_TAB_PERMANENT:
strcpy(temp, "No");
break;
case NDB_TEMP_TAB_TEMPORARY:
strcpy(temp, "Yes");
break;
default:
sprintf(temp, "%d", (int)elt.temp);
break; break;
} }
} }
}
if (ndb->usingFullyQualifiedNames()) if (ndb->usingFullyQualifiedNames())
{ {
if (_parsable) if (_parsable)
{
if (show_temp_status)
ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, temp, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name);
else
ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name); ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name);
}
else
{
if (show_temp_status)
ndbout_c("%-5d %-20s %-8s %-7s %-4s %-12s %-8s %s", elt.id, type, state, store, temp, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name);
else else
ndbout_c("%-5d %-20s %-8s %-7s %-12s %-8s %s", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name); ndbout_c("%-5d %-20s %-8s %-7s %-12s %-8s %s", elt.id, type, state, store, (elt.database)?elt.database:"", (elt.schema)?elt.schema:"", elt.name);
} }
}
else else
{ {
if (_parsable) if (_parsable)
{
if (show_temp_status)
ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, temp, elt.name);
else
ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, elt.name); ndbout_c("%d\t'%s'\t'%s'\t'%s'\t'%s'", elt.id, type, state, store, elt.name);
}
else
{
if (show_temp_status)
ndbout_c("%-5d %-20s %-8s %-7s %-4s %s", elt.id, type, state, store, temp, elt.name);
else else
ndbout_c("%-5d %-20s %-8s %-7s %s", elt.id, type, state, store, elt.name); ndbout_c("%-5d %-20s %-8s %-7s %s", elt.id, type, state, store, elt.name);
} }
} }
}
if (_parsable) if (_parsable)
exit(0); exit(0);
} }
...@@ -197,6 +247,10 @@ NDB_STD_OPTS_VARS; ...@@ -197,6 +247,10 @@ NDB_STD_OPTS_VARS;
static const char* _dbname = "TEST_DB"; static const char* _dbname = "TEST_DB";
static int _loops; static int _loops;
static int _type; static int _type;
enum options_ndb_show_tables
{
OPT_SHOW_TMP_STATUS=256,
};
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
NDB_STD_OPTS("ndb_show_tables"), NDB_STD_OPTS("ndb_show_tables"),
...@@ -215,6 +269,9 @@ static struct my_option my_long_options[] = ...@@ -215,6 +269,9 @@ static struct my_option my_long_options[] =
{ "parsable", 'p', "Return output suitable for mysql LOAD DATA INFILE", { "parsable", 'p', "Return output suitable for mysql LOAD DATA INFILE",
(gptr*) &_parsable, (gptr*) &_parsable, 0, (gptr*) &_parsable, (gptr*) &_parsable, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "show-temp-status", OPT_SHOW_TMP_STATUS, "Show table temporary flag",
(gptr*) &show_temp_status, (gptr*) &show_temp_status, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static void usage() static void usage()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment