Below is the list of changes that have just been committed into a local
5.1 repository of marty. When marty 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
1.1893 05/11/09 10:19:33 mskold@stripped +10 -0
Merge mskold@stripped:/home/bk/mysql-5.1-new
into mysql.com:/usr/local/home/marty/MySQL/mysql-5.1
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
1.95 05/11/09 10:19:28 mskold@stripped +1 -46
Merge
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
1.58 05/11/09 10:19:28 mskold@stripped +0 -41
Merge
storage/ndb/include/util/UtilBuffer.hpp
1.7 05/11/09 10:19:28 mskold@stripped +0 -2
Merge
storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
1.38 05/11/09 10:17:32 mskold@stripped +0 -4
Auto merged
storage/ndb/src/ndbapi/NdbDictionary.cpp
1.42 05/11/09 10:17:32 mskold@stripped +0 -3
Auto merged
storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp
1.22 05/11/09 10:17:31 mskold@stripped +0 -5
Auto merged
storage/ndb/include/util/BaseString.hpp
1.10 05/11/09 10:17:31 mskold@stripped +0 -12
Auto merged
storage/ndb/include/kernel/signaldata/AlterTable.hpp
1.7 05/11/09 10:17:31 mskold@stripped +0 -17
Auto merged
sql/ha_ndbcluster.h
1.98 05/11/09 10:17:31 mskold@stripped +0 -0
Auto merged
sql/ha_ndbcluster.cc
1.213 05/11/09 10:17:31 mskold@stripped +0 -0
Auto merged
# 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: mskold
# Host: blowfish.ndb.mysql.com
# Root: /usr/local/home/marty/MySQL/mysql-5.1/RESYNC
--- 1.6/storage/ndb/include/util/UtilBuffer.hpp 2005-09-13 15:02:30 +02:00
+++ 1.7/storage/ndb/include/util/UtilBuffer.hpp 2005-11-09 10:19:28 +01:00
@@ -84,11 +84,11 @@
len = 0;
}
- int length() const { return len; };
+ int length() const { return len; }
- bool empty() const { return (len == 0); };
+ void *get_data() const { return data; }
- void *get_data() const { return data; };
+ bool empty () const { return len == 0; }
private:
void *data; /* Pointer to data storage */
size_t len; /* Size of the stored data */
--- 1.57/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2005-11-07 11:57:34 +01:00
+++ 1.58/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2005-11-09 10:19:28 +01:00
@@ -55,6 +55,10 @@
#include <signaldata/DropIndx.hpp>
#include <signaldata/BuildIndx.hpp>
+#include <signaldata/DropFilegroup.hpp>
+#include <signaldata/CreateFilegroup.hpp>
+#include <signaldata/CreateFilegroupImpl.hpp>
+
#include <signaldata/CreateEvnt.hpp>
#include <signaldata/UtilPrepare.hpp>
#include <signaldata/UtilExecute.hpp>
@@ -78,6 +82,10 @@
#include <NdbSleep.h>
#include <signaldata/ApiBroadcast.hpp>
+#include <signaldata/DropObj.hpp>
+#include <signaldata/CreateObj.hpp>
+#include <SLList.hpp>
+
#define ZNOT_FOUND 626
#define ZALREADYEXIST 630
@@ -85,29 +93,122 @@
//#define EVENT_PH3_DEBUG
//#define EVENT_DEBUG
+static const char EVENT_SYSTEM_TABLE_NAME[] = "sys/def/NDB$EVENTS_0";
+
#define EVENT_TRACE \
// ndbout_c("Event debug trace: File: %s Line: %u", __FILE__, __LINE__)
#define DIV(x,y) (((x)+(y)-1)/(y))
+#define WORDS2PAGES(x) DIV(x, (ZSIZE_OF_PAGES_IN_WORDS - ZPAGE_HEADER_SIZE))
#include <ndb_version.h>
static
+struct {
+ Uint32 m_gsn_user_req;
+ Uint32 m_gsn_req;
+ Uint32 m_gsn_ref;
+ Uint32 m_gsn_conf;
+ void (Dbdict::* m_trans_commit_start)(Signal*, Dbdict::SchemaTransaction*);
+ void (Dbdict::* m_trans_commit_complete)(Signal*,Dbdict::SchemaTransaction*);
+ void (Dbdict::* m_trans_abort_start)(Signal*, Dbdict::SchemaTransaction*);
+ void (Dbdict::* m_trans_abort_complete)(Signal*, Dbdict::SchemaTransaction*);
+
+ void (Dbdict::* m_prepare_start)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_prepare_complete)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_commit)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_commit_start)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_commit_complete)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_abort)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_abort_start)(Signal*, Dbdict::SchemaOp*);
+ void (Dbdict::* m_abort_complete)(Signal*, Dbdict::SchemaOp*);
+
+} f_dict_op[] = {
+ /**
+ * Create filegroup
+ */
+ {
+ GSN_CREATE_FILEGROUP_REQ,
+ GSN_CREATE_OBJ_REQ, GSN_CREATE_OBJ_REF, GSN_CREATE_OBJ_CONF,
+ 0, 0, 0, 0,
+ &Dbdict::create_fg_prepare_start, &Dbdict::create_fg_prepare_complete,
+ &Dbdict::createObj_commit,
+ 0, 0,
+ &Dbdict::createObj_abort,
+ &Dbdict::create_fg_abort_start, &Dbdict::create_fg_abort_complete,
+ }
+
+ /**
+ * Create file
+ */
+ ,{
+ GSN_CREATE_FILE_REQ,
+ GSN_CREATE_OBJ_REQ, GSN_CREATE_OBJ_REF, GSN_CREATE_OBJ_CONF,
+ 0, 0, 0, 0,
+ &Dbdict::create_file_prepare_start, &Dbdict::create_file_prepare_complete,
+ &Dbdict::createObj_commit,
+ &Dbdict::create_file_commit_start, 0,
+ &Dbdict::createObj_abort,
+ &Dbdict::create_file_abort_start, &Dbdict::create_file_abort_complete,
+ }
+
+ /**
+ * Drop file
+ */
+ ,{
+ GSN_DROP_FILE_REQ,
+ GSN_DROP_OBJ_REQ, GSN_DROP_OBJ_REF, GSN_DROP_OBJ_CONF,
+ 0, 0, 0, 0,
+ &Dbdict::drop_file_prepare_start, 0,
+ &Dbdict::dropObj_commit,
+ &Dbdict::drop_file_commit_start, &Dbdict::drop_file_commit_complete,
+ &Dbdict::dropObj_abort,
+ &Dbdict::drop_file_abort_start, 0
+ }
+
+ /**
+ * Drop filegroup
+ */
+ ,{
+ GSN_DROP_FILEGROUP_REQ,
+ GSN_DROP_OBJ_REQ, GSN_DROP_OBJ_REF, GSN_DROP_OBJ_CONF,
+ 0, 0, 0, 0,
+ &Dbdict::drop_fg_prepare_start, 0,
+ &Dbdict::dropObj_commit,
+ &Dbdict::drop_fg_commit_start, &Dbdict::drop_fg_commit_complete,
+ &Dbdict::dropObj_abort,
+ &Dbdict::drop_fg_abort_start, 0
+ }
+
+ /**
+ * Drop undofile
+ */
+ ,{
+ GSN_DROP_FILE_REQ,
+ GSN_DROP_OBJ_REQ, GSN_DROP_OBJ_REF, GSN_DROP_OBJ_CONF,
+ 0, 0, 0, 0,
+ &Dbdict::drop_undofile_prepare_start, 0,
+ 0,
+ 0, 0,
+ 0, 0
+ }
+};
+
Uint32
-alter_table_inc_schema_version(Uint32 old)
+alter_obj_inc_schema_version(Uint32 old)
{
return (old & 0x00FFFFFF) + ((old + 0x1000000) & 0xFF000000);
}
static
Uint32
-alter_table_dec_schema_version(Uint32 old)
+alter_obj_dec_schema_version(Uint32 old)
{
return (old & 0x00FFFFFF) + ((old - 0x1000000) & 0xFF000000);
}
static
Uint32
-create_table_inc_schema_version(Uint32 old)
+create_obj_inc_schema_version(Uint32 old)
{
return (old + 0x00000001) & 0x00FFFFFF;
}
@@ -177,6 +278,14 @@
DropTableReq::SignalLength, JBB);
}
#endif
+#define MEMINFO(x, y) infoEvent(x ": %d %d", y.getSize(), y.getNoOfFree())
+ if(signal->theData[0] == 1226){
+ MEMINFO("c_obj_pool", c_obj_pool);
+ MEMINFO("c_file_pool", c_file_pool);
+ MEMINFO("c_filegroup_pool", c_filegroup_pool);
+ MEMINFO("c_opRecordPool", c_opRecordPool);
+ MEMINFO("c_rope_pool", c_rope_pool);
+ }
return;
}//Dbdict::execDUMP_STATE_ORD()
@@ -193,7 +302,7 @@
switch (signal->theData[0]) {
case ZPACK_TABLE_INTO_PAGES :
jam();
- packTableIntoPages(signal, signal->theData[1], signal->theData[2]);
+ packTableIntoPages(signal);
break;
case ZSEND_GET_TAB_RESPONSE :
@@ -214,32 +323,67 @@
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */
-void Dbdict::packTableIntoPages(Signal* signal, Uint32 tableId, Uint32 pageId)
+void Dbdict::packTableIntoPages(Signal* signal)
{
+ const Uint32 tableId= signal->theData[1];
+ const Uint32 type= signal->theData[2];
+ const Uint32 pageId= signal->theData[3];
PageRecordPtr pagePtr;
- TableRecordPtr tablePtr;
c_pageRecordArray.getPtr(pagePtr, pageId);
-
+
memset(&pagePtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
- c_tableRecordPool.getPtr(tablePtr, tableId);
LinearWriter w(&pagePtr.p->word[ZPAGE_HEADER_SIZE],
8 * ZSIZE_OF_PAGES_IN_WORDS);
-
w.first();
- packTableIntoPagesImpl(w, tablePtr, signal);
-
+ switch((DictTabInfo::TableType)type) {
+ case DictTabInfo::SystemTable:
+ case DictTabInfo::UserTable:
+ case DictTabInfo::UniqueHashIndex:
+ case DictTabInfo::HashIndex:
+ case DictTabInfo::UniqueOrderedIndex:
+ case DictTabInfo::OrderedIndex:{
+ jam();
+ TableRecordPtr tablePtr;
+ c_tableRecordPool.getPtr(tablePtr, tableId);
+ packTableIntoPages(w, tablePtr, signal);
+ break;
+ }
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:{
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, tableId));
+ packFilegroupIntoPages(w, fg_ptr);
+ break;
+ }
+ case DictTabInfo::Datafile:{
+ FilePtr fg_ptr;
+ ndbrequire(c_file_hash.find(fg_ptr, tableId));
+ const Uint32 free_extents= signal->theData[4];
+ packFileIntoPages(w, fg_ptr, free_extents);
+ break;
+ }
+ case DictTabInfo::Undofile:{
+ FilePtr fg_ptr;
+ ndbrequire(c_file_hash.find(fg_ptr, tableId));
+ packFileIntoPages(w, fg_ptr, 0);
+ break;
+ }
+ case DictTabInfo::UndefTableType:
+ case DictTabInfo::HashIndexTrigger:
+ case DictTabInfo::SubscriptionTrigger:
+ case DictTabInfo::ReadOnlyConstraint:
+ case DictTabInfo::IndexTrigger:
+ ndbrequire(false);
+ }
+
Uint32 wordsOfTable = w.getWordsUsed();
- Uint32 pagesUsed =
- DIV(wordsOfTable + ZPAGE_HEADER_SIZE, ZSIZE_OF_PAGES_IN_WORDS);
+ Uint32 pagesUsed = WORDS2PAGES(wordsOfTable);
pagePtr.p->word[ZPOS_CHECKSUM] =
computeChecksum(&pagePtr.p->word[0], pagesUsed * ZSIZE_OF_PAGES_IN_WORDS);
switch (c_packTable.m_state) {
case PackTable::PTS_IDLE:
- case PackTable::PTS_ADD_TABLE_MASTER:
- case PackTable::PTS_ADD_TABLE_SLAVE:
- case PackTable::PTS_RESTART:
ndbrequire(false);
break;
case PackTable::PTS_GET_TAB:
@@ -255,17 +399,20 @@
}//packTableIntoPages()
void
-Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w,
+Dbdict::packTableIntoPages(SimpleProperties::Writer & w,
TableRecordPtr tablePtr,
Signal* signal){
- w.add(DictTabInfo::TableName, tablePtr.p->tableName);
+ union {
+ char tableName[MAX_TAB_NAME_SIZE];
+ char frmData[MAX_FRM_DATA_SIZE];
+ char defaultValue[MAX_ATTR_DEFAULT_VALUE_SIZE];
+ char attributeName[MAX_ATTR_NAME_SIZE];
+ };
+ ConstRope r(c_rope_pool, tablePtr.p->tableName);
+ r.copy(tableName);
+ w.add(DictTabInfo::TableName, tableName);
w.add(DictTabInfo::TableId, tablePtr.i);
-#ifdef HAVE_TABLE_REORG
- w.add(DictTabInfo::SecondTableId, tablePtr.p->secondTable);
-#else
- w.add(DictTabInfo::SecondTableId, (Uint32)0);
-#endif
w.add(DictTabInfo::TableVersion, tablePtr.p->tableVersion);
w.add(DictTabInfo::NoOfKeyAttr, tablePtr.p->noOfPrimkey);
w.add(DictTabInfo::NoOfAttributes, tablePtr.p->noOfAttributes);
@@ -307,7 +454,9 @@
if (tablePtr.p->primaryTableId != RNIL){
TableRecordPtr primTab;
c_tableRecordPool.getPtr(primTab, tablePtr.p->primaryTableId);
- w.add(DictTabInfo::PrimaryTable, primTab.p->tableName);
+ ConstRope r2(c_rope_pool, primTab.p->tableName);
+ r2.copy(tableName);
+ w.add(DictTabInfo::PrimaryTable, tableName);
w.add(DictTabInfo::PrimaryTableId, tablePtr.p->primaryTableId);
w.add(DictTabInfo::IndexState, tablePtr.p->indexState);
w.add(DictTabInfo::InsertTriggerId, tablePtr.p->insertTriggerId);
@@ -315,16 +464,31 @@
w.add(DictTabInfo::DeleteTriggerId, tablePtr.p->deleteTriggerId);
w.add(DictTabInfo::CustomTriggerId, tablePtr.p->customTriggerId);
}
- w.add(DictTabInfo::FrmLen, tablePtr.p->frmLen);
- w.add(DictTabInfo::FrmData, tablePtr.p->frmData, tablePtr.p->frmLen);
+
+ ConstRope frm(c_rope_pool, tablePtr.p->frmData);
+ frm.copy(frmData);
- Uint32 nextAttribute = tablePtr.p->firstAttribute;
+ w.add(DictTabInfo::FrmLen, frm.size());
+ w.add(DictTabInfo::FrmData, frmData, frm.size());
+
+ if(tablePtr.p->m_tablespace_id != RNIL)
+ {
+ w.add(DictTabInfo::TablespaceId, tablePtr.p->m_tablespace_id);
+ FilegroupPtr tsPtr;
+ ndbrequire(c_filegroup_hash.find(tsPtr, tablePtr.p->m_tablespace_id));
+ w.add(DictTabInfo::TablespaceVersion, tsPtr.p->m_version);
+ }
+
AttributeRecordPtr attrPtr;
- do {
+ LocalDLFifoList<AttributeRecord> list(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+ for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr)){
jam();
- c_attributeRecordPool.getPtr(attrPtr, nextAttribute);
-
- w.add(DictTabInfo::AttributeName, attrPtr.p->attributeName);
+
+ ConstRope name(c_rope_pool, attrPtr.p->attributeName);
+ name.copy(attributeName);
+
+ w.add(DictTabInfo::AttributeName, attributeName);
w.add(DictTabInfo::AttributeId, attrPtr.p->attributeId);
w.add(DictTabInfo::AttributeKeyFlag, attrPtr.p->tupleKey > 0);
@@ -332,12 +496,16 @@
const Uint32 attrType = AttributeDescriptor::getType(desc);
const Uint32 attrSize = AttributeDescriptor::getSize(desc);
const Uint32 arraySize = AttributeDescriptor::getArraySize(desc);
+ const Uint32 arrayType = AttributeDescriptor::getArrayType(desc);
const Uint32 nullable = AttributeDescriptor::getNullable(desc);
const Uint32 DKey = AttributeDescriptor::getDKey(desc);
+ const Uint32 disk= AttributeDescriptor::getDiskBased(desc);
+
// AttributeType deprecated
w.add(DictTabInfo::AttributeSize, attrSize);
w.add(DictTabInfo::AttributeArraySize, arraySize);
+ w.add(DictTabInfo::AttributeArrayType, arrayType);
w.add(DictTabInfo::AttributeNullableFlag, nullable);
w.add(DictTabInfo::AttributeDKey, DKey);
w.add(DictTabInfo::AttributeExtType, attrType);
@@ -346,15 +514,88 @@
w.add(DictTabInfo::AttributeExtLength, attrPtr.p->extLength);
w.add(DictTabInfo::AttributeAutoIncrement,
(Uint32)attrPtr.p->autoIncrement);
- w.add(DictTabInfo::AttributeDefaultValue, attrPtr.p->defaultValue);
+
+ if(disk)
+ w.add(DictTabInfo::AttributeStorageType, (Uint32)NDB_STORAGETYPE_DISK);
+ else
+ w.add(DictTabInfo::AttributeStorageType, (Uint32)NDB_STORAGETYPE_MEMORY);
+
+ ConstRope def(c_rope_pool, attrPtr.p->defaultValue);
+ def.copy(defaultValue);
+ w.add(DictTabInfo::AttributeDefaultValue, defaultValue);
w.add(DictTabInfo::AttributeEnd, 1);
- nextAttribute = attrPtr.p->nextAttrInTable;
- } while (nextAttribute != RNIL);
+ }
w.add(DictTabInfo::TableEnd, 1);
}
+void
+Dbdict::packFilegroupIntoPages(SimpleProperties::Writer & w,
+ FilegroupPtr fg_ptr){
+
+ DictFilegroupInfo::Filegroup fg; fg.init();
+ ConstRope r(c_rope_pool, fg_ptr.p->m_name);
+ r.copy(fg.FilegroupName);
+
+ fg.FilegroupId = fg_ptr.p->key;
+ fg.FilegroupType = fg_ptr.p->m_type;
+ fg.FilegroupVersion = fg_ptr.p->m_version;
+
+ switch(fg.FilegroupType){
+ case DictTabInfo::Tablespace:
+ //fg.TS_DataGrow = group.m_grow_spec;
+ fg.TS_ExtentSize = fg_ptr.p->m_tablespace.m_extent_size;
+ fg.TS_LogfileGroupId = fg_ptr.p->m_tablespace.m_default_logfile_group_id;
+ FilegroupPtr lfg_ptr;
+ ndbrequire(c_filegroup_hash.find(lfg_ptr, fg.TS_LogfileGroupId));
+ fg.TS_LogfileGroupVersion = lfg_ptr.p->m_version;
+ break;
+ case DictTabInfo::LogfileGroup:
+ fg.LF_UndoBufferSize = fg_ptr.p->m_logfilegroup.m_undo_buffer_size;
+ //fg.LF_UndoGrow = ;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ SimpleProperties::UnpackStatus s;
+ s = SimpleProperties::pack(w,
+ &fg,
+ DictFilegroupInfo::Mapping,
+ DictFilegroupInfo::MappingSize, true);
+
+ ndbrequire(s == SimpleProperties::Eof);
+}
+
+void
+Dbdict::packFileIntoPages(SimpleProperties::Writer & w,
+ FilePtr f_ptr, const Uint32 free_extents){
+
+ DictFilegroupInfo::File f; f.init();
+ ConstRope r(c_rope_pool, f_ptr.p->m_path);
+ r.copy(f.FileName);
+
+ f.FileType = f_ptr.p->m_type;
+ f.FilegroupId = f_ptr.p->m_filegroup_id;; //group.m_id;
+ f.FileSizeHi = (f_ptr.p->m_file_size >> 32);
+ f.FileSizeLo = (f_ptr.p->m_file_size & 0xFFFFFFFF);
+ f.FileFreeExtents= free_extents;
+ f.FileNo = f_ptr.p->key;
+
+ FilegroupPtr lfg_ptr;
+ ndbrequire(c_filegroup_hash.find(lfg_ptr, f.FilegroupId));
+ f.FilegroupVersion = lfg_ptr.p->m_version;
+
+ SimpleProperties::UnpackStatus s;
+ s = SimpleProperties::pack(w,
+ &f,
+ DictFilegroupInfo::FileMapping,
+ DictFilegroupInfo::FileMappingSize, true);
+
+ ndbrequire(s == SimpleProperties::Eof);
+}
+
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */
// The routines to handle responses from file system.
@@ -564,15 +805,14 @@
ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE);
- Uint32 sz = tabInfoPtr.sz + ZPAGE_HEADER_SIZE;
-
- c_writeTableRecord.noOfPages = DIV(sz, ZSIZE_OF_PAGES_IN_WORDS);
+ Uint32 pages = WORDS2PAGES(tabInfoPtr.sz);
+ c_writeTableRecord.no_of_words = tabInfoPtr.sz;
c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK;
c_writeTableRecord.m_callback = * callback;
c_writeTableRecord.pageId = 0;
- ndbrequire(c_writeTableRecord.noOfPages < 8);
-
+ ndbrequire(pages == 1);
+
PageRecordPtr pageRecPtr;
c_pageRecordArray.getPtr(pageRecPtr, c_writeTableRecord.pageId);
copy(&pageRecPtr.p->word[ZPAGE_HEADER_SIZE], tabInfoPtr);
@@ -580,10 +820,9 @@
memset(&pageRecPtr.p->word[0], 0, 4 * ZPAGE_HEADER_SIZE);
pageRecPtr.p->word[ZPOS_CHECKSUM] =
computeChecksum(&pageRecPtr.p->word[0],
- c_writeTableRecord.noOfPages * ZSIZE_OF_PAGES_IN_WORDS);
+ pages * ZSIZE_OF_PAGES_IN_WORDS);
startWriteTableFile(signal, tableId);
-
}
void Dbdict::startWriteTableFile(Signal* signal, Uint32 tableId)
@@ -602,9 +841,7 @@
Uint32 tableId,
bool writeFlag)
{
- TableRecordPtr tablePtr;
FsOpenReq * const fsOpenReq = (FsOpenReq *)&signal->theData[0];
- c_tableRecordPool.getPtr(tablePtr, tableId);
fsOpenReq->userReference = reference();
fsOpenReq->userPointer = fsConPtr;
@@ -619,14 +856,13 @@
jam();
fsOpenReq->fileFlags = FsOpenReq::OM_READONLY;
}//if
-
fsOpenReq->fileNumber[3] = 0; // Initialise before byte changes
FsOpenReq::setVersion(fsOpenReq->fileNumber, 1);
FsOpenReq::setSuffix(fsOpenReq->fileNumber, FsOpenReq::S_TABLELIST);
FsOpenReq::v1_setDisk(fsOpenReq->fileNumber, (fileNo + 1));
FsOpenReq::v1_setTable(fsOpenReq->fileNumber, tableId);
FsOpenReq::v1_setFragment(fsOpenReq->fileNumber, (Uint32)-1);
- FsOpenReq::v1_setS(fsOpenReq->fileNumber, tablePtr.p->tableVersion);
+ FsOpenReq::v1_setS(fsOpenReq->fileNumber, 0);
FsOpenReq::v1_setP(fsOpenReq->fileNumber, 255);
/* ---------------------------------------------------------------- */
// File name : D1/DBDICT/T0/S1.TableList
@@ -650,7 +886,7 @@
FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
FsReadWriteReq::fsFormatArrayOfPages);
fsRWReq->varIndex = ZBAT_TABLE_FILE;
- fsRWReq->numberOfPages = c_writeTableRecord.noOfPages;
+ fsRWReq->numberOfPages = WORDS2PAGES(c_writeTableRecord.no_of_words);
fsRWReq->data.arrayOfPages.varIndex = c_writeTableRecord.pageId;
fsRWReq->data.arrayOfPages.fileOffset = 0; // Write to file page 0
sendSignal(NDBFS_REF, GSN_FSWRITEREQ, signal, 8, JBA);
@@ -727,7 +963,7 @@
FsReadWriteReq::setFormatFlag(fsRWReq->operationFlag,
FsReadWriteReq::fsFormatArrayOfPages);
fsRWReq->varIndex = ZBAT_TABLE_FILE;
- fsRWReq->numberOfPages = c_readTableRecord.noOfPages;
+ fsRWReq->numberOfPages = WORDS2PAGES(c_readTableRecord.no_of_words);
fsRWReq->data.arrayOfPages.varIndex = c_readTableRecord.pageId;
fsRWReq->data.arrayOfPages.fileOffset = 0; // Write to file page 0
sendSignal(NDBFS_REF, GSN_FSREADREQ, signal, 8, JBA);
@@ -750,7 +986,8 @@
PageRecordPtr tmpPagePtr;
c_pageRecordArray.getPtr(tmpPagePtr, c_readTableRecord.pageId);
- Uint32 sz = c_readTableRecord.noOfPages * ZSIZE_OF_PAGES_IN_WORDS;
+ Uint32 sz =
+ WORDS2PAGES(c_readTableRecord.no_of_words)*ZSIZE_OF_PAGES_IN_WORDS;
Uint32 chk = computeChecksum((const Uint32*)tmpPagePtr.p, sz);
ndbrequire((chk == 0) || !crashInd);
@@ -809,7 +1046,7 @@
case SchemaFile::ADD_STARTED:
jam();
ok = true;
- ndbrequire(create_table_inc_schema_version(oldVersion) == newVersion);
+ ndbrequire(create_obj_inc_schema_version(oldVersion) == newVersion);
ndbrequire(oldState == SchemaFile::INIT ||
oldState == SchemaFile::DROP_TABLE_COMMITTED);
break;
@@ -817,12 +1054,13 @@
jam();
ok = true;
ndbrequire(newVersion == oldVersion);
- ndbrequire(oldState == SchemaFile::ADD_STARTED);
+ ndbrequire(oldState == SchemaFile::ADD_STARTED ||
+ oldState == SchemaFile::DROP_TABLE_STARTED);
break;
case SchemaFile::ALTER_TABLE_COMMITTED:
jam();
ok = true;
- ndbrequire(alter_table_inc_schema_version(oldVersion) == newVersion);
+ ndbrequire(alter_obj_inc_schema_version(oldVersion) == newVersion);
ndbrequire(oldState == SchemaFile::TABLE_ADD_COMMITTED ||
oldState == SchemaFile::ALTER_TABLE_COMMITTED);
break;
@@ -831,7 +1069,6 @@
case SchemaFile::DROP_TABLE_COMMITTED:
jam();
ok = true;
- ndbrequire(false);
break;
case SchemaFile::INIT:
jam();
@@ -1189,9 +1426,10 @@
Dbdict::Dbdict(const class Configuration & conf):
SimulatedBlock(DBDICT, conf),
- c_tableRecordHash(c_tableRecordPool),
c_attributeRecordHash(c_attributeRecordPool),
- c_triggerRecordHash(c_triggerRecordPool),
+ c_file_hash(c_file_pool),
+ c_filegroup_hash(c_filegroup_pool),
+ c_obj_hash(c_obj_pool),
c_opCreateTable(c_opRecordPool),
c_opDropTable(c_opRecordPool),
c_opCreateIndex(c_opRecordPool),
@@ -1205,7 +1443,12 @@
c_opCreateTrigger(c_opRecordPool),
c_opDropTrigger(c_opRecordPool),
c_opAlterTrigger(c_opRecordPool),
+ c_schemaOp(c_opRecordPool),
+ c_Trans(c_opRecordPool),
+ c_opCreateObj(c_schemaOp),
+ c_opDropObj(c_schemaOp),
c_opRecordSequence(0)
+
{
BLOCK_CONSTRUCTOR(Dbdict);
@@ -1345,7 +1588,39 @@
addRecSignal(GSN_DROP_TAB_REF, &Dbdict::execDROP_TAB_REF);
addRecSignal(GSN_DROP_TAB_CONF, &Dbdict::execDROP_TAB_CONF);
+ addRecSignal(GSN_CREATE_FILE_REQ, &Dbdict::execCREATE_FILE_REQ);
+ addRecSignal(GSN_CREATE_FILEGROUP_REQ, &Dbdict::execCREATE_FILEGROUP_REQ);
+
+ addRecSignal(GSN_DROP_FILE_REQ, &Dbdict::execDROP_FILE_REQ);
+ addRecSignal(GSN_DROP_FILE_REF, &Dbdict::execDROP_FILE_REF);
+ addRecSignal(GSN_DROP_FILE_CONF, &Dbdict::execDROP_FILE_CONF);
+
+ addRecSignal(GSN_DROP_FILEGROUP_REQ, &Dbdict::execDROP_FILEGROUP_REQ);
+ addRecSignal(GSN_DROP_FILEGROUP_REF, &Dbdict::execDROP_FILEGROUP_REF);
+ addRecSignal(GSN_DROP_FILEGROUP_CONF, &Dbdict::execDROP_FILEGROUP_CONF);
+
+ addRecSignal(GSN_CREATE_OBJ_REQ, &Dbdict::execCREATE_OBJ_REQ);
+ addRecSignal(GSN_CREATE_OBJ_REF, &Dbdict::execCREATE_OBJ_REF);
+ addRecSignal(GSN_CREATE_OBJ_CONF, &Dbdict::execCREATE_OBJ_CONF);
+ addRecSignal(GSN_DROP_OBJ_REQ, &Dbdict::execDROP_OBJ_REQ);
+ addRecSignal(GSN_DROP_OBJ_REF, &Dbdict::execDROP_OBJ_REF);
+ addRecSignal(GSN_DROP_OBJ_CONF, &Dbdict::execDROP_OBJ_CONF);
+
+ addRecSignal(GSN_CREATE_FILE_REF, &Dbdict::execCREATE_FILE_REF);
+ addRecSignal(GSN_CREATE_FILE_CONF, &Dbdict::execCREATE_FILE_CONF);
+ addRecSignal(GSN_CREATE_FILEGROUP_REF, &Dbdict::execCREATE_FILEGROUP_REF);
+ addRecSignal(GSN_CREATE_FILEGROUP_CONF, &Dbdict::execCREATE_FILEGROUP_CONF);
+
addRecSignal(GSN_BACKUP_FRAGMENT_REQ, &Dbdict::execBACKUP_FRAGMENT_REQ);
+
+ addRecSignal(GSN_DICT_COMMIT_REQ, &Dbdict::execDICT_COMMIT_REQ);
+ addRecSignal(GSN_DICT_COMMIT_REF, &Dbdict::execDICT_COMMIT_REF);
+ addRecSignal(GSN_DICT_COMMIT_CONF, &Dbdict::execDICT_COMMIT_CONF);
+
+ addRecSignal(GSN_DICT_ABORT_REQ, &Dbdict::execDICT_ABORT_REQ);
+ addRecSignal(GSN_DICT_ABORT_REF, &Dbdict::execDICT_ABORT_REF);
+ addRecSignal(GSN_DICT_ABORT_CONF, &Dbdict::execDICT_ABORT_CONF);
+
}//Dbdict::Dbdict()
Dbdict::~Dbdict()
@@ -1403,7 +1678,7 @@
void Dbdict::initReadTableRecord()
{
- c_readTableRecord.noOfPages = (Uint32)-1;
+ c_readTableRecord.no_of_words= 0;
c_readTableRecord.pageId = RNIL;
c_readTableRecord.tableId = ZNIL;
c_readTableRecord.inUse = false;
@@ -1411,7 +1686,7 @@
void Dbdict::initWriteTableRecord()
{
- c_writeTableRecord.noOfPages = (Uint32)-1;
+ c_writeTableRecord.no_of_words= 0;
c_writeTableRecord.pageId = RNIL;
c_writeTableRecord.noOfTableFilesHandled = 3;
c_writeTableRecord.tableId = ZNIL;
@@ -1453,6 +1728,7 @@
{
c_restartRecord.gciToRestart = 0;
c_restartRecord.activeTable = ZNIL;
+ c_restartRecord.m_pass = 0;
}//Dbdict::initRestartRecord()
void Dbdict::initNodeRecords()
@@ -1491,25 +1767,21 @@
void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr)
{
+ new (tablePtr.p) TableRecord();
tablePtr.p->activePage = RNIL;
tablePtr.p->filePtr[0] = RNIL;
tablePtr.p->filePtr[1] = RNIL;
- tablePtr.p->firstAttribute = RNIL;
tablePtr.p->firstPage = RNIL;
- tablePtr.p->lastAttribute = RNIL;
tablePtr.p->tableId = tablePtr.i;
tablePtr.p->tableVersion = (Uint32)-1;
tablePtr.p->tabState = TableRecord::NOT_DEFINED;
tablePtr.p->tabReturnState = TableRecord::TRS_IDLE;
tablePtr.p->fragmentType = DictTabInfo::AllNodesSmallTable;
- memset(tablePtr.p->tableName, 0, sizeof(tablePtr.p->tableName));
tablePtr.p->gciTableCreated = 0;
tablePtr.p->noOfAttributes = ZNIL;
tablePtr.p->noOfNullAttr = 0;
tablePtr.p->ngLen = 0;
memset(tablePtr.p->ngData, 0, sizeof(tablePtr.p->ngData));
- tablePtr.p->frmLen = 0;
- memset(tablePtr.p->frmData, 0, sizeof(tablePtr.p->frmData));
tablePtr.p->fragmentCount = 0;
/*
tablePtr.p->lh3PageIndexBits = 0;
@@ -1552,9 +1824,9 @@
void Dbdict::initialiseTriggerRecord(TriggerRecordPtr triggerPtr)
{
+ new (triggerPtr.p) TriggerRecord();
triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
triggerPtr.p->triggerLocal = 0;
- memset(triggerPtr.p->triggerName, 0, sizeof(triggerPtr.p->triggerName));
triggerPtr.p->triggerId = RNIL;
triggerPtr.p->tableId = RNIL;
triggerPtr.p->triggerType = (TriggerType::Value)~0;
@@ -1577,53 +1849,50 @@
return fsPtr.i;
}//Dbdict::getFsConnRecord()
+/*
+ * Search schemafile for free entry. Its index is used as 'logical id'
+ * of new disk-stored object.
+ */
+Uint32 Dbdict::getFreeObjId(Uint32 minId)
+{
+ const XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ Uint32 noOfPages = xsf->noOfPages;
+ Uint32 n, i;
+ for (n = 0; n < noOfPages; n++) {
+ jam();
+ const SchemaFile * sf = &xsf->schemaPage[n];
+ for (i = 0; i < NDB_SF_PAGE_ENTRIES; i++) {
+ const SchemaFile::TableEntry& te = sf->TableEntries[i];
+ if (te.m_tableState == (Uint32)SchemaFile::INIT ||
+ te.m_tableState == (Uint32)SchemaFile::DROP_TABLE_COMMITTED) {
+ // minId is obsolete anyway
+ if (minId <= n * NDB_SF_PAGE_ENTRIES + i)
+ return n * NDB_SF_PAGE_ENTRIES + i;
+ }
+ }
+ }
+ return RNIL;
+}
+
Uint32 Dbdict::getFreeTableRecord(Uint32 primaryTableId)
{
Uint32 minId = (primaryTableId == RNIL ? 0 : primaryTableId + 1);
- TableRecordPtr tablePtr;
- TableRecordPtr firstTablePtr;
- bool firstFound = false;
- Uint32 tabSize = c_tableRecordPool.getSize();
- for (tablePtr.i = minId; tablePtr.i < tabSize ; tablePtr.i++) {
- jam();
- c_tableRecordPool.getPtr(tablePtr);
- if (tablePtr.p->tabState == TableRecord::NOT_DEFINED) {
- jam();
- initialiseTableRecord(tablePtr);
- tablePtr.p->tabState = TableRecord::DEFINING;
- firstFound = true;
- firstTablePtr.i = tablePtr.i;
- firstTablePtr.p = tablePtr.p;
- break;
- }//if
- }//for
- if (!firstFound) {
+ Uint32 i = getFreeObjId(minId);
+ if (i == RNIL) {
jam();
return RNIL;
- }//if
-#ifdef HAVE_TABLE_REORG
- bool secondFound = false;
- for (tablePtr.i = firstTablePtr.i + 1; tablePtr.i < tabSize ; tablePtr.i++) {
- jam();
- c_tableRecordPool.getPtr(tablePtr);
- if (tablePtr.p->tabState == TableRecord::NOT_DEFINED) {
- jam();
- initialiseTableRecord(tablePtr);
- tablePtr.p->tabState = TableRecord::REORG_TABLE_PREPARED;
- tablePtr.p->secondTable = firstTablePtr.i;
- firstTablePtr.p->secondTable = tablePtr.i;
- secondFound = true;
- break;
- }//if
- }//for
- if (!secondFound) {
+ }
+ if (i >= c_tableRecordPool.getSize()) {
jam();
- firstTablePtr.p->tabState = TableRecord::NOT_DEFINED;
return RNIL;
- }//if
-#endif
- return firstTablePtr.i;
-}//Dbdict::getFreeTableRecord()
+ }
+ TableRecordPtr tablePtr;
+ c_tableRecordPool.getPtr(tablePtr, i);
+ ndbrequire(tablePtr.p->tabState == TableRecord::NOT_DEFINED);
+ initialiseTableRecord(tablePtr);
+ tablePtr.p->tabState = TableRecord::DEFINING;
+ return i;
+}
Uint32 Dbdict::getFreeTriggerRecord()
{
@@ -1641,39 +1910,6 @@
return RNIL;
}
-bool
-Dbdict::getNewAttributeRecord(TableRecordPtr tablePtr,
- AttributeRecordPtr & attrPtr)
-{
- c_attributeRecordPool.seize(attrPtr);
- if(attrPtr.i == RNIL){
- return false;
- }
-
- memset(attrPtr.p->attributeName, 0, sizeof(attrPtr.p->attributeName));
- attrPtr.p->attributeDescriptor = 0x00012255; //Default value
- attrPtr.p->attributeId = ZNIL;
- attrPtr.p->nextAttrInTable = RNIL;
- attrPtr.p->tupleKey = 0;
- memset(attrPtr.p->defaultValue, 0, sizeof(attrPtr.p->defaultValue));
-
- /* ---------------------------------------------------------------- */
- // A free attribute record has been acquired. We will now link it
- // to the table record.
- /* ---------------------------------------------------------------- */
- if (tablePtr.p->lastAttribute == RNIL) {
- jam();
- tablePtr.p->firstAttribute = attrPtr.i;
- } else {
- jam();
- AttributeRecordPtr lastAttrPtr;
- c_attributeRecordPool.getPtr(lastAttrPtr, tablePtr.p->lastAttribute);
- lastAttrPtr.p->nextAttrInTable = attrPtr.i;
- }//if
- tablePtr.p->lastAttribute = attrPtr.i;
- return true;
-}//Dbdict::getNewAttributeRecord()
-
/* **************************************************************** */
/* ---------------------------------------------------------------- */
/* MODULE: START/RESTART HANDLING ------------------------ */
@@ -1743,10 +1979,17 @@
c_pageRecordArray.setSize(ZNUMBER_OF_PAGES);
c_schemaPageRecordArray.setSize(2 * NDB_SF_MAX_PAGES);
c_tableRecordPool.setSize(tablerecSize);
- c_tableRecordHash.setSize(tablerecSize);
g_key_descriptor_pool.setSize(tablerecSize);
c_triggerRecordPool.setSize(c_maxNoOfTriggers);
- c_triggerRecordHash.setSize(c_maxNoOfTriggers);
+
+ c_obj_pool.setSize(tablerecSize+c_maxNoOfTriggers);
+ c_obj_hash.setSize((tablerecSize+c_maxNoOfTriggers+1)/2);
+
+ c_file_pool.setSize(10);
+ c_file_hash.setSize(16);
+ c_filegroup_pool.setSize(10);
+ c_filegroup_hash.setSize(16);
+
c_opRecordPool.setSize(256); // XXX need config params
c_opCreateTable.setSize(8);
c_opDropTable.setSize(8);
@@ -1770,6 +2013,11 @@
(SchemaFile*)c_schemaPageRecordArray.getPtr(1 * NDB_SF_MAX_PAGES);
c_schemaFile[1].noOfPages = 0;
+ c_schemaOp.setSize(8);
+ //c_opDropObj.setSize(8);
+ c_Trans.setSize(8);
+ c_rope_pool.setSize(100000/28);
+
// Initialize BAT for interface to file system
NewVARIABLE* bat = allocateBat(2);
bat[0].WA = &c_schemaPageRecordArray.getPtr(0)->word[0];
@@ -1791,6 +2039,30 @@
conf->senderData = senderData;
sendSignal(ref, GSN_READ_CONFIG_CONF, signal,
ReadConfigConf::SignalLength, JBB);
+
+ {
+ Ptr<DictObject> ptr;
+ SLList<DictObject> objs(c_obj_pool);
+ while(objs.seize(ptr))
+ new (ptr.p) DictObject();
+ objs.release();
+ }
+
+ {
+ Ptr<File> ptr;
+ SLList<File> objs(c_file_pool);
+ while(objs.seize(ptr))
+ new (ptr.p) File();
+ objs.release();
+ }
+
+ {
+ Ptr<Filegroup> ptr;
+ SLList<Filegroup> objs(c_filegroup_pool);
+ while(objs.seize(ptr))
+ new (ptr.p) Filegroup();
+ objs.release();
+ }
}//execSIZEALT_REP()
/* ---------------------------------------------------------------- */
@@ -2088,6 +2360,7 @@
c_schemaRecord.m_callback.m_callbackFunction =
safe_cast(&Dbdict::masterRestart_checkSchemaStatusComplete);
+ c_restartRecord.m_pass = 0;
c_restartRecord.activeTable = 0;
c_schemaRecord.schemaPage = c_schemaRecord.oldSchemaPage; // ugly
checkSchemaStatus(signal);
@@ -2215,6 +2488,8 @@
c_schemaRecord.m_callback.m_callbackData = 0;
c_schemaRecord.m_callback.m_callbackFunction =
safe_cast(&Dbdict::restart_checkSchemaStatusComplete);
+
+ c_restartRecord.m_pass= 0;
c_restartRecord.activeTable = 0;
checkSchemaStatus(signal);
}//execSCHEMA_INFO()
@@ -2235,6 +2510,9 @@
c_writeSchemaRecord.m_callback.m_callbackFunction =
safe_cast(&Dbdict::restart_writeSchemaConf);
+ for(Uint32 i = 0; i<xsf->noOfPages; i++)
+ computeChecksum(xsf, i);
+
startWriteSchemaFile(signal);
}
@@ -2277,6 +2555,37 @@
activateIndexes(signal, 0);
}//execSCHEMA_INFOCONF()
+static bool
+checkSchemaStatus(Uint32 tableType, Uint32 pass)
+{
+ switch(tableType){
+ case DictTabInfo::UndefTableType:
+ return true;
+ case DictTabInfo::HashIndexTrigger:
+ case DictTabInfo::SubscriptionTrigger:
+ case DictTabInfo::ReadOnlyConstraint:
+ case DictTabInfo::IndexTrigger:
+ return false;
+ case DictTabInfo::LogfileGroup:
+ return pass == 0;
+ case DictTabInfo::Tablespace:
+ return pass == 1;
+ case DictTabInfo::Datafile:
+ case DictTabInfo::Undofile:
+ return pass == 2;
+ case DictTabInfo::SystemTable:
+ case DictTabInfo::UserTable:
+ return pass == 3;
+ case DictTabInfo::UniqueHashIndex:
+ case DictTabInfo::HashIndex:
+ case DictTabInfo::UniqueOrderedIndex:
+ case DictTabInfo::OrderedIndex:
+ return pass == 4;
+ }
+
+ return false;
+}
+
void Dbdict::checkSchemaStatus(Signal* signal)
{
XSchemaFile * newxsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
@@ -2303,6 +2612,12 @@
continue;
}//if
+ if(!::checkSchemaStatus(oldEntry->m_tableType, c_restartRecord.m_pass))
+ continue;
+
+ if(!::checkSchemaStatus(newEntry->m_tableType, c_restartRecord.m_pass))
+ continue;
+
switch(schemaState){
case SchemaFile::INIT:{
jam();
@@ -2380,7 +2695,7 @@
// Table was added in the master node but not in our node. We can
// retrieve the table definition from the master.
//------------------------------------------------------------------
- restartCreateTab(signal, tableId, oldEntry, false);
+ restartCreateTab(signal, tableId, oldEntry, newEntry, false);
return;
break;
case SchemaFile::TABLE_ADD_COMMITTED:
@@ -2392,17 +2707,16 @@
// Table was added in both our node and the master node. We can
// retrieve the table definition from our own disk.
//------------------------------------------------------------------
- if(* newEntry == * oldEntry){
- jam();
-
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
- tablePtr.p->tableVersion = oldEntry->m_tableVersion;
- tablePtr.p->tableType = (DictTabInfo::TableType)oldEntry->m_tableType;
-
+ if(newEntry->m_tableVersion == oldEntry->m_tableVersion)
+ {
+ jam();
+ ndbrequire(newEntry->m_gcp == oldEntry->m_gcp);
+ ndbrequire(newEntry->m_tableType == oldEntry->m_tableType);
+ Uint32 type= oldEntry->m_tableType;
// On NR get index from master because index state is not on file
- const bool file = c_systemRestart || tablePtr.p->isTable();
- restartCreateTab(signal, tableId, oldEntry, file);
+ const bool file = c_systemRestart || !DictTabInfo::isIndex(type);
+ newEntry->m_info_words= oldEntry->m_info_words;
+ restartCreateTab(signal, tableId, oldEntry, newEntry, file);
return;
} else {
@@ -2417,7 +2731,7 @@
ndbrequire(newEntry->m_tableVersion != oldEntry->m_tableVersion);
jam();
- restartCreateTab(signal, tableId, oldEntry, false);
+ restartCreateTab(signal, tableId, oldEntry, newEntry, false);
return;
}//if
}
@@ -2470,7 +2784,7 @@
// Table was altered in the master node but not in our node. We can
// retrieve the altered table definition from the master.
//------------------------------------------------------------------
- restartCreateTab(signal, tableId, oldEntry, false);
+ restartCreateTab(signal, tableId, oldEntry, newEntry, false);
return;
break;
case SchemaFile::ALTER_TABLE_COMMITTED:
@@ -2481,15 +2795,13 @@
// Table was altered in both our node and the master node. We can
// retrieve the table definition from our own disk.
//------------------------------------------------------------------
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
- tablePtr.p->tableVersion = oldEntry->m_tableVersion;
- tablePtr.p->tableType = (DictTabInfo::TableType)oldEntry->m_tableType;
// On NR get index from master because index state is not on file
- const bool file = c_systemRestart || tablePtr.p->isTable();
- restartCreateTab(signal, tableId, oldEntry, file);
-
+ Uint32 type= oldEntry->m_tableType;
+ const bool file = c_systemRestart || !DictTabInfo::isIndex(type);
+ newEntry->m_info_words= oldEntry->m_info_words;
+ restartCreateTab(signal, tableId, oldEntry, newEntry, file);
+
return;
}
ndbrequire(ok);
@@ -2498,13 +2810,46 @@
}
}
- execute(signal, c_schemaRecord.m_callback, 0);
+ c_restartRecord.m_pass++;
+ c_restartRecord.activeTable= 0;
+ if(c_restartRecord.m_pass <= 4)
+ {
+ checkSchemaStatus(signal);
+ }
+ else
+ {
+ execute(signal, c_schemaRecord.m_callback, 0);
+ }
}//checkSchemaStatus()
void
Dbdict::restartCreateTab(Signal* signal, Uint32 tableId,
- const SchemaFile::TableEntry * te, bool file){
+ const SchemaFile::TableEntry * old_entry,
+ const SchemaFile::TableEntry * new_entry,
+ bool file){
jam();
+
+ switch(new_entry->m_tableType){
+ case DictTabInfo::UndefTableType:
+ case DictTabInfo::HashIndexTrigger:
+ case DictTabInfo::SubscriptionTrigger:
+ case DictTabInfo::ReadOnlyConstraint:
+ case DictTabInfo::IndexTrigger:
+ ndbrequire(false);
+ case DictTabInfo::SystemTable:
+ case DictTabInfo::UserTable:
+ case DictTabInfo::UniqueHashIndex:
+ case DictTabInfo::HashIndex:
+ case DictTabInfo::UniqueOrderedIndex:
+ case DictTabInfo::OrderedIndex:
+ break;
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:
+ case DictTabInfo::Datafile:
+ case DictTabInfo::Undofile:
+ restartCreateObj(signal, tableId, old_entry, new_entry, file);
+ return;
+ }
CreateTableRecordPtr createTabPtr;
c_opCreateTable.seize(createTabPtr);
@@ -2524,8 +2869,7 @@
if(file && !ERROR_INSERTED(6002)){
jam();
- c_readTableRecord.noOfPages =
- DIV(te->m_info_words + ZPAGE_HEADER_SIZE, ZSIZE_OF_PAGES_IN_WORDS);
+ c_readTableRecord.no_of_words = old_entry->m_info_words;
c_readTableRecord.pageId = 0;
c_readTableRecord.m_callback.m_callbackData = createTabPtr.p->key;
c_readTableRecord.m_callback.m_callbackFunction =
@@ -2569,17 +2913,17 @@
parseRecord.requestType = DictTabInfo::GetTabInfoConf;
parseRecord.errorCode = 0;
- Uint32 sz = c_readTableRecord.noOfPages * ZSIZE_OF_PAGES_IN_WORDS;
- SimplePropertiesLinearReader r(&pageRecPtr.p->word[0], sz);
+ Uint32 sz = c_readTableRecord.no_of_words;
+ SimplePropertiesLinearReader r(pageRecPtr.p->word+ZPAGE_HEADER_SIZE, sz);
handleTabInfoInit(r, &parseRecord);
ndbrequire(parseRecord.errorCode == 0);
-
+
/* ---------------------------------------------------------------- */
// We have read the table description from disk as part of system restart.
// We will also write it back again to ensure that both copies are ok.
/* ---------------------------------------------------------------- */
ndbrequire(c_writeTableRecord.tableWriteState == WriteTableRecord::IDLE);
- c_writeTableRecord.noOfPages = c_readTableRecord.noOfPages;
+ c_writeTableRecord.no_of_words = c_readTableRecord.no_of_words;
c_writeTableRecord.pageId = c_readTableRecord.pageId;
c_writeTableRecord.tableWriteState = WriteTableRecord::TWR_CALLBACK;
c_writeTableRecord.m_callback.m_callbackData = callbackData;
@@ -2599,9 +2943,53 @@
GetTabInfoConf * const conf = (GetTabInfoConf*)signal->getDataPtr();
+ switch(conf->tableType){
+ case DictTabInfo::UndefTableType:
+ case DictTabInfo::HashIndexTrigger:
+ case DictTabInfo::SubscriptionTrigger:
+ case DictTabInfo::ReadOnlyConstraint:
+ case DictTabInfo::IndexTrigger:
+ ndbrequire(false);
+ case DictTabInfo::SystemTable:
+ case DictTabInfo::UserTable:
+ case DictTabInfo::UniqueHashIndex:
+ case DictTabInfo::HashIndex:
+ case DictTabInfo::UniqueOrderedIndex:
+ case DictTabInfo::OrderedIndex:
+ break;
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:
+ case DictTabInfo::Datafile:
+ case DictTabInfo::Undofile:
+ if(refToBlock(conf->senderRef) == TSMAN
+ && (refToNode(conf->senderRef) == 0
+ || refToNode(conf->senderRef) == getOwnNodeId()))
+ {
+ jam();
+ FilePtr fg_ptr;
+ ndbrequire(c_file_hash.find(fg_ptr, conf->tableId));
+ const Uint32 free_extents= conf->freeExtents;
+ const Uint32 id= conf->tableId;
+ const Uint32 type= conf->tableType;
+ const Uint32 data= conf->senderData;
+ signal->theData[0]= ZPACK_TABLE_INTO_PAGES;
+ signal->theData[1]= id;
+ signal->theData[2]= type;
+ signal->theData[3]= data;
+ signal->theData[4]= free_extents;
+ sendSignal(reference(), GSN_CONTINUEB, signal, 5, JBB);
+ }
+ else
+ {
+ jam();
+ restartCreateObj_getTabInfoConf(signal);
+ }
+ return;
+ }
+
const Uint32 tableId = conf->tableId;
const Uint32 senderData = conf->senderData;
-
+
SegmentedSectionPtr tabInfoPtr;
signal->getSection(tabInfoPtr, GetTabInfoConf::DICT_TAB_INFO);
@@ -2620,6 +3008,11 @@
SimplePropertiesSectionReader r(tabInfoPtr, getSectionSegmentPool());
handleTabInfoInit(r, &parseRecord);
ndbrequire(parseRecord.errorCode == 0);
+
+ ndbrequire(tableId < c_tableRecordPool.getSize());
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry * tableEntry = getTableEntry(xsf, tableId);
+ tableEntry->m_info_words= tabInfoPtr.sz;
Callback callback;
callback.m_callbackData = createTabPtr.p->key;
@@ -2721,7 +3114,6 @@
dropTabPtr.p->m_coordinatorRef = 0;
dropTabPtr.p->m_requestType = DropTabReq::RestartDropTab;
dropTabPtr.p->m_participantData.m_gsn = GSN_DROP_TAB_REQ;
-
dropTabPtr.p->m_participantData.m_block = 0;
dropTabPtr.p->m_participantData.m_callback.m_callbackData = key;
@@ -2747,6 +3139,234 @@
checkSchemaStatus(signal);
}
+void
+Dbdict::restartCreateObj(Signal* signal,
+ Uint32 tableId,
+ const SchemaFile::TableEntry * old_entry,
+ const SchemaFile::TableEntry * new_entry,
+ bool file){
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.seize(createObjPtr));
+
+ const Uint32 key = ++c_opRecordSequence;
+ createObjPtr.p->key = key;
+ c_opCreateObj.add(createObjPtr);
+ createObjPtr.p->m_errorCode = 0;
+ createObjPtr.p->m_senderRef = reference();
+ createObjPtr.p->m_senderData = tableId;
+ createObjPtr.p->m_clientRef = reference();
+ createObjPtr.p->m_clientData = tableId;
+
+ createObjPtr.p->m_obj_id = tableId;
+ createObjPtr.p->m_obj_type = new_entry->m_tableType;
+ createObjPtr.p->m_obj_version = new_entry->m_tableVersion;
+
+ createObjPtr.p->m_callback.m_callbackData = key;
+ createObjPtr.p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::restartCreateObj_prepare_start_done);
+
+ createObjPtr.p->m_restart= file ? 1 : 2;
+ switch(new_entry->m_tableType){
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:
+ createObjPtr.p->m_vt_index = 0;
+ break;
+ case DictTabInfo::Datafile:
+ case DictTabInfo::Undofile:
+ createObjPtr.p->m_vt_index = 1;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ createObjPtr.p->m_obj_info_ptr_i = RNIL;
+ if(file)
+ {
+ c_readTableRecord.no_of_words = old_entry->m_info_words;
+ c_readTableRecord.pageId = 0;
+ c_readTableRecord.m_callback.m_callbackData = key;
+ c_readTableRecord.m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartCreateObj_readConf);
+
+ startReadTableFile(signal, tableId);
+ }
+ else
+ {
+ /**
+ * Get from master
+ */
+ GetTabInfoReq * const req = (GetTabInfoReq *)&signal->theData[0];
+ req->senderRef = reference();
+ req->senderData = key;
+ req->requestType = GetTabInfoReq::RequestById |
+ GetTabInfoReq::LongSignalConf;
+ req->tableId = tableId;
+ sendSignal(calcDictBlockRef(c_masterNodeId), GSN_GET_TABINFOREQ, signal,
+ GetTabInfoReq::SignalLength, JBB);
+ }
+}
+
+void
+Dbdict::restartCreateObj_getTabInfoConf(Signal* signal)
+{
+ jam();
+
+ GetTabInfoConf * const conf = (GetTabInfoConf*)signal->getDataPtr();
+
+ const Uint32 objId = conf->tableId;
+ const Uint32 senderData = conf->senderData;
+
+ SegmentedSectionPtr objInfoPtr;
+ signal->getSection(objInfoPtr, GetTabInfoConf::DICT_TAB_INFO);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, senderData));
+ ndbrequire(createObjPtr.p->m_obj_id == objId);
+
+ createObjPtr.p->m_obj_info_ptr_i= objInfoPtr.i;
+ signal->header.m_noOfSections = 0;
+
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_prepare_start)
+ (signal, createObjPtr.p);
+}
+
+void
+Dbdict::restartCreateObj_readConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ PageRecordPtr pageRecPtr;
+ c_pageRecordArray.getPtr(pageRecPtr, c_readTableRecord.pageId);
+
+ Uint32 sz = c_readTableRecord.no_of_words;
+
+ Ptr<SectionSegment> ptr;
+ ndbrequire(import(ptr, pageRecPtr.p->word+ZPAGE_HEADER_SIZE, sz));
+ createObjPtr.p->m_obj_info_ptr_i= ptr.i;
+
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_prepare_start)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_prepare_start)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::restartCreateObj_prepare_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ Callback callback;
+ callback.m_callbackData = callbackData;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartCreateObj_write_complete);
+
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, createObjPtr.p->m_obj_info_ptr_i);
+
+ writeTableFile(signal, createObjPtr.p->m_obj_id, objInfoPtr, &callback);
+}
+
+void
+Dbdict::restartCreateObj_write_complete(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, createObjPtr.p->m_obj_info_ptr_i);
+ signal->setSection(objInfoPtr, 0);
+ releaseSections(signal);
+ createObjPtr.p->m_obj_info_ptr_i = RNIL;
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartCreateObj_prepare_complete_done);
+
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_prepare_complete)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_prepare_complete)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::restartCreateObj_prepare_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartCreateObj_commit_start_done);
+
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_commit_start)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_commit_start)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::restartCreateObj_commit_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::restartCreateObj_commit_complete_done);
+
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_commit_complete)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_commit_complete)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+}
+
+
+void
+Dbdict::restartCreateObj_commit_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+ ndbrequire(createObjPtr.p->m_errorCode == 0);
+
+ c_opCreateObj.release(createObjPtr);
+
+ c_restartRecord.activeTable++;
+ checkSchemaStatus(signal);
+}
+
/* **************************************************************** */
/* ---------------------------------------------------------------- */
/* MODULE: NODE FAILURE HANDLING ------------------------- */
@@ -3181,7 +3801,7 @@
// Send prepare request to all alive nodes
SimplePropertiesSectionWriter w(getSectionSegmentPool());
- packTableIntoPagesImpl(w, parseRecord.tablePtr);
+ packTableIntoPages(w, parseRecord.tablePtr);
SegmentedSectionPtr tabInfoPtr;
w.getPtr(tabInfoPtr);
@@ -3251,7 +3871,7 @@
lreq->clientData = alterTabPtr.p->m_senderData;
lreq->changeMask = alterTabPtr.p->m_changeMask;
lreq->tableId = tablePtr.p->tableId;
- lreq->tableVersion = alter_table_inc_schema_version(tablePtr.p->tableVersion);
+ lreq->tableVersion = alter_obj_inc_schema_version(tablePtr.p->tableVersion);
lreq->gci = tablePtr.p->gciTableCreated;
lreq->requestType = AlterTabReq::AlterTablePrepare;
@@ -3381,7 +4001,7 @@
}
ndbrequire(ok);
- if(alter_table_inc_schema_version(tablePtr.p->tableVersion) != tableVersion){
+ if(alter_obj_inc_schema_version(tablePtr.p->tableVersion) != tableVersion){
jam();
alterTabRef(signal, req, AlterTableRef::InvalidTableVersion);
return;
@@ -3555,7 +4175,7 @@
Uint32 tableVersion = tablePtr.p->tableVersion;
Uint32 gci = tablePtr.p->gciTableCreated;
SimplePropertiesSectionWriter w(getSectionSegmentPool());
- packTableIntoPagesImpl(w, tablePtr);
+ packTableIntoPages(w, tablePtr);
SegmentedSectionPtr spDataPtr;
w.getPtr(spDataPtr);
signal->setSection(spDataPtr, AlterTabReq::DICT_TAB_INFO);
@@ -3691,7 +4311,7 @@
Uint32 tableVersion = tablePtr.p->tableVersion;
Uint32 gci = tablePtr.p->gciTableCreated;
SimplePropertiesSectionWriter w(getSectionSegmentPool());
- packTableIntoPagesImpl(w, tablePtr);
+ packTableIntoPages(w, tablePtr);
SegmentedSectionPtr spDataPtr;
w.getPtr(spDataPtr);
signal->setSection(spDataPtr, AlterTabReq::DICT_TAB_INFO);
@@ -3720,7 +4340,7 @@
TableRecordPtr tablePtr;
c_tableRecordPool.getPtr(tablePtr, tableId);
SimplePropertiesSectionWriter w(getSectionSegmentPool());
- packTableIntoPagesImpl(w, tablePtr);
+ packTableIntoPages(w, tablePtr);
SegmentedSectionPtr spDataPtr;
w.getPtr(spDataPtr);
signal->setSection(spDataPtr, AlterTabReq::DICT_TAB_INFO);
@@ -3803,13 +4423,16 @@
inline
void Dbdict::printTables()
{
- DLHashTable<TableRecord>::Iterator iter;
- bool moreTables = c_tableRecordHash.first(iter);
- printf("TABLES IN DICT:\n");
+ DLHashTable<DictObject>::Iterator iter;
+ bool moreTables = c_obj_hash.first(iter);
+ printf("OBJECTS IN DICT:\n");
+ char name[MAX_TAB_NAME_SIZE];
while (moreTables) {
- TableRecordPtr tablePtr = iter.curr;
- printf("%s ", tablePtr.p->tableName);
- moreTables = c_tableRecordHash.next(iter);
+ Ptr<DictObject> tablePtr = iter.curr;
+ ConstRope r(c_rope_pool, tablePtr.p->m_name);
+ r.copy(name);
+ printf("%s ", name);
+ moreTables = c_obj_hash.next(iter);
}
printf("\n");
}
@@ -3827,39 +4450,45 @@
// Table rename
supportedAlteration = true;
// Remove from hashtable
-#ifdef VM_TRACE
- TableRecordPtr tmp;
- ndbrequire(c_tableRecordHash.find(tmp, *origTablePtr.p));
-#endif
- c_tableRecordHash.remove(origTablePtr);
- // Save old name
- strcpy(alterTabPtrP->previousTableName, origTablePtr.p->tableName);
- // Set new name
- strcpy(origTablePtr.p->tableName, newTablePtr.p->tableName);
- // Set new schema version
- origTablePtr.p->tableVersion = newTablePtr.p->tableVersion;
+ Ptr<DictObject> obj_ptr;
+ c_obj_pool.getPtr(obj_ptr, origTablePtr.p->m_obj_ptr_i);
+ c_obj_hash.remove(obj_ptr);
+ {
+ Rope org(c_rope_pool, origTablePtr.p->tableName);
+ org.copy(alterTabPtrP->previousTableName);
+
+ ConstRope src(c_rope_pool, newTablePtr.p->tableName);
+ char tmp[MAX_TAB_NAME_SIZE];
+ const int len = src.size();
+ src.copy(tmp);
+ ndbrequire(org.assign(tmp, len));
+ }
+ obj_ptr.p->m_name = origTablePtr.p->tableName;
// Put it back
-#ifdef VM_TRACE
- ndbrequire(!c_tableRecordHash.find(tmp, *origTablePtr.p));
-#endif
- c_tableRecordHash.add(origTablePtr);
+ c_obj_hash.add(obj_ptr);
}
if (AlterTableReq::getFrmFlag(changeMask)) {
// Table definition changed (new frm)
supportedAlteration = true;
// Save old definition
- strncpy(alterTabPtrP->previousFrmData, origTablePtr.p->frmData, origTablePtr.p->frmLen);
- alterTabPtrP->previousFrmLen = origTablePtr.p->frmLen;
+ Rope org(c_rope_pool, origTablePtr.p->frmData);
+ org.copy(alterTabPtrP->previousFrmData);
+ alterTabPtrP->previousFrmLen = org.size();
+
// Set new definition
- strncpy(origTablePtr.p->frmData, newTablePtr.p->frmData, newTablePtr.p->frmLen);
- origTablePtr.p->frmLen = newTablePtr.p->frmLen;
- // Set new schema version
- origTablePtr.p->tableVersion = newTablePtr.p->tableVersion;
+ ConstRope src(c_rope_pool, newTablePtr.p->frmData);
+ char tmp[MAX_FRM_DATA_SIZE];
+ src.copy(tmp);
+ ndbrequire(org.assign(tmp, src.size()));
}
if (supportedAlteration)
+ {
+ // Set new schema version
+ origTablePtr.p->tableVersion = newTablePtr.p->tableVersion;
return 0;
+ }
else
{
jam();
@@ -3874,46 +4503,48 @@
{
bool supportedAlteration = false;
+ TableRecordPtr tablePtr;
+ c_tableRecordPool.getPtr(tablePtr, tableId);
+
if (AlterTableReq::getNameFlag(changeMask)) {
jam();
// Table rename
supportedAlteration = true;
// Restore previous name
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
- // Remove from hashtable
-#ifdef VM_TRACE
- TableRecordPtr tmp;
- ndbrequire(c_tableRecordHash.find(tmp, * tablePtr.p));
-#endif
- c_tableRecordHash.remove(tablePtr);
- // Restore name
- strcpy(tablePtr.p->tableName, alterTabPtrP->previousTableName);
- // Revert schema version
- tablePtr.p->tableVersion = alter_table_dec_schema_version(tablePtr.p->tableVersion);
+
+ Ptr<DictObject> obj_ptr;
+ c_obj_pool.getPtr(obj_ptr, tablePtr.p->m_obj_ptr_i);
+ c_obj_hash.remove(obj_ptr);
+
+ {
+ // Restore name
+ Rope org(c_rope_pool, tablePtr.p->tableName);
+ ndbrequire(org.assign(alterTabPtrP->previousTableName));
+ }
+ obj_ptr.p->m_name = tablePtr.p->tableName;
// Put it back
-#ifdef VM_TRACE
- ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p));
-#endif
- c_tableRecordHash.add(tablePtr);
+ c_obj_hash.add(obj_ptr);
}
- if (AlterTableReq::getFrmFlag(changeMask)) {
+ if (AlterTableReq::getFrmFlag(changeMask))
+ {
jam();
// Table redefinition
supportedAlteration = true;
// Restore previous frm
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, tableId);
- // Restore frm
- strncpy(tablePtr.p->frmData, alterTabPtrP->previousFrmData, alterTabPtrP->previousFrmLen);
- tablePtr.p->frmLen = alterTabPtrP->previousFrmLen;
- // Revert schema version
- tablePtr.p->tableVersion = alter_table_dec_schema_version(tablePtr.p->tableVersion);
+ Rope org(c_rope_pool, tablePtr.p->tableName);
+ ndbrequire(org.assign(alterTabPtrP->previousFrmData,
+ alterTabPtrP->previousFrmLen));
+
}
+
if (supportedAlteration)
+ {
+ tablePtr.p->tableVersion =
+ alter_obj_dec_schema_version(tablePtr.p->tableVersion);
return;
+ }
ndbrequire(false);
}
@@ -3986,7 +4617,7 @@
AlterTableRep* rep = (AlterTableRep*)api->theData;
rep->tableId = tabPtr.p->tableId;
- rep->tableVersion = alter_table_dec_schema_version(tabPtr.p->tableVersion);
+ rep->tableVersion = alter_obj_dec_schema_version(tabPtr.p->tableVersion);
rep->changeType = AlterTableRep::CT_ALTERED;
LinearSectionPtr ptr[3];
@@ -4049,13 +4680,14 @@
XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
SchemaFile::TableEntry * tabEntry = getTableEntry(xsf, tabPtr.i);
- tabPtr.p->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion);
+ tabPtr.p->tableVersion =
+ create_obj_inc_schema_version(tabEntry->m_tableVersion);
/**
* Pack
*/
SimplePropertiesSectionWriter w(getSectionSegmentPool());
- packTableIntoPagesImpl(w, tabPtr);
+ packTableIntoPages(w, tabPtr);
SegmentedSectionPtr spDataPtr;
w.getPtr(spDataPtr);
@@ -4078,7 +4710,7 @@
req->gci = 0;
req->tableId = tabPtr.i;
- req->tableVersion = create_table_inc_schema_version(tabEntry->m_tableVersion);
+ req->tableVersion = create_obj_inc_schema_version(tabEntry->m_tableVersion);
sendFragmentedSignal(rg, GSN_CREATE_TAB_REQ, signal,
CreateTabReq::SignalLength, JBB);
@@ -4362,6 +4994,13 @@
safe_cast(&Dbdict::createTab_writeSchemaConf1);
updateSchemaState(signal, tableId, &tabEntry, &callback);
+
+ if (tabPtr.p->m_tablespace_id != RNIL)
+ {
+ FilegroupPtr ptr;
+ ndbrequire(c_filegroup_hash.find(ptr, tabPtr.p->m_tablespace_id));
+ increase_ref_count(ptr.p->m_obj_ptr_i);
+ }
}
void getSection(SegmentedSectionPtr & ptr, Uint32 i);
@@ -4447,34 +5086,39 @@
new (desc) KeyDescriptor();
Uint32 key = 0;
- Uint32 tAttr = tabPtr.p->firstAttribute;
- while (tAttr != RNIL)
+ Ptr<AttributeRecord> attrPtr;
+ LocalDLFifoList<AttributeRecord> list(c_attributeRecordPool,
+ tabPtr.p->m_attributes);
+ for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr))
{
- jam();
- AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr);
- if (aRec->tupleKey)
+ AttributeRecord* aRec = attrPtr.p;
+ if (aRec->tupleKey)
{
+ Uint32 attr = aRec->attributeDescriptor;
+
desc->noOfKeyAttr ++;
- desc->keyAttr[key].attributeDescriptor = aRec->attributeDescriptor;
-
+ desc->keyAttr[key].attributeDescriptor = attr;
Uint32 csNumber = (aRec->extPrecision >> 16);
- if(csNumber)
+ if (csNumber)
{
- desc->keyAttr[key].charsetInfo = all_charsets[csNumber];
- ndbrequire(all_charsets[csNumber]);
- desc->hasCharAttr = 1;
+ desc->keyAttr[key].charsetInfo = all_charsets[csNumber];
+ ndbrequire(all_charsets[csNumber] != 0);
+ desc->hasCharAttr = 1;
}
else
{
- desc->keyAttr[key].charsetInfo = 0;
+ desc->keyAttr[key].charsetInfo = 0;
+ }
+ if (AttributeDescriptor::getDKey(attr))
+ {
+ desc->noOfDistrKeys ++;
}
- if(AttributeDescriptor::getDKey(aRec->attributeDescriptor))
+ if (AttributeDescriptor::getArrayType(attr) != NDB_ARRAYTYPE_FIXED)
{
- desc->noOfDistrKeys ++;
+ desc->noOfVarKeys ++;
}
key++;
}
- tAttr = aRec->nextAttrInTable;
}
ndbrequire(key == tabPtr.p->noOfPrimkey);
}
@@ -4571,11 +5215,11 @@
// noOfCharsets passed to TUP in upper half
req->noOfNewAttr |= (tabPtr.p->noOfCharsets << 16);
req->checksumIndicator = 1;
- req->noOfAttributeGroups = 1;
req->GCPIndicator = 0;
req->startGci = startGci;
req->tableType = tabPtr.p->tableType;
req->primaryTableId = tabPtr.p->primaryTableId;
+ req->tablespace_id= tabPtr.p->m_tablespace_id;
sendSignal(DBLQH_REF, GSN_LQHFRAGREQ, signal,
LqhFragReq::SignalLength, JBB);
}
@@ -4611,7 +5255,7 @@
TableRecordPtr tabPtr;
c_tableRecordPool.getPtr(tabPtr, createTabPtr.p->m_tablePtrI);
- sendLQHADDATTRREQ(signal, createTabPtr, tabPtr.p->firstAttribute);
+ sendLQHADDATTRREQ(signal, createTabPtr, tabPtr.p->m_attributes.firstItem);
}
void
@@ -4635,7 +5279,7 @@
entry.extTypeInfo |= (attrPtr.p->extPrecision & ~0xFFFF);
if (tabPtr.p->isIndex()) {
Uint32 primaryAttrId;
- if (attrPtr.p->nextAttrInTable != RNIL) {
+ if (attrPtr.p->nextList != RNIL) {
getIndexAttr(tabPtr, attributePtrI, &primaryAttrId);
} else {
primaryAttrId = ZNIL;
@@ -4644,7 +5288,7 @@
}
entry.attrId |= (primaryAttrId << 16);
}
- attributePtrI = attrPtr.p->nextAttrInTable;
+ attributePtrI = attrPtr.p->nextList;
}
req->lqhFragPtr = createTabPtr.p->m_lqhFragPtr;
req->senderData = createTabPtr.p->key;
@@ -4773,7 +5417,6 @@
signal->theData[4] = (Uint32)tabPtr.p->tableType;
signal->theData[5] = createTabPtr.p->key;
signal->theData[6] = (Uint32)tabPtr.p->noOfPrimkey;
-
sendSignal(DBTC_REF, GSN_TC_SCHVERREQ, signal, 7, JBB);
return;
}
@@ -4930,6 +5573,13 @@
dropTabPtr.p->m_participantData.m_callback.m_callbackFunction =
safe_cast(&Dbdict::createTab_dropComplete);
dropTab_nextStep(signal, dropTabPtr);
+
+ if (tabPtr.p->m_tablespace_id != RNIL)
+ {
+ FilegroupPtr ptr;
+ ndbrequire(c_filegroup_hash.find(ptr, tabPtr.p->m_tablespace_id));
+ decrease_ref_count(ptr.p->m_obj_ptr_i);
+ }
}
void
@@ -5002,6 +5652,42 @@
// handleAddTableFailure(signal, __LINE__, allocatedTable);
+Dbdict::DictObject *
+Dbdict::get_object(const char * name, Uint32 len, Uint32 hash){
+ DictObject key;
+ key.m_key.m_name_ptr = name;
+ key.m_key.m_name_len = len;
+ key.m_key.m_pool = &c_rope_pool;
+ key.m_name.m_hash = hash;
+ Ptr<DictObject> old_ptr;
+ c_obj_hash.find(old_ptr, key);
+ return old_ptr.p;
+}
+
+void
+Dbdict::release_object(Uint32 obj_ptr_i, DictObject* obj_ptr_p){
+ Rope name(c_rope_pool, obj_ptr_p->m_name);
+ name.erase();
+
+ Ptr<DictObject> ptr = { obj_ptr_p, obj_ptr_i };
+ c_obj_hash.release(ptr);
+}
+
+void
+Dbdict::increase_ref_count(Uint32 obj_ptr_i)
+{
+ DictObject* ptr = c_obj_pool.getPtr(obj_ptr_i);
+ ptr->m_ref_count++;
+}
+
+void
+Dbdict::decrease_ref_count(Uint32 obj_ptr_i)
+{
+ DictObject* ptr = c_obj_pool.getPtr(obj_ptr_i);
+ ndbrequire(ptr->m_ref_count);
+ ptr->m_ref_count--;
+}
+
void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
ParseDictTabInfoRecord * parseP,
bool checkExist)
@@ -5043,23 +5729,15 @@
// TODO
/* ---------------------------------------------------------------- */
const Uint32 tableNameLength = strlen(tableDesc.TableName) + 1;
+ const Uint32 name_hash = Rope::hash(tableDesc.TableName, tableNameLength);
- TableRecord keyRecord;
- tabRequire(tableNameLength <= sizeof(keyRecord.tableName),
- CreateTableRef::TableNameTooLong);
- strcpy(keyRecord.tableName, tableDesc.TableName);
-
- TableRecordPtr tablePtr;
- c_tableRecordHash.find(tablePtr, keyRecord);
-
- if (checkExist){
+ if(checkExist){
jam();
- /* ---------------------------------------------------------------- */
- // Check if table already existed.
- /* ---------------------------------------------------------------- */
- tabRequire(tablePtr.i == RNIL, CreateTableRef::TableAlreadyExist);
+ tabRequire(get_object(tableDesc.TableName, tableNameLength) == 0,
+ CreateTableRef::TableAlreadyExist);
}
-
+
+ TableRecordPtr tablePtr;
switch (parseP->requestType) {
case DictTabInfo::CreateTableFromAPI: {
jam();
@@ -5100,21 +5778,7 @@
jam();
tablePtr.p->tabState = TableRecord::DEFINING;
}//if
-#ifdef HAVE_TABLE_REORG
-/* ---------------------------------------------------------------- */
-// Get id of second table id and check that table doesn't already exist
-// and set up links between first and second table.
-/* ---------------------------------------------------------------- */
- TableRecordPtr secondTablePtr;
- secondTablePtr.i = tableDesc.SecondTableId;
- c_tableRecordPool.getPtr(secondTablePtr);
- ndbrequire(secondTablePtr.p->tabState == TableRecord::NOT_DEFINED);
-
- initialiseTableRecord(secondTablePtr);
- secondTablePtr.p->tabState = TableRecord::REORG_TABLE_PREPARED;
- secondTablePtr.p->secondTable = tablePtr.i;
- tablePtr.p->secondTable = secondTablePtr.i;
-#endif
+
/* ---------------------------------------------------------------- */
// Set table version
/* ---------------------------------------------------------------- */
@@ -5129,21 +5793,28 @@
}//switch
parseP->tablePtr = tablePtr;
- strcpy(tablePtr.p->tableName, keyRecord.tableName);
+ {
+ Rope name(c_rope_pool, tablePtr.p->tableName);
+ ndbrequire(name.assign(tableDesc.TableName, tableNameLength, name_hash));
+ }
+
+ Ptr<DictObject> obj_ptr;
if (parseP->requestType != DictTabInfo::AlterTableFromAPI) {
jam();
+ ndbrequire(c_obj_hash.seize(obj_ptr));
+ obj_ptr.p->m_id = tablePtr.i;
+ obj_ptr.p->m_type = tableDesc.TableType;
+ obj_ptr.p->m_name = tablePtr.p->tableName;
+ obj_ptr.p->m_ref_count = 0;
+ c_obj_hash.add(obj_ptr);
+ tablePtr.p->m_obj_ptr_i = obj_ptr.i;
+
#ifdef VM_TRACE
- ndbout_c("Dbdict: name=%s, id=%u, version=%u",
- tablePtr.p->tableName, tablePtr.i, tablePtr.p->tableVersion);
- TableRecordPtr tmp;
- ndbrequire(!c_tableRecordHash.find(tmp, * tablePtr.p));
+ ndbout_c("Dbdict: name=%s,id=%u,obj_ptr_i=%d",
+ tableDesc.TableName, tablePtr.i, tablePtr.p->m_obj_ptr_i);
#endif
- c_tableRecordHash.add(tablePtr);
}
- //tablePtr.p->noOfPrimkey = tableDesc.NoOfKeyAttr;
- //tablePtr.p->noOfNullAttr = tableDesc.NoOfNullable;
- //tablePtr.p->tupKeyLength = tableDesc.KeyLength;
tablePtr.p->noOfAttributes = tableDesc.NoOfAttributes;
tablePtr.p->storedTable = tableDesc.TableLoggedFlag;
tablePtr.p->minLoadFactor = tableDesc.MinLoadFactor;
@@ -5152,10 +5823,13 @@
tablePtr.p->tableType = (DictTabInfo::TableType)tableDesc.TableType;
tablePtr.p->kValue = tableDesc.TableKValue;
tablePtr.p->fragmentCount = tableDesc.FragmentCount;
-
- tablePtr.p->frmLen = tableDesc.FrmLen;
- memcpy(tablePtr.p->frmData, tableDesc.FrmData, tableDesc.FrmLen);
-
+ tablePtr.p->m_tablespace_id = tableDesc.TablespaceId;
+
+ {
+ Rope frm(c_rope_pool, tablePtr.p->frmData);
+ ndbrequire(frm.assign(tableDesc.FrmData, tableDesc.FrmLen));
+ }
+
tablePtr.p->ngLen = tableDesc.FragmentDataLen;
memcpy(tablePtr.p->ngData, tableDesc.FragmentData,
tableDesc.FragmentDataLen);
@@ -5179,8 +5853,8 @@
tablePtr.p->buildTriggerId = RNIL;
tablePtr.p->indexLocal = 0;
- handleTabInfo(it, parseP);
-
+ handleTabInfo(it, parseP, tableDesc.TablespaceVersion);
+
if(parseP->errorCode != 0)
{
/**
@@ -5191,7 +5865,8 @@
}//handleTabInfoInit()
void Dbdict::handleTabInfo(SimpleProperties::Reader & it,
- ParseDictTabInfoRecord * parseP)
+ ParseDictTabInfoRecord * parseP,
+ Uint32 tablespaceVersion)
{
TableRecordPtr tablePtr = parseP->tablePtr;
@@ -5207,6 +5882,11 @@
Uint32 recordLength = 0;
AttributeRecordPtr attrPtr;
c_attributeRecordHash.removeAll();
+
+ LocalDLFifoList<AttributeRecord> list(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+
+ Uint32 counts[] = {0,0,0,0,0};
for(Uint32 i = 0; i<attrCount; i++){
/**
@@ -5217,6 +5897,7 @@
DictTabInfo::AttributeMapping,
DictTabInfo::AttributeMappingSize,
true, true);
+
if(status != SimpleProperties::Break){
parseP->errorCode = CreateTableRef::InvalidFormat;
parseP->status = status;
@@ -5228,32 +5909,45 @@
/**
* Check that attribute is not defined twice
*/
- AttributeRecord tmpAttr;
+ const size_t len = strlen(attrDesc.AttributeName)+1;
+ const Uint32 name_hash = Rope::hash(attrDesc.AttributeName, len);
{
- strcpy(tmpAttr.attributeName, attrDesc.AttributeName);
-
- AttributeRecordPtr attrPtr;
- c_attributeRecordHash.find(attrPtr, tmpAttr);
+ AttributeRecord key;
+ key.m_key.m_name_ptr = attrDesc.AttributeName;
+ key.m_key.m_name_len = len;
+ key.attributeName.m_hash = name_hash;
+ key.m_key.m_pool = &c_rope_pool;
+ Ptr<AttributeRecord> old_ptr;
+ c_attributeRecordHash.find(old_ptr, key);
- if(attrPtr.i != RNIL){
+ if(old_ptr.i != RNIL){
parseP->errorCode = CreateTableRef::AttributeNameTwice;
return;
}
}
- if(!getNewAttributeRecord(tablePtr, attrPtr)){
+ list.seize(attrPtr);
+ if(attrPtr.i == RNIL){
jam();
parseP->errorCode = CreateTableRef::NoMoreAttributeRecords;
return;
}
+ new (attrPtr.p) AttributeRecord();
+ attrPtr.p->attributeDescriptor = 0x00012255; //Default value
+ attrPtr.p->tupleKey = 0;
+
/**
* TmpAttrib to Attribute mapping
*/
- strcpy(attrPtr.p->attributeName, attrDesc.AttributeName);
- attrPtr.p->attributeId = attrDesc.AttributeId;
+ {
+ Rope name(c_rope_pool, attrPtr.p->attributeName);
+ name.assign(attrDesc.AttributeName, len, name_hash);
+ }
+ attrPtr.p->attributeId = i;
+ //attrPtr.p->attributeId = attrDesc.AttributeId;
attrPtr.p->tupleKey = (keyCount + 1) * attrDesc.AttributeKeyFlag;
-
+
attrPtr.p->extPrecision = attrDesc.AttributeExtPrecision;
attrPtr.p->extScale = attrDesc.AttributeExtScale;
attrPtr.p->extLength = attrDesc.AttributeExtLength;
@@ -5301,20 +5995,30 @@
return;
}
+ // XXX old test option, remove
+ if(!attrDesc.AttributeKeyFlag &&
+ tablePtr.i > 1 &&
+ !tablePtr.p->isIndex())
+ {
+ //attrDesc.AttributeStorageType= NDB_STORAGETYPE_DISK;
+ }
+
Uint32 desc = 0;
AttributeDescriptor::setType(desc, attrDesc.AttributeExtType);
AttributeDescriptor::setSize(desc, attrDesc.AttributeSize);
- AttributeDescriptor::setArray(desc, attrDesc.AttributeArraySize);
+ AttributeDescriptor::setArraySize(desc, attrDesc.AttributeArraySize);
+ AttributeDescriptor::setArrayType(desc, attrDesc.AttributeArrayType);
AttributeDescriptor::setNullable(desc, attrDesc.AttributeNullableFlag);
AttributeDescriptor::setDKey(desc, attrDesc.AttributeDKey);
AttributeDescriptor::setPrimaryKey(desc, attrDesc.AttributeKeyFlag);
+ AttributeDescriptor::setDiskBased(desc, attrDesc.AttributeStorageType == NDB_STORAGETYPE_DISK);
attrPtr.p->attributeDescriptor = desc;
attrPtr.p->autoIncrement = attrDesc.AttributeAutoIncrement;
- strcpy(attrPtr.p->defaultValue, attrDesc.AttributeDefaultValue);
-
- tabRequire(attrDesc.AttributeId == i, CreateTableRef::InvalidFormat);
+ {
+ Rope defaultValue(c_rope_pool, attrPtr.p->defaultValue);
+ defaultValue.assign(attrDesc.AttributeDefaultValue);
+ }
- attrCount ++;
keyCount += attrDesc.AttributeKeyFlag;
nullCount += attrDesc.AttributeNullableFlag;
@@ -5352,8 +6056,21 @@
}
}
- if (parseP->requestType != DictTabInfo::AlterTableFromAPI)
- c_attributeRecordHash.add(attrPtr);
+ c_attributeRecordHash.add(attrPtr);
+
+ int a= AttributeDescriptor::getDiskBased(desc);
+ int b= AttributeDescriptor::getArrayType(desc);
+ Uint32 pos= 2*(a ? 1 : 0) + (b == NDB_ARRAYTYPE_FIXED ? 0 : 1);
+ counts[pos+1]++;
+
+ if(b != NDB_ARRAYTYPE_FIXED && sz == 0)
+ {
+ parseP->errorCode = CreateTableRef::VarsizeBitfieldNotSupported;
+ parseP->status = status;
+ parseP->errorKey = it.getKey();
+ parseP->errorLine = __LINE__;
+ return;
+ }
if(!it.next())
break;
@@ -5374,7 +6091,25 @@
CreateTableRef::InvalidPrimaryKeySize);
tabRequire(keyLength > 0,
CreateTableRef::InvalidPrimaryKeySize);
-
+
+ if(tablePtr.p->m_tablespace_id != RNIL || counts[3] || counts[4])
+ {
+ FilegroupPtr tablespacePtr;
+ if(!c_filegroup_hash.find(tablespacePtr, tablePtr.p->m_tablespace_id))
+ {
+ tabRequire(false, CreateTableRef::InvalidTablespace);
+ }
+
+ if(tablespacePtr.p->m_type != DictTabInfo::Tablespace)
+ {
+ tabRequire(false, CreateTableRef::NotATablespace);
+ }
+
+ if(tablespacePtr.p->m_version != tablespaceVersion)
+ {
+ tabRequire(false, CreateTableRef::InvalidTablespaceVersion);
+ }
+ }
}//handleTabInfo()
@@ -5902,6 +6637,13 @@
dropTabPtr.p->m_participantData.m_callback.m_callbackFunction =
safe_cast(&Dbdict::dropTab_complete);
dropTab_nextStep(signal, dropTabPtr);
+
+ if (tablePtr.p->m_tablespace_id != RNIL)
+ {
+ FilegroupPtr ptr;
+ ndbrequire(c_filegroup_hash.find(ptr, tablePtr.p->m_tablespace_id));
+ decrease_ref_count(ptr.p->m_obj_ptr_i);
+ }
}
#include <DebuggerNames.hpp>
@@ -6069,35 +6811,26 @@
void Dbdict::releaseTableObject(Uint32 tableId, bool removeFromHash)
{
TableRecordPtr tablePtr;
- AttributeRecordPtr attrPtr;
c_tableRecordPool.getPtr(tablePtr, tableId);
- if (removeFromHash)
- {
-#ifdef VM_TRACE
- TableRecordPtr tmp;
- ndbrequire(c_tableRecordHash.find(tmp, * tablePtr.p));
-#endif
- c_tableRecordHash.remove(tablePtr);
+ if (removeFromHash){
+ jam();
+ release_object(tablePtr.p->m_obj_ptr_i);
}
+
+ Rope frm(c_rope_pool, tablePtr.p->frmData);
+ frm.erase();
tablePtr.p->tabState = TableRecord::NOT_DEFINED;
-
- Uint32 nextAttrRecord = tablePtr.p->firstAttribute;
- while (nextAttrRecord != RNIL) {
- jam();
-/* ---------------------------------------------------------------- */
-// Release all attribute records
-/* ---------------------------------------------------------------- */
- c_attributeRecordPool.getPtr(attrPtr, nextAttrRecord);
- nextAttrRecord = attrPtr.p->nextAttrInTable;
- c_attributeRecordPool.release(attrPtr);
- }//if
-#ifdef HAVE_TABLE_REORG
- Uint32 secondTableId = tablePtr.p->secondTable;
- initialiseTableRecord(tablePtr);
- c_tableRecordPool.getPtr(tablePtr, secondTableId);
- initialiseTableRecord(tablePtr);
-#endif
- return;
+
+ LocalDLFifoList<AttributeRecord> list(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+ AttributeRecordPtr attrPtr;
+ for(list.first(attrPtr); !attrPtr.isNull(); list.next(attrPtr)){
+ Rope name(c_rope_pool, attrPtr.p->attributeName);
+ Rope def(c_rope_pool, attrPtr.p->defaultValue);
+ name.erase();
+ def.erase();
+ }
+ list.release();
}//releaseTableObject()
/**
@@ -6161,36 +6894,29 @@
}
char tableName[MAX_TAB_NAME_SIZE];
- TableRecord keyRecord;
SegmentedSectionPtr ssPtr;
signal->getSection(ssPtr,GetTableIdReq::TABLE_NAME);
copy((Uint32*)tableName, ssPtr);
- strcpy(keyRecord.tableName, tableName);
releaseSections(signal);
-
- if(len > sizeof(keyRecord.tableName)){
- jam();
- sendGET_TABLEID_REF((Signal*)signal,
- (GetTableIdReq *)req,
- GetTableIdRef::TableNameTooLong);
- return;
- }
-
- TableRecordPtr tablePtr;
- if(!c_tableRecordHash.find(tablePtr, keyRecord)) {
+
+ DictObject * obj_ptr_p = get_object(tableName, len);
+ if(obj_ptr_p == 0 || !DictTabInfo::isTable(obj_ptr_p->m_type)){
jam();
- sendGET_TABLEID_REF((Signal*)signal,
+ sendGET_TABLEID_REF(signal,
(GetTableIdReq *)req,
GetTableIdRef::TableNotDefined);
return;
}
+
+ TableRecordPtr tablePtr;
+ c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_id);
+
GetTableIdConf * conf = (GetTableIdConf *)req;
- conf->tableId = tablePtr.p->tableId;
- conf->schemaVersion = tablePtr.p->tableVersion;
- conf->senderData = senderData;
+ conf->tableId = tablePtr.p->tableId;
+ conf->schemaVersion = tablePtr.p->tableVersion;
+ conf->senderData = senderData;
sendSignal(senderRef, GSN_GET_TABLEID_CONF, signal,
GetTableIdConf::SignalLength, JBB);
-
}
@@ -6259,15 +6985,14 @@
const bool useLongSig = (req->requestType & GetTabInfoReq::LongSignalConf);
const Uint32 reqType = req->requestType & (~GetTabInfoReq::LongSignalConf);
-
- TableRecordPtr tablePtr;
+
+ Uint32 obj_id = RNIL;
if(reqType == GetTabInfoReq::RequestByName){
jam();
ndbrequire(signal->getNoOfSections() == 1);
const Uint32 len = req->tableNameLen;
- TableRecord keyRecord;
- if(len > sizeof(keyRecord.tableName)){
+ if(len > MAX_TAB_NAME_SIZE){
jam();
releaseSections(signal);
sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNameTooLong);
@@ -6279,33 +7004,37 @@
signal->getSection(ssPtr,GetTabInfoReq::TABLE_NAME);
SimplePropertiesSectionReader r0(ssPtr, getSectionSegmentPool());
r0.reset(); // undo implicit first()
- if(r0.getWords((Uint32*)tableName, ((len + 3)/4)))
- memcpy(keyRecord.tableName, tableName, len);
- else {
+ if(!r0.getWords((Uint32*)tableName, (len+3)/4)){
jam();
releaseSections(signal);
sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNotDefined);
return;
}
releaseSections(signal);
- // memcpy(keyRecord.tableName, req->tableName, len);
- //ntohS(&keyRecord.tableName[0], len);
-
- c_tableRecordHash.find(tablePtr, keyRecord);
+
+ DictObject * old_ptr_p = old_ptr_p = get_object(tableName, len);
+ if(old_ptr_p)
+ obj_id = old_ptr_p->m_id;
} else {
jam();
- c_tableRecordPool.getPtr(tablePtr, req->tableId, false);
+ obj_id = req->tableId;
}
-
+
+ SchemaFile::TableEntry *objEntry = 0;
+ if(obj_id != RNIL){
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ objEntry = getTableEntry(xsf, obj_id);
+ }
+
// The table seached for was not found
- if(tablePtr.i == RNIL){
+ if(objEntry == 0){
jam();
- sendGET_TABINFOREF(signal, req, GetTabInfoRef::InvalidTableId);
+ sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNotDefined);
return;
}//if
- if (! (tablePtr.p->tabState == TableRecord::DEFINED ||
- tablePtr.p->tabState == TableRecord::BACKUP_ONGOING)) {
+ if (objEntry->m_tableState != SchemaFile::TABLE_ADD_COMMITTED &&
+ objEntry->m_tableState != SchemaFile::ALTER_TABLE_COMMITTED){
jam();
sendGET_TABINFOREF(signal, req, GetTabInfoRef::TableNotDefined);
return;
@@ -6314,16 +7043,34 @@
c_retrieveRecord.busyState = true;
c_retrieveRecord.blockRef = req->senderRef;
c_retrieveRecord.m_senderData = req->senderData;
- c_retrieveRecord.tableId = tablePtr.i;
+ c_retrieveRecord.tableId = obj_id;
c_retrieveRecord.currentSent = 0;
c_retrieveRecord.m_useLongSig = useLongSig;
-
+ c_retrieveRecord.m_table_type = objEntry->m_tableType;
c_packTable.m_state = PackTable::PTS_GET_TAB;
-
- signal->theData[0] = ZPACK_TABLE_INTO_PAGES;
- signal->theData[1] = tablePtr.i;
- signal->theData[2] = c_retrieveRecord.retrievePage;
- sendSignal(reference(), GSN_CONTINUEB, signal, 3, JBB);
+
+ if(objEntry->m_tableType==DictTabInfo::Datafile)
+ {
+ jam();
+ GetTabInfoReq *req= (GetTabInfoReq*)signal->theData;
+ req->senderData= c_retrieveRecord.retrievePage;
+ req->senderRef= reference();
+ req->requestType= GetTabInfoReq::RequestById;
+ req->tableId= obj_id;
+
+ sendSignal(TSMAN_REF, GSN_GET_TABINFOREQ, signal,
+ GetTabInfoReq::SignalLength, JBB);
+ }
+ else
+ {
+ jam();
+ signal->theData[0] = ZPACK_TABLE_INTO_PAGES;
+ signal->theData[1] = obj_id;
+ signal->theData[2] = objEntry->m_tableType;
+ signal->theData[3] = c_retrieveRecord.retrievePage;
+ sendSignal(reference(), GSN_CONTINUEB, signal, 4, JBB);
+ }
+ jam();
}//execGET_TABINFOREQ()
void Dbdict::sendGetTabResponse(Signal* signal)
@@ -6345,7 +7092,8 @@
conf->tableId = c_retrieveRecord.tableId;
conf->senderData = c_retrieveRecord.m_senderData;
conf->totalLen = c_retrieveRecord.retrievedNoOfWords;
-
+ conf->tableType = c_retrieveRecord.m_table_type;
+
Callback c = { safe_cast(&Dbdict::initRetrieveRecord), 0 };
LinearSectionPtr ptr[3];
ptr[0].p = pagePointer;
@@ -6379,18 +7127,6 @@
sendSignal(retRef, GSN_GET_TABINFOREF, signal, signal->length(), JBB);
}//sendGET_TABINFOREF()
-Uint32 convertEndian(Uint32 in) {
-#ifdef WORDS_BIGENDIAN
- Uint32 ut = 0;
- ut += ((in >> 24) & 255);
- ut += (((in >> 16) & 255) << 8);
- ut += (((in >> 8) & 255) << 16);
- ut += ((in & 255) << 24);
- return ut;
-#else
- return in;
-#endif
-}
void
Dbdict::execLIST_TABLES_REQ(Signal* signal)
{
@@ -6409,144 +7145,125 @@
conf->senderData = senderData;
conf->counter = 0;
Uint32 pos = 0;
- for (i = 0; i < c_tableRecordPool.getSize(); i++) {
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, i);
- // filter
- if (tablePtr.p->tabState == TableRecord::NOT_DEFINED ||
- tablePtr.p->tabState == TableRecord::REORG_TABLE_PREPARED)
- continue;
-
- if ((reqTableType != (Uint32)0) && (reqTableType != (unsigned)tablePtr.p->tableType))
+ DLHashTable<DictObject>::Iterator iter;
+ bool ok = c_obj_hash.first(iter);
+ for(; ok; ok = c_obj_hash.next(iter)){
+ Uint32 type = iter.curr.p->m_type;
+ if ((reqTableType != (Uint32)0) && (reqTableType != type))
continue;
- if (reqListIndexes && reqTableId != tablePtr.p->primaryTableId)
+
+ if (reqListIndexes && !DictTabInfo::isIndex(type))
continue;
- conf->tableData[pos] = 0;
- // id
- conf->setTableId(pos, tablePtr.i);
- // type
- conf->setTableType(pos, tablePtr.p->tableType);
- // state
- if (tablePtr.p->isTable()) {
- switch (tablePtr.p->tabState) {
- case TableRecord::DEFINING:
- case TableRecord::CHECKED:
- conf->setTableState(pos, DictTabInfo::StateBuilding);
- break;
- case TableRecord::PREPARE_DROPPING:
- case TableRecord::DROPPING:
- conf->setTableState(pos, DictTabInfo::StateDropping);
- break;
- case TableRecord::DEFINED:
- conf->setTableState(pos, DictTabInfo::StateOnline);
- break;
- case TableRecord::BACKUP_ONGOING:
- conf->setTableState(pos, DictTabInfo::StateBackup);
- break;
- default:
- conf->setTableState(pos, DictTabInfo::StateBroken);
- break;
+
+ TableRecordPtr tablePtr;
+ if (DictTabInfo::isTable(type) || DictTabInfo::isIndex(type)){
+ c_tableRecordPool.getPtr(tablePtr, iter.curr.p->m_id);
+
+ if(reqListIndexes && (reqTableId != tablePtr.p->primaryTableId))
+ continue;
+
+ conf->tableData[pos] = 0;
+ conf->setTableId(pos, tablePtr.i); // id
+ conf->setTableType(pos, type); // type
+ // state
+
+ if(DictTabInfo::isTable(type)){
+ switch (tablePtr.p->tabState) {
+ case TableRecord::DEFINING:
+ case TableRecord::CHECKED:
+ conf->setTableState(pos, DictTabInfo::StateBuilding);
+ break;
+ case TableRecord::PREPARE_DROPPING:
+ case TableRecord::DROPPING:
+ conf->setTableState(pos, DictTabInfo::StateDropping);
+ break;
+ case TableRecord::DEFINED:
+ conf->setTableState(pos, DictTabInfo::StateOnline);
+ break;
+ case TableRecord::BACKUP_ONGOING:
+ conf->setTableState(pos, DictTabInfo::StateBackup);
+ break;
+ default:
+ conf->setTableState(pos, DictTabInfo::StateBroken);
+ break;
+ }
+ }
+ if (tablePtr.p->isIndex()) {
+ switch (tablePtr.p->indexState) {
+ case TableRecord::IS_OFFLINE:
+ conf->setTableState(pos, DictTabInfo::StateOffline);
+ break;
+ case TableRecord::IS_BUILDING:
+ conf->setTableState(pos, DictTabInfo::StateBuilding);
+ break;
+ case TableRecord::IS_DROPPING:
+ conf->setTableState(pos, DictTabInfo::StateDropping);
+ break;
+ case TableRecord::IS_ONLINE:
+ conf->setTableState(pos, DictTabInfo::StateOnline);
+ break;
+ default:
+ conf->setTableState(pos, DictTabInfo::StateBroken);
+ break;
+ }
+ }
+ // store
+ if (! tablePtr.p->storedTable) {
+ conf->setTableStore(pos, DictTabInfo::StoreTemporary);
+ } else {
+ conf->setTableStore(pos, DictTabInfo::StorePermanent);
}
+ pos++;
}
- if (tablePtr.p->isIndex()) {
- switch (tablePtr.p->indexState) {
- case TableRecord::IS_OFFLINE:
- conf->setTableState(pos, DictTabInfo::StateOffline);
- break;
- case TableRecord::IS_BUILDING:
- conf->setTableState(pos, DictTabInfo::StateBuilding);
- break;
- case TableRecord::IS_DROPPING:
- conf->setTableState(pos, DictTabInfo::StateDropping);
- break;
- case TableRecord::IS_ONLINE:
- conf->setTableState(pos, DictTabInfo::StateOnline);
- break;
+ if(DictTabInfo::isTrigger(type)){
+ TriggerRecordPtr triggerPtr;
+ c_triggerRecordPool.getPtr(triggerPtr, iter.curr.p->m_id);
+
+ conf->tableData[pos] = 0;
+ conf->setTableId(pos, triggerPtr.i);
+ conf->setTableType(pos, type);
+ switch (triggerPtr.p->triggerState) {
+ case TriggerRecord::TS_OFFLINE:
+ conf->setTableState(pos, DictTabInfo::StateOffline);
+ break;
+ case TriggerRecord::TS_ONLINE:
+ conf->setTableState(pos, DictTabInfo::StateOnline);
+ break;
default:
- conf->setTableState(pos, DictTabInfo::StateBroken);
- break;
+ conf->setTableState(pos, DictTabInfo::StateBroken);
+ break;
}
- }
- // store
- if (! tablePtr.p->storedTable) {
conf->setTableStore(pos, DictTabInfo::StoreTemporary);
- } else {
- conf->setTableStore(pos, DictTabInfo::StorePermanent);
- }
- pos++;
- if (pos >= ListTablesConf::DataLength) {
- sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
- ListTablesConf::SignalLength, JBB);
- conf->counter++;
- pos = 0;
- }
- if (! reqListNames)
- continue;
- const Uint32 size = strlen(tablePtr.p->tableName) + 1;
- conf->tableData[pos] = size;
- pos++;
- if (pos >= ListTablesConf::DataLength) {
- sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
- ListTablesConf::SignalLength, JBB);
- conf->counter++;
- pos = 0;
+ pos++;
}
- Uint32 k = 0;
- while (k < size) {
- char* p = (char*)&conf->tableData[pos];
- for (Uint32 j = 0; j < 4; j++) {
- if (k < size)
- *p++ = tablePtr.p->tableName[k++];
- else
- *p++ = 0;
- }
+ if (DictTabInfo::isFilegroup(type)){
+ jam();
+ conf->tableData[pos] = 0;
+ conf->setTableId(pos, iter.curr.p->m_id);
+ conf->setTableType(pos, type); // type
pos++;
- if (pos >= ListTablesConf::DataLength) {
- sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
- ListTablesConf::SignalLength, JBB);
- conf->counter++;
- pos = 0;
- }
}
- }
- // XXX merge with above somehow
- for (i = 0; i < c_triggerRecordPool.getSize(); i++) {
- if (reqListIndexes)
- break;
- TriggerRecordPtr triggerPtr;
- c_triggerRecordPool.getPtr(triggerPtr, i);
- if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED)
- continue;
- // constant 10 hardcoded
- Uint32 type = 10 + triggerPtr.p->triggerType;
- if (reqTableType != 0 && reqTableType != type)
- continue;
- conf->tableData[pos] = 0;
- conf->setTableId(pos, triggerPtr.i);
- conf->setTableType(pos, type);
- switch (triggerPtr.p->triggerState) {
- case TriggerRecord::TS_OFFLINE:
- conf->setTableState(pos, DictTabInfo::StateOffline);
- break;
- case TriggerRecord::TS_ONLINE:
- conf->setTableState(pos, DictTabInfo::StateOnline);
- break;
- default:
- conf->setTableState(pos, DictTabInfo::StateBroken);
- break;
+ if (DictTabInfo::isFile(type)){
+ jam();
+ conf->tableData[pos] = 0;
+ conf->setTableId(pos, iter.curr.p->m_id);
+ conf->setTableType(pos, type); // type
+ pos++;
}
- conf->setTableStore(pos, DictTabInfo::StoreTemporary);
- pos++;
+
if (pos >= ListTablesConf::DataLength) {
sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
- ListTablesConf::SignalLength, JBB);
+ ListTablesConf::SignalLength, JBB);
conf->counter++;
pos = 0;
}
+
if (! reqListNames)
continue;
- const Uint32 size = strlen(triggerPtr.p->triggerName) + 1;
+
+ Rope name(c_rope_pool, iter.curr.p->m_name);
+ const Uint32 size = name.size();
conf->tableData[pos] = size;
pos++;
if (pos >= ListTablesConf::DataLength) {
@@ -6555,21 +7272,23 @@
conf->counter++;
pos = 0;
}
- Uint32 k = 0;
- while (k < size) {
+ Uint32 i = 0;
+ char tmp[MAX_TAB_NAME_SIZE];
+ name.copy(tmp);
+ while (i < size) {
char* p = (char*)&conf->tableData[pos];
for (Uint32 j = 0; j < 4; j++) {
- if (k < size)
- *p++ = triggerPtr.p->triggerName[k++];
- else
- *p++ = 0;
+ if (i < size)
+ *p++ = tmp[i++];
+ else
+ *p++ = 0;
}
pos++;
if (pos >= ListTablesConf::DataLength) {
- sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
- ListTablesConf::SignalLength, JBB);
- conf->counter++;
- pos = 0;
+ sendSignal(senderRef, GSN_LIST_TABLES_CONF, signal,
+ ListTablesConf::SignalLength, JBB);
+ conf->counter++;
+ pos = 0;
}
}
}
@@ -6810,8 +7529,13 @@
void
Dbdict::createIndex_toCreateTable(Signal* signal, OpCreateIndexPtr opPtr)
{
- Uint32 attrid_map[MAX_ATTRIBUTES_IN_INDEX];
+ union {
+ char tableName[MAX_TAB_NAME_SIZE];
+ char attributeName[MAX_ATTR_NAME_SIZE];
+ };
Uint32 k;
+ Uint32 attrid_map[MAX_ATTRIBUTES_IN_INDEX];
+
jam();
const CreateIndxReq* const req = &opPtr.p->m_request;
// signal data writer
@@ -6875,6 +7599,7 @@
opPtr.p->m_errorLine = __LINE__;
return;
}
+
if (indexPtr.p->isOrderedIndex()) {
// tree node size in words (make configurable later)
indexPtr.p->tupKeyLength = MAX_TTREE_NODE_SIZE;
@@ -6885,13 +7610,16 @@
for (k = 0; k < opPtr.p->m_attrList.sz; k++) {
jam();
unsigned current_id= opPtr.p->m_attrList.id[k];
- AttributeRecord* aRec= NULL;
- Uint32 tAttr= tablePtr.p->firstAttribute;
- for (; tAttr != RNIL; tAttr= aRec->nextAttrInTable)
+ Uint32 tAttr = tablePtr.p->m_attributes.firstItem;
+ AttributeRecord* aRec = NULL;
+ for (; tAttr != RNIL; )
{
aRec = c_attributeRecordPool.getPtr(tAttr);
if (aRec->attributeId != current_id)
- continue;
+ {
+ tAttr= aRec->nextList;
+ continue;
+ }
jam();
break;
}
@@ -6908,21 +7636,29 @@
opPtr.p->m_errorLine = __LINE__;
return;
}
- mask.set(current_id);
-
const Uint32 a = aRec->attributeDescriptor;
+
+ if (AttributeDescriptor::getDiskBased(a))
+ {
+ jam();
+ opPtr.p->m_errorCode = CreateIndxRef::IndexOnDiskAttributeError;
+ opPtr.p->m_errorLine = __LINE__;
+ return;
+ }
+
+ mask.set(current_id);
unsigned kk= k;
if (indexPtr.p->isHashIndex()) {
const Uint32 s1 = AttributeDescriptor::getSize(a);
const Uint32 s2 = AttributeDescriptor::getArraySize(a);
indexPtr.p->tupKeyLength += ((1 << s1) * s2 + 31) >> 5;
- // reorder the attributes according to the tableid order
- // for unque indexes
+
for (; kk > 0 && current_id < attrid_map[kk-1]>>16; kk--)
attrid_map[kk]= attrid_map[kk-1];
}
attrid_map[kk]= k | (current_id << 16);
}
+
indexPtr.p->noOfPrimkey = indexPtr.p->noOfAttributes;
// plus concatenated primary table key attribute
indexPtr.p->noOfAttributes += 1;
@@ -6932,15 +7668,15 @@
w.add(DictTabInfo::TableLoggedFlag, indexPtr.p->storedTable);
w.add(DictTabInfo::FragmentTypeVal, indexPtr.p->fragmentType);
w.add(DictTabInfo::TableTypeVal, indexPtr.p->tableType);
- w.add(DictTabInfo::PrimaryTable, tablePtr.p->tableName);
+ Rope name(c_rope_pool, tablePtr.p->tableName);
+ name.copy(tableName);
+ w.add(DictTabInfo::PrimaryTable, tableName);
w.add(DictTabInfo::PrimaryTableId, tablePtr.i);
w.add(DictTabInfo::NoOfAttributes, indexPtr.p->noOfAttributes);
w.add(DictTabInfo::NoOfKeyAttr, indexPtr.p->noOfPrimkey);
w.add(DictTabInfo::NoOfNullable, indexPtr.p->noOfNullAttr);
w.add(DictTabInfo::KeyLength, indexPtr.p->tupKeyLength);
// write index key attributes
- AttributeRecordPtr aRecPtr;
- c_attributeRecordPool.getPtr(aRecPtr, tablePtr.p->firstAttribute);
for (k = 0; k < opPtr.p->m_attrList.sz; k++) {
// insert the attributes in the order decided above in attrid_map
// k is new order, current_id is in previous order
@@ -6948,16 +7684,20 @@
// passed up to NdbDictionary
unsigned current_id= opPtr.p->m_attrList.id[attrid_map[k] & 0xffff];
jam();
- for (Uint32 tAttr = tablePtr.p->firstAttribute; tAttr != RNIL; ) {
+ for (Uint32 tAttr = tablePtr.p->m_attributes.firstItem; tAttr != RNIL; ) {
AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr);
- tAttr = aRec->nextAttrInTable;
+ tAttr = aRec->nextList;
if (aRec->attributeId != current_id)
continue;
jam();
const Uint32 a = aRec->attributeDescriptor;
bool isNullable = AttributeDescriptor::getNullable(a);
+ Uint32 arrayType = AttributeDescriptor::getArrayType(a);
+ Rope attrName(c_rope_pool, aRec->attributeName);
+ attrName.copy(attributeName);
+ w.add(DictTabInfo::AttributeName, attributeName);
Uint32 attrType = AttributeDescriptor::getType(a);
- w.add(DictTabInfo::AttributeName, aRec->attributeName);
+ // computed
w.add(DictTabInfo::AttributeId, k);
if (indexPtr.p->isHashIndex()) {
w.add(DictTabInfo::AttributeKeyFlag, (Uint32)true);
@@ -6967,6 +7707,7 @@
w.add(DictTabInfo::AttributeKeyFlag, (Uint32)false);
w.add(DictTabInfo::AttributeNullableFlag, (Uint32)isNullable);
}
+ w.add(DictTabInfo::AttributeArrayType, arrayType);
w.add(DictTabInfo::AttributeExtType, attrType);
w.add(DictTabInfo::AttributeExtPrecision, aRec->extPrecision);
w.add(DictTabInfo::AttributeExtScale, aRec->extScale);
@@ -6976,9 +7717,26 @@
}
if (indexPtr.p->isHashIndex()) {
jam();
- // write concatenated primary table key attribute
+
+ Uint32 key_type = NDB_ARRAYTYPE_FIXED;
+ AttributeRecordPtr attrPtr;
+ LocalDLFifoList<AttributeRecord> alist(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+ for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr))
+ {
+ const Uint32 desc = attrPtr.p->attributeDescriptor;
+ if (AttributeDescriptor::getPrimaryKey(desc) &&
+ AttributeDescriptor::getArrayType(desc) != NDB_ARRAYTYPE_FIXED)
+ {
+ key_type = NDB_ARRAYTYPE_MEDIUM_VAR;
+ break;
+ }
+ }
+
+ // write concatenated primary table key attribute i.e. keyinfo
w.add(DictTabInfo::AttributeName, "NDB$PK");
w.add(DictTabInfo::AttributeId, opPtr.p->m_attrList.sz);
+ w.add(DictTabInfo::AttributeArrayType, key_type);
w.add(DictTabInfo::AttributeKeyFlag, (Uint32)false);
w.add(DictTabInfo::AttributeNullableFlag, (Uint32)false);
w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned);
@@ -6990,6 +7748,8 @@
// write index tree node as Uint32 array attribute
w.add(DictTabInfo::AttributeName, "NDB$TNODE");
w.add(DictTabInfo::AttributeId, opPtr.p->m_attrList.sz);
+ // should not matter but VAR crashes in TUP
+ w.add(DictTabInfo::AttributeArrayType, (Uint32)NDB_ARRAYTYPE_FIXED);
w.add(DictTabInfo::AttributeKeyFlag, (Uint32)true);
w.add(DictTabInfo::AttributeNullableFlag, (Uint32)false);
w.add(DictTabInfo::AttributeExtType, (Uint32)DictTabInfo::ExtUnsigned);
@@ -7178,24 +7938,28 @@
// forward initial request plus operation key to all
Uint32 indexId= req->getIndexId();
Uint32 indexVersion= req->getIndexVersion();
- TableRecordPtr tmp;
- int res = getMetaTablePtr(tmp, indexId, indexVersion);
- switch(res){
- case MetaData::InvalidArgument:
+
+ if(indexId >= c_tableRecordPool.getSize())
+ {
err = DropIndxRef::IndexNotFound;
goto error;
- case MetaData::TableNotFound:
- case MetaData::InvalidTableVersion:
+ }
+
+ TableRecordPtr tmp;
+ c_tableRecordPool.getPtr(tmp, indexId);
+ if(tmp.p->tabState == TableRecord::NOT_DEFINED ||
+ tmp.p->tableVersion != indexVersion)
+ {
err = DropIndxRef::InvalidIndexVersion;
goto error;
}
-
+
if (! tmp.p->isIndex()) {
jam();
err = DropIndxRef::NotAnIndex;
goto error;
}
-
+
if (tmp.p->indexState != TableRecord::IS_ONLINE)
req->addRequestFlag(RequestFlag::RF_FORCE);
@@ -7204,7 +7968,7 @@
req->setOpKey(++c_opRecordSequence);
NodeReceiverGroup rg(DBDICT, c_aliveNodes);
sendSignal(rg, GSN_DROP_INDX_REQ,
- signal, DropIndxReq::SignalLength + 1, JBB);
+ signal, DropIndxReq::SignalLength + 1, JBB);
return;
}
// seize operation record
@@ -7643,18 +8407,18 @@
UtilPrepareReq::OperationTypeValue prepReq)
{
// find table id for event system table
- TableRecord keyRecord;
- strcpy(keyRecord.tableName, EVENT_SYSTEM_TABLE_NAME);
+ DictObject * opj_ptr_p = get_object(EVENT_SYSTEM_TABLE_NAME,
+ sizeof(EVENT_SYSTEM_TABLE_NAME));
+ ndbrequire(opj_ptr_p != 0);
TableRecordPtr tablePtr;
- c_tableRecordHash.find(tablePtr, keyRecord);
-
+ c_tableRecordPool.getPtr(tablePtr, opj_ptr_p->m_id);
ndbrequire(tablePtr.i != RNIL); // system table must exist
-
+
Uint32 tableId = tablePtr.p->tableId; /* System table */
Uint32 noAttr = tablePtr.p->noOfAttributes;
ndbrequire(noAttr == EVENT_SYSTEM_TABLE_LENGTH);
-
+
switch (prepReq) {
case UtilPrepareReq::Update:
case UtilPrepareReq::Insert:
@@ -8359,13 +9123,8 @@
evntRecPtr.p->m_eventRec.TABLEVERSION));
// find table id for event table
- TableRecord keyRecord;
- strcpy(keyRecord.tableName, evntRecPtr.p->m_eventRec.TABLE_NAME);
-
- TableRecordPtr tablePtr;
- c_tableRecordHash.find(tablePtr, keyRecord);
-
- if (tablePtr.i == RNIL) {
+ DictObject* obj_ptr_p = get_object(evntRecPtr.p->m_eventRec.TABLE_NAME);
+ if(!obj_ptr_p){
jam();
evntRecPtr.p->m_errorCode = 723;
evntRecPtr.p->m_errorLine = __LINE__;
@@ -8375,6 +9134,8 @@
return;
}
+ TableRecordPtr tablePtr;
+ c_tableRecordPool.getPtr(tablePtr, obj_ptr_p->m_id);
evntRec->m_request.setTableId(tablePtr.p->tableId);
evntRec->m_request.setTableVersion(tablePtr.p->tableVersion);
@@ -10880,21 +11641,14 @@
}
}
releaseSections(signal);
- {
- // check that trigger name is unique
- TriggerRecordPtr triggerPtr;
- TriggerRecord keyRecord;
- strcpy(keyRecord.triggerName, opPtr.p->m_triggerName);
- c_triggerRecordHash.find(triggerPtr, keyRecord);
- if (triggerPtr.i != RNIL) {
- jam();
- opPtr.p->m_errorCode = CreateTrigRef::TriggerExists;
- opPtr.p->m_errorLine = __LINE__;
- createTrigger_sendReply(signal, opPtr, opPtr.p->m_isMaster);
- return;
- }
+ if(get_object(opPtr.p->m_triggerName) != 0){
+ jam();
+ opPtr.p->m_errorCode = CreateTrigRef::TriggerExists;
+ opPtr.p->m_errorLine = __LINE__;
+ createTrigger_sendReply(signal, opPtr, opPtr.p->m_isMaster);
+ return;
}
-
+
// master expects to hear from all
if (opPtr.p->m_isMaster)
opPtr.p->m_signalCounter = receiverNodes;
@@ -11123,7 +11877,10 @@
c_triggerRecordPool.getPtr(triggerPtr, triggerId);
initialiseTriggerRecord(triggerPtr);
// fill in trigger data
- strcpy(triggerPtr.p->triggerName, opPtr.p->m_triggerName);
+ {
+ Rope name(c_rope_pool, triggerPtr.p->triggerName);
+ ndbrequire(name.assign(opPtr.p->m_triggerName));
+ }
triggerPtr.p->triggerId = triggerId;
triggerPtr.p->tableId = req->getTableId();
triggerPtr.p->indexId = RNIL;
@@ -11136,7 +11893,16 @@
triggerPtr.p->triggerState = TriggerRecord::TS_OFFLINE;
// add to hash table
// ndbout_c("++++++++++++ Adding trigger id %u, %s", triggerPtr.p->triggerId, triggerPtr.p->triggerName);
- c_triggerRecordHash.add(triggerPtr);
+ {
+ Ptr<DictObject> obj_ptr;
+ ndbrequire(c_obj_hash.seize(obj_ptr));
+ obj_ptr.p->m_name = triggerPtr.p->triggerName;
+ obj_ptr.p->m_id = triggerId;
+ obj_ptr.p->m_type = triggerPtr.p->triggerType;
+ obj_ptr.p->m_ref_count = 0;
+ c_obj_hash.add(obj_ptr);
+ triggerPtr.p->m_obj_ptr_i = obj_ptr.i;
+ }
if (triggerPtr.p->triggerType == TriggerType::SECONDARY_INDEX ||
triggerPtr.p->triggerType == TriggerType::ORDERED_INDEX) {
jam();
@@ -11300,7 +12066,7 @@
if (signal->getNoOfSections() > 0) {
ndbrequire(signal->getNoOfSections() == 1);
jam();
- TriggerRecord keyRecord;
+ char triggerName[MAX_TAB_NAME_SIZE];
OpDropTrigger opTmp;
opPtr.p=&opTmp;
@@ -11308,7 +12074,7 @@
signal->getSection(ssPtr, DropTrigReq::TRIGGER_NAME_SECTION);
SimplePropertiesSectionReader ssReader(ssPtr, getSectionSegmentPool());
if (ssReader.getKey() != DropTrigReq::TriggerNameKey ||
- ! ssReader.getString(keyRecord.triggerName)) {
+ ! ssReader.getString(triggerName)) {
jam();
opPtr.p->m_errorCode = DropTrigRef::InvalidName;
opPtr.p->m_errorLine = __LINE__;
@@ -11318,16 +12084,16 @@
}
releaseSections(signal);
- TriggerRecordPtr triggerPtr;
-
- // ndbout_c("++++++++++++++ Looking for trigger %s", keyRecord.triggerName);
- c_triggerRecordHash.find(triggerPtr, keyRecord);
- if (triggerPtr.i == RNIL) {
+ //ndbout_c("++++++++++++++ Looking for trigger %s", keyRecord.triggerName);
+ DictObject * obj_ptr_p = get_object(triggerName);
+ if (obj_ptr_p == 0){
jam();
req->setTriggerId(RNIL);
} else {
jam();
- // ndbout_c("++++++++++ Found trigger %s", triggerPtr.p->triggerName);
+ //ndbout_c("++++++++++ Found trigger %s", triggerPtr.p->triggerName);
+ TriggerRecordPtr triggerPtr;
+ c_triggerRecordPool.getPtr(triggerPtr, obj_ptr_p->m_id);
req->setTriggerId(triggerPtr.p->triggerId);
req->setTableId(triggerPtr.p->tableId);
}
@@ -11597,9 +12363,9 @@
c_tableRecordPool.getPtr(indexPtr, triggerPtr.p->indexId);
indexPtr.p->buildTriggerId = RNIL;
}
- // remove trigger
- // ndbout_c("++++++++++++ Removing trigger id %u, %s", triggerPtr.p->triggerId, triggerPtr.p->triggerName);
- c_triggerRecordHash.remove(triggerPtr);
+ //remove trigger
+ //ndbout_c("++++++++++++ Removing trigger id %u, %s", triggerPtr.p->triggerId, triggerPtr.p->triggerName);
+ release_object(triggerPtr.p->m_obj_ptr_i);
triggerPtr.p->triggerState = TriggerRecord::TS_NOT_DEFINED;
}
@@ -12173,12 +12939,15 @@
jam();
list.sz = 0;
list.id[list.sz++] = AttributeHeader::FRAGMENT;
- for (Uint32 tAttr = tablePtr.p->firstAttribute; tAttr != RNIL; ) {
- AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr);
- if (aRec->tupleKey)
- list.id[list.sz++] = aRec->attributeId;
- tAttr = aRec->nextAttrInTable;
+ LocalDLFifoList<AttributeRecord> alist(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+ AttributeRecordPtr attrPtr;
+ for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)) {
+ if (attrPtr.p->tupleKey) {
+ list.id[list.sz++] = attrPtr.p->attributeId;
+ }
}
+ ndbrequire(list.sz == tablePtr.p->noOfPrimkey + 1);
ndbrequire(list.sz <= MAX_ATTRIBUTES_IN_INDEX + 1);
}
@@ -12187,16 +12956,27 @@
Dbdict::getIndexAttr(TableRecordPtr indexPtr, Uint32 itAttr, Uint32* id)
{
jam();
+
+ Uint32 len;
+ char name[MAX_ATTR_NAME_SIZE];
TableRecordPtr tablePtr;
+ AttributeRecordPtr attrPtr;
+
c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
AttributeRecord* iaRec = c_attributeRecordPool.getPtr(itAttr);
- for (Uint32 tAttr = tablePtr.p->firstAttribute; tAttr != RNIL; ) {
- AttributeRecord* aRec = c_attributeRecordPool.getPtr(tAttr);
- if (iaRec->equal(*aRec)) {
- id[0] = aRec->attributeId;
+ {
+ ConstRope tmp(c_rope_pool, iaRec->attributeName);
+ tmp.copy(name);
+ len = tmp.size();
+ }
+ LocalDLFifoList<AttributeRecord> alist(c_attributeRecordPool,
+ tablePtr.p->m_attributes);
+ for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)){
+ ConstRope tmp(c_rope_pool, attrPtr.p->attributeName);
+ if(tmp.compare(name, len) == 0){
+ id[0] = attrPtr.p->attributeId;
return;
}
- tAttr = aRec->nextAttrInTable;
}
ndbrequire(false);
}
@@ -12205,34 +12985,39 @@
Dbdict::getIndexAttrList(TableRecordPtr indexPtr, AttributeList& list)
{
jam();
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
list.sz = 0;
memset(list.id, 0, sizeof(list.id));
ndbrequire(indexPtr.p->noOfAttributes >= 2);
- Uint32 itAttr = indexPtr.p->firstAttribute;
- for (Uint32 i = 0; i < (Uint32)indexPtr.p->noOfAttributes - 1; i++) {
- getIndexAttr(indexPtr, itAttr, &list.id[list.sz++]);
- AttributeRecord* iaRec = c_attributeRecordPool.getPtr(itAttr);
- itAttr = iaRec->nextAttrInTable;
+
+ LocalDLFifoList<AttributeRecord> alist(c_attributeRecordPool,
+ indexPtr.p->m_attributes);
+ AttributeRecordPtr attrPtr;
+ for (alist.first(attrPtr); !attrPtr.isNull(); alist.next(attrPtr)) {
+ // skip last
+ AttributeRecordPtr tempPtr = attrPtr;
+ if (! alist.next(tempPtr))
+ break;
+ getIndexAttr(indexPtr, attrPtr.i, &list.id[list.sz++]);
}
+ ndbrequire(indexPtr.p->noOfAttributes == list.sz + 1);
}
void
Dbdict::getIndexAttrMask(TableRecordPtr indexPtr, AttributeMask& mask)
{
jam();
- TableRecordPtr tablePtr;
- c_tableRecordPool.getPtr(tablePtr, indexPtr.p->primaryTableId);
mask.clear();
ndbrequire(indexPtr.p->noOfAttributes >= 2);
- Uint32 itAttr = indexPtr.p->firstAttribute;
- for (Uint32 i = 0; i < (Uint32)indexPtr.p->noOfAttributes - 1; i++) {
+
+ AttributeRecordPtr attrPtr, currPtr;
+ LocalDLFifoList<AttributeRecord> alist(c_attributeRecordPool,
+ indexPtr.p->m_attributes);
+
+
+ for (alist.first(attrPtr); currPtr = attrPtr, alist.next(attrPtr); ){
Uint32 id;
- getIndexAttr(indexPtr, itAttr, &id);
+ getIndexAttr(indexPtr, currPtr.i, &id);
mask.set(id);
- AttributeRecord* iaRec = c_attributeRecordPool.getPtr(itAttr);
- itAttr = iaRec->nextAttrInTable;
}
}
@@ -12337,107 +13122,2146 @@
return &sf->TableEntries[i];
}
-// global metadata support
+//******************************************
+void
+Dbdict::execCREATE_FILE_REQ(Signal* signal){
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
+ }
+
+ CreateFileReq * req = (CreateFileReq*)signal->getDataPtr();
+ CreateFileRef * ref = (CreateFileRef*)signal->getDataPtrSend();
+ Uint32 senderRef = req->senderRef;
+ Uint32 senderData = req->senderData;
+ Uint32 type = req->objType;
+ Uint32 requestInfo = req->requestInfo;
+
+ do {
+ Ptr<SchemaTransaction> trans_ptr;
+ if (! c_Trans.seize(trans_ptr)){
+ ref->errorCode = CreateFileRef::Busy;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ const Uint32 trans_key = ++c_opRecordSequence;
+ trans_ptr.p->key = trans_key;
+ trans_ptr.p->m_senderRef = senderRef;
+ trans_ptr.p->m_senderData = senderData;
+ trans_ptr.p->m_nodes = c_aliveNodes;
+ trans_ptr.p->m_errorCode = 0;
+// trans_ptr.p->m_nodes.clear();
+// trans_ptr.p->m_nodes.set(getOwnNodeId());
+ c_Trans.add(trans_ptr);
+
+ const Uint32 op_key = ++c_opRecordSequence;
+ trans_ptr.p->m_op.m_key = op_key;
+ trans_ptr.p->m_op.m_vt_index = 1;
+ trans_ptr.p->m_op.m_state = DictObjOp::Preparing;
+
+ CreateObjReq* create_obj = (CreateObjReq*)signal->getDataPtrSend();
+ create_obj->op_key = op_key;
+ create_obj->senderRef = reference();
+ create_obj->senderData = trans_key;
+ create_obj->clientRef = senderRef;
+ create_obj->clientData = senderData;
+
+ create_obj->objType = type;
+ create_obj->requestInfo = requestInfo;
-int
-Dbdict::getMetaTablePtr(TableRecordPtr& tablePtr, Uint32 tableId, Uint32 tableVersion)
+ {
+ Uint32 objId = getFreeObjId(0);
+ if (objId == RNIL) {
+ ref->errorCode = CreateFileRef::NoMoreObjectRecords;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ create_obj->objId = objId;
+ trans_ptr.p->m_op.m_obj_id = objId;
+ create_obj->gci = 0;
+
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry *objEntry = getTableEntry(xsf, objId);
+ create_obj->objVersion =
+ create_obj_inc_schema_version(objEntry->m_tableVersion);
+ }
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key);
+ sendSignal(rg, GSN_CREATE_OBJ_REQ, signal,
+ CreateObjReq::SignalLength, JBB);
+ return;
+ } while(0);
+
+ ref->senderData = senderData;
+ ref->masterNodeId = c_masterNodeId;
+ sendSignal(senderRef, GSN_CREATE_FILE_REF,signal,
+ CreateFileRef::SignalLength, JBB);
+}
+
+void
+Dbdict::execCREATE_FILEGROUP_REQ(Signal* signal){
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
+ }
+
+ CreateFilegroupReq * req = (CreateFilegroupReq*)signal->getDataPtr();
+ CreateFilegroupRef * ref = (CreateFilegroupRef*)signal->getDataPtrSend();
+ Uint32 senderRef = req->senderRef;
+ Uint32 senderData = req->senderData;
+ Uint32 type = req->objType;
+
+ do {
+ Ptr<SchemaTransaction> trans_ptr;
+ if (! c_Trans.seize(trans_ptr)){
+ ref->errorCode = CreateFilegroupRef::Busy;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ if(getOwnNodeId() != c_masterNodeId){
+ jam();
+ ref->errorCode = CreateFilegroupRef::NotMaster;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ if (c_blockState != BS_IDLE){
+ jam();
+ ref->errorCode = CreateFilegroupRef::Busy;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ const Uint32 trans_key = ++c_opRecordSequence;
+ trans_ptr.p->key = trans_key;
+ trans_ptr.p->m_senderRef = senderRef;
+ trans_ptr.p->m_senderData = senderData;
+ trans_ptr.p->m_nodes = c_aliveNodes;
+ trans_ptr.p->m_errorCode = 0;
+ c_Trans.add(trans_ptr);
+
+ const Uint32 op_key = ++c_opRecordSequence;
+ trans_ptr.p->m_op.m_key = op_key;
+ trans_ptr.p->m_op.m_vt_index = 0;
+ trans_ptr.p->m_op.m_state = DictObjOp::Preparing;
+
+ CreateObjReq* create_obj = (CreateObjReq*)signal->getDataPtrSend();
+ create_obj->op_key = op_key;
+ create_obj->senderRef = reference();
+ create_obj->senderData = trans_key;
+ create_obj->clientRef = senderRef;
+ create_obj->clientData = senderData;
+
+ create_obj->objType = type;
+
+ {
+ Uint32 objId = getFreeObjId(0);
+ if (objId == RNIL) {
+ ref->errorCode = CreateFilegroupRef::NoMoreObjectRecords;
+ ref->status = 0;
+ ref->errorKey = 0;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ create_obj->objId = objId;
+ trans_ptr.p->m_op.m_obj_id = objId;
+ create_obj->gci = 0;
+
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry *objEntry = getTableEntry(xsf, objId);
+ create_obj->objVersion =
+ create_obj_inc_schema_version(objEntry->m_tableVersion);
+ }
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ tmp.init<CreateObjRef>(rg, GSN_CREATE_OBJ_REF, trans_key);
+ sendSignal(rg, GSN_CREATE_OBJ_REQ, signal,
+ CreateObjReq::SignalLength, JBB);
+ return;
+ } while(0);
+
+ ref->senderData = senderData;
+ ref->masterNodeId = c_masterNodeId;
+ sendSignal(senderRef, GSN_CREATE_FILEGROUP_REF,signal,
+ CreateFilegroupRef::SignalLength, JBB);
+}
+
+void
+Dbdict::execDROP_FILE_REQ(Signal* signal)
{
- if (tableId >= c_tableRecordPool.getSize()) {
- return MetaData::InvalidArgument;
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
}
- c_tableRecordPool.getPtr(tablePtr, tableId);
- if (tablePtr.p->tabState == TableRecord::NOT_DEFINED) {
- return MetaData::TableNotFound;
+
+ DropFileReq * req = (DropFileReq*)signal->getDataPtr();
+ DropFileRef * ref = (DropFileRef*)signal->getDataPtrSend();
+ Uint32 senderRef = req->senderRef;
+ Uint32 senderData = req->senderData;
+ Uint32 objId = req->file_id;
+ Uint32 version = req->file_version;
+
+ do {
+ Ptr<File> file_ptr;
+ if (!c_file_hash.find(file_ptr, objId))
+ {
+ ref->errorCode = DropFileRef::NoSuchFile;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ Ptr<SchemaTransaction> trans_ptr;
+ if (! c_Trans.seize(trans_ptr))
+ {
+ ref->errorCode = CreateFileRef::Busy;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ const Uint32 trans_key = ++c_opRecordSequence;
+ trans_ptr.p->key = trans_key;
+ trans_ptr.p->m_senderRef = senderRef;
+ trans_ptr.p->m_senderData = senderData;
+ trans_ptr.p->m_nodes = c_aliveNodes;
+ trans_ptr.p->m_errorCode = 0;
+ c_Trans.add(trans_ptr);
+
+ const Uint32 op_key = ++c_opRecordSequence;
+ trans_ptr.p->m_op.m_key = op_key;
+ trans_ptr.p->m_op.m_vt_index = 2;
+ trans_ptr.p->m_op.m_state = DictObjOp::Preparing;
+
+ DropObjReq* drop_obj = (DropObjReq*)signal->getDataPtrSend();
+ drop_obj->op_key = op_key;
+ drop_obj->objVersion = version;
+ drop_obj->objId = objId;
+ drop_obj->objType = file_ptr.p->m_type;
+ trans_ptr.p->m_op.m_obj_id = objId;
+
+ drop_obj->senderRef = reference();
+ drop_obj->senderData = trans_key;
+ drop_obj->clientRef = senderRef;
+ drop_obj->clientData = senderData;
+
+ drop_obj->requestInfo = 0;
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key);
+ sendSignal(rg, GSN_DROP_OBJ_REQ, signal,
+ DropObjReq::SignalLength, JBB);
+ return;
+ } while(0);
+
+ ref->senderData = senderData;
+ ref->masterNodeId = c_masterNodeId;
+ sendSignal(senderRef, GSN_DROP_FILE_REF,signal,
+ DropFileRef::SignalLength, JBB);
+}
+
+void
+Dbdict::execDROP_FILEGROUP_REQ(Signal* signal)
+{
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
}
- if (tablePtr.p->tableVersion != tableVersion) {
- return MetaData::InvalidTableVersion;
+
+ DropFilegroupReq * req = (DropFilegroupReq*)signal->getDataPtr();
+ DropFilegroupRef * ref = (DropFilegroupRef*)signal->getDataPtrSend();
+ Uint32 senderRef = req->senderRef;
+ Uint32 senderData = req->senderData;
+ Uint32 objId = req->filegroup_id;
+ Uint32 version = req->filegroup_version;
+
+ do {
+ Ptr<Filegroup> filegroup_ptr;
+ if (!c_filegroup_hash.find(filegroup_ptr, objId))
+ {
+ ref->errorCode = DropFilegroupRef::NoSuchFilegroup;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ Ptr<SchemaTransaction> trans_ptr;
+ if (! c_Trans.seize(trans_ptr))
+ {
+ ref->errorCode = CreateFilegroupRef::Busy;
+ ref->errorLine = __LINE__;
+ break;
+ }
+
+ const Uint32 trans_key = ++c_opRecordSequence;
+ trans_ptr.p->key = trans_key;
+ trans_ptr.p->m_senderRef = senderRef;
+ trans_ptr.p->m_senderData = senderData;
+ trans_ptr.p->m_nodes = c_aliveNodes;
+ trans_ptr.p->m_errorCode = 0;
+ c_Trans.add(trans_ptr);
+
+ const Uint32 op_key = ++c_opRecordSequence;
+ trans_ptr.p->m_op.m_key = op_key;
+ trans_ptr.p->m_op.m_vt_index = 3;
+ trans_ptr.p->m_op.m_state = DictObjOp::Preparing;
+
+ DropObjReq* drop_obj = (DropObjReq*)signal->getDataPtrSend();
+ drop_obj->op_key = op_key;
+ drop_obj->objVersion = version;
+ drop_obj->objId = objId;
+ drop_obj->objType = filegroup_ptr.p->m_type;
+ trans_ptr.p->m_op.m_obj_id = objId;
+
+ drop_obj->senderRef = reference();
+ drop_obj->senderData = trans_key;
+ drop_obj->clientRef = senderRef;
+ drop_obj->clientData = senderData;
+
+ drop_obj->requestInfo = 0;
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ tmp.init<CreateObjRef>(rg, GSN_DROP_OBJ_REF, trans_key);
+ sendSignal(rg, GSN_DROP_OBJ_REQ, signal,
+ DropObjReq::SignalLength, JBB);
+ return;
+ } while(0);
+
+ ref->senderData = senderData;
+ ref->masterNodeId = c_masterNodeId;
+ sendSignal(senderRef, GSN_DROP_FILEGROUP_REF,signal,
+ DropFilegroupRef::SignalLength, JBB);
+}
+
+void
+Dbdict::execCREATE_OBJ_REF(Signal* signal){
+ jamEntry();
+
+ CreateObjRef * const ref = (CreateObjRef*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, ref->senderData));
+
+ if(ref->errorCode != CreateObjRef::NF_FakeErrorREF){
+ trans_ptr.p->setErrorCode(ref->errorCode);
}
- // online flag is not maintained by DICT
- tablePtr.p->online =
- tablePtr.p->isTable() &&
- (tablePtr.p->tabState == TableRecord::DEFINED ||
- tablePtr.p->tabState == TableRecord::BACKUP_ONGOING) ||
- tablePtr.p->isIndex() && tablePtr.p->indexState == TableRecord::IS_ONLINE;
- return 0;
+ Uint32 node = refToNode(ref->senderRef);
+ schemaOp_reply(signal, trans_ptr.p, node);
}
-int
-Dbdict::getMetaTable(MetaData::Table& table, Uint32 tableId, Uint32 tableVersion)
+void
+Dbdict::execCREATE_OBJ_CONF(Signal* signal){
+ jamEntry();
+
+ CreateObjConf * const conf = (CreateObjConf*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, conf->senderData));
+ schemaOp_reply(signal, trans_ptr.p, refToNode(conf->senderRef));
+}
+
+void
+Dbdict::schemaOp_reply(Signal* signal,
+ SchemaTransaction * trans_ptr_p,
+ Uint32 nodeId)
{
- int ret;
- TableRecordPtr tablePtr;
- if ((ret = getMetaTablePtr(tablePtr, tableId, tableVersion)) < 0) {
- return ret;
+ {
+ SafeCounter tmp(c_counterMgr, trans_ptr_p->m_counter);
+ if(!tmp.clearWaitingFor(nodeId)){
+ jam();
+ return;
+ }
}
- new (&table) MetaData::Table(*tablePtr.p);
- return 0;
+
+ switch(trans_ptr_p->m_op.m_state){
+ case DictObjOp::Preparing:{
+
+ if(trans_ptr_p->m_errorCode != 0)
+ {
+ jam();
+ /**
+ * Failed to prepare on atleast one node -> abort on all
+ */
+ trans_ptr_p->m_op.m_state = DictObjOp::Aborting;
+ trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+ trans_ptr_p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::trans_abort_start_done);
+
+ if(f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_abort_start)
+ (this->*f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_abort_start)
+ (signal, trans_ptr_p);
+ else
+ execute(signal, trans_ptr_p->m_callback, 0);
+ return;
+ }
+
+ trans_ptr_p->m_op.m_state = DictObjOp::Prepared;
+ trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+ trans_ptr_p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::trans_commit_start_done);
+
+ if(f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_commit_start)
+ (this->*f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_commit_start)
+ (signal, trans_ptr_p);
+ else
+ execute(signal, trans_ptr_p->m_callback, 0);
+ return;
+ }
+ case DictObjOp::Committing: {
+ jam();
+ ndbrequire(trans_ptr_p->m_errorCode == 0);
+
+ trans_ptr_p->m_op.m_state = DictObjOp::Committed;
+ trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+ trans_ptr_p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::trans_commit_complete_done);
+
+ if(f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_commit_complete)
+ (this->*f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_commit_complete)
+ (signal, trans_ptr_p);
+ else
+ execute(signal, trans_ptr_p->m_callback, 0);
+ return;
+ }
+ case DictObjOp::Aborting:{
+ jam();
+
+ trans_ptr_p->m_op.m_state = DictObjOp::Committed;
+ trans_ptr_p->m_callback.m_callbackData = trans_ptr_p->key;
+ trans_ptr_p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::trans_abort_complete_done);
+
+ if(f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_abort_complete)
+ (this->*f_dict_op[trans_ptr_p->m_op.m_vt_index].m_trans_abort_complete)
+ (signal, trans_ptr_p);
+ else
+ execute(signal, trans_ptr_p->m_callback, 0);
+ return;
+ }
+ case DictObjOp::Defined:
+ case DictObjOp::Prepared:
+ case DictObjOp::Committed:
+ case DictObjOp::Aborted:
+ break;
+ }
+ ndbrequire(false);
}
-int
-Dbdict::getMetaTable(MetaData::Table& table, const char* tableName)
+void
+Dbdict::trans_commit_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 retValue){
+ jamEntry();
+
+ ndbrequire(retValue == 0);
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, callbackData));
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ tmp.init<DictCommitRef>(rg, GSN_DICT_COMMIT_REF, trans_ptr.p->key);
+
+ DictCommitReq * const req = (DictCommitReq*)signal->getDataPtrSend();
+ req->senderRef = reference();
+ req->senderData = trans_ptr.p->key;
+ req->op_key = trans_ptr.p->m_op.m_key;
+ sendSignal(rg, GSN_DICT_COMMIT_REQ, signal, DictCommitReq::SignalLength,
+ JBB);
+
+ trans_ptr.p->m_op.m_state = DictObjOp::Committing;
+}
+
+void
+Dbdict::trans_commit_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 retValue){
+ jamEntry();
+
+ ndbrequire(retValue == 0);
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, callbackData));
+
+ switch(f_dict_op[trans_ptr.p->m_op.m_vt_index].m_gsn_user_req){
+ case GSN_CREATE_FILEGROUP_REQ:{
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, trans_ptr.p->m_op.m_obj_id));
+
+ //
+ CreateFilegroupConf * conf = (CreateFilegroupConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = trans_ptr.p->m_senderData;
+ conf->filegroupId = fg_ptr.p->key;
+ conf->filegroupVersion = fg_ptr.p->m_version;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILEGROUP_CONF, signal,
+ CreateFilegroupConf::SignalLength, JBB);
+ break;
+ }
+ case GSN_CREATE_FILE_REQ:{
+ FilePtr f_ptr;
+ ndbrequire(c_file_hash.find(f_ptr, trans_ptr.p->m_op.m_obj_id));
+ CreateFileConf * conf = (CreateFileConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = trans_ptr.p->m_senderData;
+ conf->fileId = f_ptr.p->key;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILE_CONF, signal,
+ CreateFileConf::SignalLength, JBB);
+
+ break;
+ }
+ case GSN_DROP_FILE_REQ:{
+ DropFileConf * conf = (DropFileConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = trans_ptr.p->m_senderData;
+ conf->fileId = trans_ptr.p->m_op.m_obj_id;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_DROP_FILE_CONF, signal,
+ DropFileConf::SignalLength, JBB);
+ break;
+ }
+ case GSN_DROP_FILEGROUP_REQ:{
+ DropFilegroupConf * conf = (DropFilegroupConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = trans_ptr.p->m_senderData;
+ conf->filegroupId = trans_ptr.p->m_op.m_obj_id;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_DROP_FILEGROUP_CONF, signal,
+ DropFilegroupConf::SignalLength, JBB);
+ break;
+ }
+ default:
+ ndbrequire(false);
+ }
+
+ c_Trans.release(trans_ptr);
+ c_blockState = BS_IDLE;
+ return;
+}
+
+void
+Dbdict::trans_abort_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 retValue){
+ jamEntry();
+
+ ndbrequire(retValue == 0);
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, callbackData));
+
+ NodeReceiverGroup rg(DBDICT, trans_ptr.p->m_nodes);
+ SafeCounter tmp(c_counterMgr, trans_ptr.p->m_counter);
+ ndbrequire(tmp.init<DictAbortRef>(rg, trans_ptr.p->key));
+
+ DictAbortReq * const req = (DictAbortReq*)signal->getDataPtrSend();
+ req->senderRef = reference();
+ req->senderData = trans_ptr.p->key;
+ req->op_key = trans_ptr.p->m_op.m_key;
+
+ sendSignal(rg, GSN_DICT_ABORT_REQ, signal, DictAbortReq::SignalLength, JBB);
+}
+
+void
+Dbdict::trans_abort_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 retValue){
+ jamEntry();
+
+ ndbrequire(retValue == 0);
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, callbackData));
+
+ switch(f_dict_op[trans_ptr.p->m_op.m_vt_index].m_gsn_user_req){
+ case GSN_CREATE_FILEGROUP_REQ:
+ {
+ //
+ CreateFilegroupRef * ref = (CreateFilegroupRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = trans_ptr.p->m_senderData;
+ ref->masterNodeId = c_masterNodeId;
+ ref->errorCode = trans_ptr.p->m_errorCode;
+ ref->errorLine = 0;
+ ref->errorKey = 0;
+ ref->status = 0;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILEGROUP_REF, signal,
+ CreateFilegroupRef::SignalLength, JBB);
+
+ break;
+ }
+ case GSN_CREATE_FILE_REQ:
+ {
+ CreateFileRef * ref = (CreateFileRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = trans_ptr.p->m_senderData;
+ ref->masterNodeId = c_masterNodeId;
+ ref->errorCode = trans_ptr.p->m_errorCode;
+ ref->errorLine = 0;
+ ref->errorKey = 0;
+ ref->status = 0;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_CREATE_FILE_REF, signal,
+ CreateFileRef::SignalLength, JBB);
+
+ break;
+ }
+ case GSN_DROP_FILE_REQ:
+ {
+ DropFileRef * ref = (DropFileRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = trans_ptr.p->m_senderData;
+ ref->masterNodeId = c_masterNodeId;
+ ref->errorCode = trans_ptr.p->m_errorCode;
+ ref->errorLine = 0;
+ ref->errorKey = 0;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_DROP_FILE_REF, signal,
+ DropFileRef::SignalLength, JBB);
+
+ break;
+ }
+ case GSN_DROP_FILEGROUP_REQ:
+ {
+ //
+ DropFilegroupRef * ref = (DropFilegroupRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = trans_ptr.p->m_senderData;
+ ref->masterNodeId = c_masterNodeId;
+ ref->errorCode = trans_ptr.p->m_errorCode;
+ ref->errorLine = 0;
+ ref->errorKey = 0;
+
+ //@todo check api failed
+ sendSignal(trans_ptr.p->m_senderRef, GSN_DROP_FILEGROUP_REF, signal,
+ DropFilegroupRef::SignalLength, JBB);
+
+ break;
+ }
+ default:
+ ndbrequire(false);
+ }
+
+ c_Trans.release(trans_ptr);
+ c_blockState = BS_IDLE;
+ return;
+}
+
+void
+Dbdict::execCREATE_OBJ_REQ(Signal* signal){
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
+ }
+
+ CreateObjReq * const req = (CreateObjReq*)signal->getDataPtr();
+ const Uint32 gci = req->gci;
+ const Uint32 objId = req->objId;
+ const Uint32 objVersion = req->objVersion;
+ const Uint32 objType = req->objType;
+ const Uint32 requestInfo = req->requestInfo;
+
+ SegmentedSectionPtr objInfoPtr;
+ signal->getSection(objInfoPtr, CreateObjReq::DICT_OBJ_INFO);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.seize(createObjPtr));
+
+ const Uint32 key = req->op_key;
+ createObjPtr.p->key = key;
+ c_opCreateObj.add(createObjPtr);
+ createObjPtr.p->m_errorCode = 0;
+ createObjPtr.p->m_senderRef = req->senderRef;
+ createObjPtr.p->m_senderData = req->senderData;
+ createObjPtr.p->m_clientRef = req->clientRef;
+ createObjPtr.p->m_clientData = req->clientData;
+
+ createObjPtr.p->m_gci = gci;
+ createObjPtr.p->m_obj_id = objId;
+ createObjPtr.p->m_obj_type = objType;
+ createObjPtr.p->m_obj_version = objVersion;
+ createObjPtr.p->m_obj_info_ptr_i = objInfoPtr.i;
+
+ createObjPtr.p->m_callback.m_callbackData = key;
+ createObjPtr.p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::createObj_prepare_start_done);
+
+ createObjPtr.p->m_restart= 0;
+ switch(objType){
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:
+ createObjPtr.p->m_vt_index = 0;
+ break;
+ case DictTabInfo::Datafile:
+ case DictTabInfo::Undofile:
+ /**
+ * Use restart code to impl. ForceCreateFile
+ */
+ if (requestInfo & CreateFileReq::ForceCreateFile)
+ createObjPtr.p->m_restart= 2;
+ createObjPtr.p->m_vt_index = 1;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ signal->header.m_noOfSections = 0;
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_prepare_start)
+ (signal, createObjPtr.p);
+}
+
+void
+Dbdict::execDICT_COMMIT_REQ(Signal* signal)
{
- int ret;
- TableRecordPtr tablePtr;
- if (strlen(tableName) + 1 > MAX_TAB_NAME_SIZE) {
- return MetaData::InvalidArgument;
+ DictCommitReq* req = (DictCommitReq*)signal->getDataPtr();
+
+ Ptr<SchemaOp> op;
+ ndbrequire(c_schemaOp.find(op, req->op_key));
+
+ (this->*f_dict_op[op.p->m_vt_index].m_commit)(signal, op.p);
+}
+
+void
+Dbdict::execDICT_ABORT_REQ(Signal* signal)
+{
+ DictAbortReq* req = (DictAbortReq*)signal->getDataPtr();
+
+ Ptr<SchemaOp> op;
+ ndbrequire(c_schemaOp.find(op, req->op_key));
+
+ (this->*f_dict_op[op.p->m_vt_index].m_abort)(signal, op.p);
+}
+
+void
+Dbdict::execDICT_COMMIT_REF(Signal* signal){
+ jamEntry();
+
+ DictCommitRef * const ref = (DictCommitRef*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, ref->senderData));
+
+ if(ref->errorCode != DictCommitRef::NF_FakeErrorREF){
+ trans_ptr.p->setErrorCode(ref->errorCode);
}
- TableRecord keyRecord;
- strcpy(keyRecord.tableName, tableName);
- c_tableRecordHash.find(tablePtr, keyRecord);
- if (tablePtr.i == RNIL) {
- return MetaData::TableNotFound;
+ Uint32 node = refToNode(ref->senderRef);
+ schemaOp_reply(signal, trans_ptr.p, node);
+}
+
+void
+Dbdict::execDICT_COMMIT_CONF(Signal* signal){
+ jamEntry();
+
+ DictCommitConf * const conf = (DictCommitConf*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, conf->senderData));
+ schemaOp_reply(signal, trans_ptr.p, refToNode(conf->senderRef));
+}
+
+void
+Dbdict::execDICT_ABORT_REF(Signal* signal){
+ jamEntry();
+
+ DictAbortRef * const ref = (DictAbortRef*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, ref->senderData));
+
+ if(ref->errorCode != DictAbortRef::NF_FakeErrorREF){
+ trans_ptr.p->setErrorCode(ref->errorCode);
}
- if ((ret = getMetaTablePtr(tablePtr, tablePtr.i, tablePtr.p->tableVersion)) < 0) {
- return ret;
+ Uint32 node = refToNode(ref->senderRef);
+ schemaOp_reply(signal, trans_ptr.p, node);
+}
+
+void
+Dbdict::execDICT_ABORT_CONF(Signal* signal){
+ jamEntry();
+
+ DictAbortConf * const conf = (DictAbortConf*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, conf->senderData));
+ schemaOp_reply(signal, trans_ptr.p, refToNode(conf->senderRef));
+}
+
+
+
+void
+Dbdict::createObj_prepare_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+
+ ndbrequire(returnCode == 0);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, createObjPtr.p->m_obj_info_ptr_i);
+
+ if(createObjPtr.p->m_errorCode != 0){
+ jam();
+ createObjPtr.p->m_obj_info_ptr_i= RNIL;
+ signal->setSection(objInfoPtr, 0);
+ releaseSections(signal);
+ createObj_prepare_complete_done(signal, callbackData, 0);
+ return;
}
- new (&table) MetaData::Table(*tablePtr.p);
- return 0;
+
+ SchemaFile::TableEntry tabEntry;
+ bzero(&tabEntry, sizeof(tabEntry));
+ tabEntry.m_tableVersion = createObjPtr.p->m_obj_version;
+ tabEntry.m_tableType = createObjPtr.p->m_obj_type;
+ tabEntry.m_tableState = SchemaFile::ADD_STARTED;
+ tabEntry.m_gcp = createObjPtr.p->m_gci;
+ tabEntry.m_info_words = objInfoPtr.sz;
+
+ Callback cb;
+ cb.m_callbackData = createObjPtr.p->key;
+ cb.m_callbackFunction = safe_cast(&Dbdict::createObj_writeSchemaConf1);
+
+ updateSchemaState(signal, createObjPtr.p->m_obj_id, &tabEntry, &cb);
}
-int
-Dbdict::getMetaAttribute(MetaData::Attribute& attr, const MetaData::Table& table, Uint32 attributeId)
+void
+Dbdict::createObj_writeSchemaConf1(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ ndbrequire(returnCode == 0);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ Callback callback;
+ callback.m_callbackData = createObjPtr.p->key;
+ callback.m_callbackFunction = safe_cast(&Dbdict::createObj_writeObjConf);
+
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, createObjPtr.p->m_obj_info_ptr_i);
+ writeTableFile(signal, createObjPtr.p->m_obj_id, objInfoPtr, &callback);
+
+ signal->setSection(objInfoPtr, 0);
+ releaseSections(signal);
+ createObjPtr.p->m_obj_info_ptr_i = RNIL;
+}
+
+void
+Dbdict::createObj_writeObjConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ ndbrequire(returnCode == 0);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_prepare_complete_done);
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_prepare_complete)
+ (signal, createObjPtr.p);
+}
+
+void
+Dbdict::createObj_prepare_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ ndbrequire(returnCode == 0);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ //@todo check for master failed
+
+ if(createObjPtr.p->m_errorCode == 0){
+ jam();
+
+ CreateObjConf * const conf = (CreateObjConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = createObjPtr.p->m_senderData;
+ sendSignal(createObjPtr.p->m_senderRef, GSN_CREATE_OBJ_CONF,
+ signal, CreateObjConf::SignalLength, JBB);
+ return;
+ }
+
+ CreateObjRef * const ref = (CreateObjRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = createObjPtr.p->m_senderData;
+ ref->errorCode = createObjPtr.p->m_errorCode;
+ ref->errorLine = 0;
+ ref->errorKey = 0;
+ ref->errorStatus = 0;
+
+ sendSignal(createObjPtr.p->m_senderRef, GSN_CREATE_OBJ_REF,
+ signal, CreateObjRef::SignalLength, JBB);
+}
+
+void
+Dbdict::createObj_commit(Signal * signal, SchemaOp * op){
+ jam();
+
+ OpCreateObj * createObj = (OpCreateObj*)op;
+ createObj->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_commit_start_done);
+ if (f_dict_op[createObj->m_vt_index].m_commit_start)
+ (this->*f_dict_op[createObj->m_vt_index].m_commit_start)(signal, createObj);
+ else
+ execute(signal, createObj->m_callback, 0);
+}
+
+void
+Dbdict::createObj_commit_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+
+ jam();
+
+ ndbrequire(returnCode == 0);
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ Uint32 objId = createObjPtr.p->m_obj_id;
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = * getTableEntry(xsf, objId);
+ objEntry.m_tableState = SchemaFile::TABLE_ADD_COMMITTED;
+
+ Callback callback;
+ callback.m_callbackData = createObjPtr.p->key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_writeSchemaConf2);
+
+ updateSchemaState(signal, createObjPtr.p->m_obj_id, &objEntry, &callback);
+
+}
+
+void
+Dbdict::createObj_writeSchemaConf2(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_commit_complete_done);
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_commit_complete)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_commit_complete)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+
+}
+
+void
+Dbdict::createObj_commit_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ //@todo check error
+ //@todo check master failed
+
+ DictCommitConf * const conf = (DictCommitConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = createObjPtr.p->m_senderData;
+ sendSignal(createObjPtr.p->m_senderRef, GSN_DICT_COMMIT_CONF,
+ signal, DictCommitConf::SignalLength, JBB);
+
+ c_opCreateObj.release(createObjPtr);
+}
+
+void
+Dbdict::createObj_abort(Signal* signal, SchemaOp* op)
{
- int ret;
- TableRecordPtr tablePtr;
- if ((ret = getMetaTablePtr(tablePtr, table.tableId, table.tableVersion)) < 0) {
- return ret;
+ jam();
+
+ OpCreateObj * createObj = (OpCreateObj*)op;
+
+ createObj->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_abort_start_done);
+ if (f_dict_op[createObj->m_vt_index].m_abort_start)
+ (this->*f_dict_op[createObj->m_vt_index].m_abort_start)(signal, createObj);
+ else
+ execute(signal, createObj->m_callback, 0);
+}
+
+void
+Dbdict::createObj_abort_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode){
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = * getTableEntry(xsf,
+ createObjPtr.p->m_obj_id);
+ objEntry.m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
+
+ Callback callback;
+ callback.m_callbackData = createObjPtr.p->key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_abort_writeSchemaConf);
+
+ updateSchemaState(signal, createObjPtr.p->m_obj_id, &objEntry, &callback);
+}
+
+void
+Dbdict::createObj_abort_writeSchemaConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ createObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::createObj_abort_complete_done);
+
+ if (f_dict_op[createObjPtr.p->m_vt_index].m_abort_complete)
+ (this->*f_dict_op[createObjPtr.p->m_vt_index].m_abort_complete)
+ (signal, createObjPtr.p);
+ else
+ execute(signal, createObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::createObj_abort_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+
+ CreateObjRecordPtr createObjPtr;
+ ndbrequire(c_opCreateObj.find(createObjPtr, callbackData));
+
+ DictAbortConf * const conf = (DictAbortConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = createObjPtr.p->m_senderData;
+ sendSignal(createObjPtr.p->m_senderRef, GSN_DICT_ABORT_CONF,
+ signal, DictAbortConf::SignalLength, JBB);
+
+ c_opCreateObj.release(createObjPtr);
+}
+
+void
+Dbdict::execDROP_OBJ_REQ(Signal* signal){
+ jamEntry();
+
+ if(!assembleFragments(signal)){
+ jam();
+ return;
}
- AttributeRecordPtr attrPtr;
- attrPtr.i = tablePtr.p->firstAttribute;
- while (attrPtr.i != RNIL) {
- c_attributeRecordPool.getPtr(attrPtr);
- if (attrPtr.p->attributeId == attributeId)
- break;
- attrPtr.i = attrPtr.p->nextAttrInTable;
+
+ DropObjReq * const req = (DropObjReq*)signal->getDataPtr();
+
+ const Uint32 objId = req->objId;
+ const Uint32 objVersion = req->objVersion;
+ const Uint32 objType = req->objType;
+ const Uint32 requestInfo = req->requestInfo;
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.seize(dropObjPtr));
+
+ const Uint32 key = req->op_key;
+ dropObjPtr.p->key = key;
+ c_opDropObj.add(dropObjPtr);
+ dropObjPtr.p->m_errorCode = 0;
+ dropObjPtr.p->m_senderRef = req->senderRef;
+ dropObjPtr.p->m_senderData = req->senderData;
+ dropObjPtr.p->m_clientRef = req->clientRef;
+ dropObjPtr.p->m_clientData = req->clientData;
+
+ dropObjPtr.p->m_obj_id = objId;
+ dropObjPtr.p->m_obj_type = objType;
+ dropObjPtr.p->m_obj_version = objVersion;
+
+ dropObjPtr.p->m_callback.m_callbackData = key;
+ dropObjPtr.p->m_callback.m_callbackFunction=
+ safe_cast(&Dbdict::dropObj_prepare_start_done);
+
+ switch(objType){
+ case DictTabInfo::Tablespace:
+ case DictTabInfo::LogfileGroup:
+ {
+ dropObjPtr.p->m_vt_index = 3;
+ Ptr<Filegroup> fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, objId));
+ dropObjPtr.p->m_obj_ptr_i = fg_ptr.i;
+ break;
+
}
- if (attrPtr.i == RNIL) {
- return MetaData::AttributeNotFound;
+ case DictTabInfo::Datafile:
+ {
+ dropObjPtr.p->m_vt_index = 2;
+ Ptr<File> file_ptr;
+ ndbrequire(c_file_hash.find(file_ptr, objId));
+ dropObjPtr.p->m_obj_ptr_i = file_ptr.i;
+ break;
}
- new (&attr) MetaData::Attribute(*attrPtr.p);
- return 0;
+ case DictTabInfo::Undofile:
+ dropObjPtr.p->m_vt_index = 4;
+ return;
+ default:
+ ndbrequire(false);
+ }
+
+ signal->header.m_noOfSections = 0;
+ (this->*f_dict_op[dropObjPtr.p->m_vt_index].m_prepare_start)
+ (signal, dropObjPtr.p);
}
-int
-Dbdict::getMetaAttribute(MetaData::Attribute& attr, const MetaData::Table& table, const char* attributeName)
+void
+Dbdict::dropObj_prepare_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
{
- int ret;
- TableRecordPtr tablePtr;
- if ((ret = getMetaTablePtr(tablePtr, table.tableId, table.tableVersion)) < 0) {
- return ret;
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ Callback cb;
+ cb.m_callbackData = callbackData;
+ cb.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_prepare_writeSchemaConf);
+
+ if(dropObjPtr.p->m_errorCode != 0)
+ {
+ jam();
+ dropObj_prepare_complete_done(signal, callbackData, 0);
+ return;
}
- AttributeRecordPtr attrPtr;
- attrPtr.i = tablePtr.p->firstAttribute;
- while (attrPtr.i != RNIL) {
- c_attributeRecordPool.getPtr(attrPtr);
- if (strcmp(attrPtr.p->attributeName, attributeName) == 0)
+
+ Uint32 objId = dropObjPtr.p->m_obj_id;
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = *getTableEntry(xsf, objId);
+ objEntry.m_tableState = SchemaFile::DROP_TABLE_STARTED;
+ updateSchemaState(signal, objId, &objEntry, &cb);
+}
+
+void
+Dbdict::dropObj_prepare_writeSchemaConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ dropObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_prepare_complete_done);
+
+ if(f_dict_op[dropObjPtr.p->m_vt_index].m_prepare_complete)
+ (this->*f_dict_op[dropObjPtr.p->m_vt_index].m_prepare_complete)
+ (signal, dropObjPtr.p);
+ else
+ execute(signal, dropObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::dropObj_prepare_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ //@todo check for master failed
+
+ if(dropObjPtr.p->m_errorCode == 0){
+ jam();
+
+ DropObjConf * const conf = (DropObjConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = dropObjPtr.p->m_senderData;
+ sendSignal(dropObjPtr.p->m_senderRef, GSN_DROP_OBJ_CONF,
+ signal, DropObjConf::SignalLength, JBB);
+ return;
+ }
+
+ DropObjRef * const ref = (DropObjRef*)signal->getDataPtr();
+ ref->senderRef = reference();
+ ref->senderData = dropObjPtr.p->m_senderData;
+ ref->errorCode = dropObjPtr.p->m_errorCode;
+
+ sendSignal(dropObjPtr.p->m_senderRef, GSN_DROP_OBJ_REF,
+ signal, DropObjRef::SignalLength, JBB);
+
+}
+
+void
+Dbdict::dropObj_commit(Signal * signal, SchemaOp * op){
+ jam();
+
+ OpDropObj * dropObj = (OpDropObj*)op;
+ dropObj->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_commit_start_done);
+ if (f_dict_op[dropObj->m_vt_index].m_commit_start)
+ (this->*f_dict_op[dropObj->m_vt_index].m_commit_start)(signal, dropObj);
+ else
+ execute(signal, dropObj->m_callback, 0);
+}
+
+void
+Dbdict::dropObj_commit_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ Uint32 objId = dropObjPtr.p->m_obj_id;
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = * getTableEntry(xsf, objId);
+ objEntry.m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
+
+ Callback callback;
+ callback.m_callbackData = dropObjPtr.p->key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_commit_writeSchemaConf);
+
+ updateSchemaState(signal, objId, &objEntry, &callback);
+}
+
+void
+Dbdict::dropObj_commit_writeSchemaConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ dropObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_commit_complete_done);
+
+ if(f_dict_op[dropObjPtr.p->m_vt_index].m_commit_complete)
+ (this->*f_dict_op[dropObjPtr.p->m_vt_index].m_commit_complete)
+ (signal, dropObjPtr.p);
+ else
+ execute(signal, dropObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::dropObj_commit_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ //@todo check error
+ //@todo check master failed
+
+ DictCommitConf * const conf = (DictCommitConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = dropObjPtr.p->m_senderData;
+ sendSignal(dropObjPtr.p->m_senderRef, GSN_DICT_COMMIT_CONF,
+ signal, DictCommitConf::SignalLength, JBB);
+
+ c_opDropObj.release(dropObjPtr);
+}
+
+void
+Dbdict::dropObj_abort(Signal * signal, SchemaOp * op){
+ jam();
+
+ OpDropObj * dropObj = (OpDropObj*)op;
+ dropObj->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_abort_start_done);
+
+ if (f_dict_op[dropObj->m_vt_index].m_abort_start)
+ (this->*f_dict_op[dropObj->m_vt_index].m_abort_start)(signal, dropObj);
+ else
+ execute(signal, dropObj->m_callback, 0);
+}
+
+void
+Dbdict::dropObj_abort_start_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ SchemaFile::TableEntry objEntry = * getTableEntry(xsf,
+ dropObjPtr.p->m_obj_id);
+
+ Callback callback;
+ callback.m_callbackData = dropObjPtr.p->key;
+ callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_abort_writeSchemaConf);
+
+ if (objEntry.m_tableState == SchemaFile::DROP_TABLE_STARTED)
+ {
+ jam();
+ objEntry.m_tableState = SchemaFile::TABLE_ADD_COMMITTED;
+
+ updateSchemaState(signal, dropObjPtr.p->m_obj_id, &objEntry, &callback);
+ }
+ else
+ {
+ execute(signal, callback, 0);
+ }
+}
+
+void
+Dbdict::dropObj_abort_writeSchemaConf(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ jam();
+ ndbrequire(returnCode == 0);
+
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ dropObjPtr.p->m_callback.m_callbackFunction =
+ safe_cast(&Dbdict::dropObj_abort_complete_done);
+
+ if(f_dict_op[dropObjPtr.p->m_vt_index].m_abort_complete)
+ (this->*f_dict_op[dropObjPtr.p->m_vt_index].m_abort_complete)
+ (signal, dropObjPtr.p);
+ else
+ execute(signal, dropObjPtr.p->m_callback, 0);
+}
+
+void
+Dbdict::dropObj_abort_complete_done(Signal* signal,
+ Uint32 callbackData,
+ Uint32 returnCode)
+{
+ DropObjRecordPtr dropObjPtr;
+ ndbrequire(c_opDropObj.find(dropObjPtr, callbackData));
+
+ DictAbortConf * const conf = (DictAbortConf*)signal->getDataPtr();
+ conf->senderRef = reference();
+ conf->senderData = dropObjPtr.p->m_senderData;
+ sendSignal(dropObjPtr.p->m_senderRef, GSN_DICT_ABORT_CONF,
+ signal, DictAbortConf::SignalLength, JBB);
+
+ c_opDropObj.release(dropObjPtr);
+}
+
+void
+Dbdict::create_fg_prepare_start(Signal* signal, SchemaOp* op){
+ /**
+ * Put data into table record
+ */
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, ((OpCreateObj*)op)->m_obj_info_ptr_i);
+ SimplePropertiesSectionReader it(objInfoPtr, getSectionSegmentPool());
+
+ SimpleProperties::UnpackStatus status;
+ DictFilegroupInfo::Filegroup fg; fg.init();
+ do {
+ status = SimpleProperties::unpack(it, &fg,
+ DictFilegroupInfo::Mapping,
+ DictFilegroupInfo::MappingSize,
+ true, true);
+
+ if(status != SimpleProperties::Eof)
+ {
+ op->m_errorCode = CreateTableRef::InvalidFormat;
+ break;
+ }
+
+ if(fg.FilegroupType == DictTabInfo::Tablespace)
+ {
+ if(!fg.TS_ExtentSize)
+ {
+ op->m_errorCode = CreateFilegroupRef::InvalidExtentSize;
+ break;
+ }
+ }
+ else if(fg.FilegroupType == DictTabInfo::LogfileGroup)
+ {
+ if(!fg.LF_UndoBufferSize)
+ {
+ op->m_errorCode = CreateFilegroupRef::InvalidUndoBufferSize;
+ break;
+ }
+ }
+
+ Uint32 len = strlen(fg.FilegroupName) + 1;
+ Uint32 hash = Rope::hash(fg.FilegroupName, len);
+ if(get_object(fg.FilegroupName, len, hash) != 0){
+ op->m_errorCode = CreateTableRef::TableAlreadyExist;
+ break;
+ }
+
+ Ptr<DictObject> obj_ptr;
+ if(!c_obj_pool.seize(obj_ptr)){
+ op->m_errorCode = CreateTableRef::NoMoreTableRecords;
+ break;
+ }
+
+ FilegroupPtr fg_ptr;
+ if(!c_filegroup_pool.seize(fg_ptr)){
+ c_obj_pool.release(obj_ptr);
+ op->m_errorCode = CreateTableRef::NoMoreTableRecords;
+ break;
+ }
+
+ {
+ Rope name(c_rope_pool, obj_ptr.p->m_name);
+ if(!name.assign(fg.FilegroupName, len, hash)){
+ op->m_errorCode = CreateTableRef::TableNameTooLong;
+ c_obj_pool.release(obj_ptr);
+ c_filegroup_pool.release(fg_ptr);
+ break;
+ }
+ }
+
+ fg_ptr.p->key = op->m_obj_id;
+ fg_ptr.p->m_obj_ptr_i = obj_ptr.i;
+ fg_ptr.p->m_type = fg.FilegroupType;
+ fg_ptr.p->m_version = op->m_obj_version;
+ fg_ptr.p->m_name = obj_ptr.p->m_name;
+
+ switch(fg.FilegroupType){
+ case DictTabInfo::Tablespace:
+ //fg.TS_DataGrow = group.m_grow_spec;
+ fg_ptr.p->m_tablespace.m_extent_size = fg.TS_ExtentSize;
+ fg_ptr.p->m_tablespace.m_default_logfile_group_id = fg.TS_LogfileGroupId;
+
+ Ptr<Filegroup> lg_ptr;
+ if (!c_filegroup_hash.find(lg_ptr, fg.TS_LogfileGroupId))
+ {
+ op->m_errorCode = CreateFilegroupRef::NoSuchLogfileGroup;
+ goto error;
+ }
+
+ if (lg_ptr.p->m_version != fg.TS_LogfileGroupVersion)
+ {
+ op->m_errorCode = CreateFilegroupRef::InvalidFilegroupVersion;
+ goto error;
+ }
+ increase_ref_count(lg_ptr.p->m_obj_ptr_i);
+ break;
+ case DictTabInfo::LogfileGroup:
+ fg_ptr.p->m_logfilegroup.m_undo_buffer_size = fg.LF_UndoBufferSize;
+ fg_ptr.p->m_logfilegroup.m_files.init();
+ //fg.LF_UndoGrow = ;
break;
- attrPtr.i = attrPtr.p->nextAttrInTable;
+ default:
+ ndbrequire(false);
+ }
+
+ obj_ptr.p->m_id = op->m_obj_id;
+ obj_ptr.p->m_type = fg.FilegroupType;
+ obj_ptr.p->m_ref_count = 0;
+ c_obj_hash.add(obj_ptr);
+ c_filegroup_hash.add(fg_ptr);
+
+ op->m_obj_ptr_i = fg_ptr.i;
+ } while(0);
+
+error:
+ execute(signal, op->m_callback, 0);
+}
+
+void
+Dbdict::create_fg_prepare_complete(Signal* signal, SchemaOp* op){
+ /**
+ * CONTACT TSMAN LGMAN PGMAN
+ */
+ CreateFilegroupImplReq* req =
+ (CreateFilegroupImplReq*)signal->getDataPtrSend();
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ req->filegroup_id = op->m_obj_id;
+ req->filegroup_version = op->m_obj_version;
+
+ FilegroupPtr fg_ptr;
+ c_filegroup_pool.getPtr(fg_ptr, op->m_obj_ptr_i);
+
+ Uint32 ref= 0;
+ Uint32 len= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Tablespace:
+ ref = TSMAN_REF;
+ len = CreateFilegroupImplReq::TablespaceLength;
+ req->tablespace.extent_size = fg_ptr.p->m_tablespace.m_extent_size;
+ req->tablespace.logfile_group_id =
+ fg_ptr.p->m_tablespace.m_default_logfile_group_id;
+ break;
+ case DictTabInfo::LogfileGroup:
+ ref = LGMAN_REF;
+ len = CreateFilegroupImplReq::LogfileGroupLength;
+ req->logfile_group.buffer_size =
+ fg_ptr.p->m_logfilegroup.m_undo_buffer_size;
+ break;
+ default:
+ ndbrequire(false);
}
- if (attrPtr.i == RNIL) {
- return MetaData::AttributeNotFound;
+
+ sendSignal(ref, GSN_CREATE_FILEGROUP_REQ, signal, len, JBB);
+}
+
+void
+Dbdict::execCREATE_FILEGROUP_REF(Signal* signal){
+ jamEntry();
+
+ CreateFilegroupImplRef * ref = (CreateFilegroupImplRef*)signal->getDataPtr();
+
+ CreateObjRecordPtr op_ptr;
+ ndbrequire(c_opCreateObj.find(op_ptr, ref->senderData));
+ op_ptr.p->m_errorCode = ref->errorCode;
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::execCREATE_FILEGROUP_CONF(Signal* signal){
+ jamEntry();
+
+ CreateFilegroupImplConf * rep =
+ (CreateFilegroupImplConf*)signal->getDataPtr();
+
+ CreateObjRecordPtr op_ptr;
+ ndbrequire(c_opCreateObj.find(op_ptr, rep->senderData));
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::create_fg_abort_start(Signal* signal, SchemaOp* op){
+ execute(signal, op->m_callback, 0);
+ abort();
+}
+
+void
+Dbdict::create_fg_abort_complete(Signal* signal, SchemaOp* op){
+ execute(signal, op->m_callback, 0);
+ abort();
+}
+
+void
+Dbdict::create_file_prepare_start(Signal* signal, SchemaOp* op){
+ /**
+ * Put data into table record
+ */
+ SegmentedSectionPtr objInfoPtr;
+ getSection(objInfoPtr, ((OpCreateObj*)op)->m_obj_info_ptr_i);
+ SimplePropertiesSectionReader it(objInfoPtr, getSectionSegmentPool());
+
+ DictFilegroupInfo::File f; f.init();
+ SimpleProperties::UnpackStatus status;
+ status = SimpleProperties::unpack(it, &f,
+ DictFilegroupInfo::FileMapping,
+ DictFilegroupInfo::FileMappingSize,
+ true, true);
+
+ do {
+ if(status != SimpleProperties::Eof){
+ op->m_errorCode = CreateFileRef::InvalidFormat;
+ break;
+ }
+
+ // Get Filegroup
+ FilegroupPtr fg_ptr;
+ if(!c_filegroup_hash.find(fg_ptr, f.FilegroupId)){
+ op->m_errorCode = CreateFileRef::NoSuchFilegroup;
+ break;
+ }
+
+ if(fg_ptr.p->m_version != f.FilegroupVersion){
+ op->m_errorCode = CreateFileRef::InvalidFilegroupVersion;
+ break;
+ }
+
+ switch(f.FileType){
+ case DictTabInfo::Datafile:
+ if(fg_ptr.p->m_type != DictTabInfo::Tablespace)
+ op->m_errorCode = CreateFileRef::InvalidFileType;
+ break;
+ case DictTabInfo::Undofile:
+ if(fg_ptr.p->m_type != DictTabInfo::LogfileGroup)
+ op->m_errorCode = CreateFileRef::InvalidFileType;
+ break;
+ default:
+ op->m_errorCode = CreateFileRef::InvalidFileType;
+ }
+
+ if(op->m_errorCode)
+ break;
+
+ Uint32 len = strlen(f.FileName) + 1;
+ Uint32 hash = Rope::hash(f.FileName, len);
+ if(get_object(f.FileName, len, hash) != 0){
+ op->m_errorCode = CreateFileRef::FilenameAlreadyExists;
+ break;
+ }
+
+ // Loop through all filenames...
+ Ptr<DictObject> obj_ptr;
+ if(!c_obj_pool.seize(obj_ptr)){
+ op->m_errorCode = CreateTableRef::NoMoreTableRecords;
+ break;
+ }
+
+ FilePtr filePtr;
+ if (! c_file_pool.seize(filePtr)){
+ op->m_errorCode = CreateFileRef::OutOfFileRecords;
+ c_obj_pool.release(obj_ptr);
+ break;
+ }
+
+ {
+ Rope name(c_rope_pool, obj_ptr.p->m_name);
+ if(!name.assign(f.FileName, len, hash)){
+ op->m_errorCode = CreateTableRef::TableNameTooLong;
+ c_obj_pool.release(obj_ptr);
+ c_file_pool.release(filePtr);
+ break;
+ }
+ }
+
+ switch(fg_ptr.p->m_type){
+ case DictTabInfo::Tablespace:
+ increase_ref_count(fg_ptr.p->m_obj_ptr_i);
+ break;
+ case DictTabInfo::LogfileGroup:
+ {
+ LocalDLList<File> list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
+ list.add(filePtr);
+ break;
+ }
+ default:
+ ndbrequire(false);
+ }
+
+ /**
+ * Init file
+ */
+ filePtr.p->key = op->m_obj_id;
+ filePtr.p->m_file_size = ((Uint64)f.FileSizeHi) << 32 | f.FileSizeLo;
+ filePtr.p->m_path = obj_ptr.p->m_name;
+ filePtr.p->m_obj_ptr_i = obj_ptr.i;
+ filePtr.p->m_filegroup_id = f.FilegroupId;
+ filePtr.p->m_type = f.FileType;
+
+ obj_ptr.p->m_id = op->m_obj_id;
+ obj_ptr.p->m_type = f.FileType;
+ obj_ptr.p->m_ref_count = 0;
+ c_obj_hash.add(obj_ptr);
+ c_file_hash.add(filePtr);
+
+ op->m_obj_ptr_i = filePtr.i;
+ } while(0);
+
+ execute(signal, op->m_callback, 0);
+}
+
+
+void
+Dbdict::create_file_prepare_complete(Signal* signal, SchemaOp* op){
+ /**
+ * CONTACT TSMAN LGMAN PGMAN
+ */
+ CreateFileImplReq* req = (CreateFileImplReq*)signal->getDataPtrSend();
+
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ switch(((OpCreateObj*)op)->m_restart){
+ case 0:
+ req->requestInfo = CreateFileImplReq::Create;
+ break;
+ case 1:
+ req->requestInfo = CreateFileImplReq::Open;
+ if(getNodeState().getNodeRestartInProgress())
+ req->requestInfo = CreateFileImplReq::CreateForce;
+ break;
+ case 2:
+ req->requestInfo = CreateFileImplReq::CreateForce;
+ break;
+ }
+
+ req->file_id = f_ptr.p->key;
+ req->filegroup_id = f_ptr.p->m_filegroup_id;
+ req->filegroup_version = fg_ptr.p->m_version;
+ req->file_size_hi = f_ptr.p->m_file_size >> 32;
+ req->file_size_lo = f_ptr.p->m_file_size & 0xFFFFFFFF;
+
+ Uint32 ref= 0;
+ Uint32 len= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Datafile:
+ ref = TSMAN_REF;
+ len = CreateFileImplReq::DatafileLength;
+ req->tablespace.extent_size = fg_ptr.p->m_tablespace.m_extent_size;
+ break;
+ case DictTabInfo::Undofile:
+ ref = LGMAN_REF;
+ len = CreateFileImplReq::UndofileLength;
+ break;
+ default:
+ ndbrequire(false);
}
- new (&attr) MetaData::Attribute(*attrPtr.p);
- return 0;
+
+ char name[MAX_TAB_NAME_SIZE];
+ ConstRope tmp(c_rope_pool, f_ptr.p->m_path);
+ tmp.copy(name);
+ LinearSectionPtr ptr[3];
+ ptr[0].p = (Uint32*)&name[0];
+ ptr[0].sz = (strlen(name)+1+3)/4;
+ sendSignal(ref, GSN_CREATE_FILE_REQ, signal, len, JBB, ptr, 1);
+}
+
+void
+Dbdict::execCREATE_FILE_REF(Signal* signal){
+ jamEntry();
+
+ CreateFileImplRef * ref = (CreateFileImplRef*)signal->getDataPtr();
+
+ CreateObjRecordPtr op_ptr;
+ ndbrequire(c_opCreateObj.find(op_ptr, ref->senderData));
+ op_ptr.p->m_errorCode = ref->errorCode;
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::execCREATE_FILE_CONF(Signal* signal){
+ jamEntry();
+
+ CreateFileImplConf * rep =
+ (CreateFileImplConf*)signal->getDataPtr();
+
+ CreateObjRecordPtr op_ptr;
+ ndbrequire(c_opCreateObj.find(op_ptr, rep->senderData));
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::create_file_commit_start(Signal* signal, SchemaOp* op){
+ /**
+ * CONTACT TSMAN LGMAN PGMAN
+ */
+ CreateFileImplReq* req = (CreateFileImplReq*)signal->getDataPtrSend();
+
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ req->requestInfo = CreateFileImplReq::Commit;
+
+ req->file_id = f_ptr.p->key;
+ req->filegroup_id = f_ptr.p->m_filegroup_id;
+ req->filegroup_version = fg_ptr.p->m_version;
+
+ Uint32 ref= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Datafile:
+ ref = TSMAN_REF;
+ break;
+ case DictTabInfo::Undofile:
+ ref = LGMAN_REF;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ sendSignal(ref, GSN_CREATE_FILE_REQ, signal,
+ CreateFileImplReq::CommitLength, JBB);
+}
+
+void
+Dbdict::create_file_abort_start(Signal* signal, SchemaOp* op)
+{
+ CreateFileImplReq* req = (CreateFileImplReq*)signal->getDataPtrSend();
+
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ req->requestInfo = CreateFileImplReq::Abort;
+
+ req->file_id = f_ptr.p->key;
+ req->filegroup_id = f_ptr.p->m_filegroup_id;
+ req->filegroup_version = fg_ptr.p->m_version;
+
+ Uint32 ref= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Datafile:
+ ref = TSMAN_REF;
+ break;
+ case DictTabInfo::Undofile:
+ ref = LGMAN_REF;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ sendSignal(ref, GSN_CREATE_FILE_REQ, signal,
+ CreateFileImplReq::AbortLength, JBB);
+}
+
+void
+Dbdict::create_file_abort_complete(Signal* signal, SchemaOp* op)
+{
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ switch(fg_ptr.p->m_type){
+ case DictTabInfo::Tablespace:
+ decrease_ref_count(fg_ptr.p->m_obj_ptr_i);
+ break;
+ case DictTabInfo::LogfileGroup:
+ {
+ LocalDLList<File> list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
+ list.remove(f_ptr);
+ break;
+ }
+ default:
+ ndbrequire(false);
+ }
+
+ release_object(f_ptr.p->m_obj_ptr_i);
+
+ execute(signal, op->m_callback, 0);
}
CArray<KeyDescriptor> g_key_descriptor_pool;
+
+void
+Dbdict::drop_file_prepare_start(Signal* signal, SchemaOp* op)
+{
+ send_drop_file(signal, op, DropFileImplReq::Prepare);
+}
+
+void
+Dbdict::drop_undofile_prepare_start(Signal* signal, SchemaOp* op)
+{
+ op->m_errorCode = DropFileRef::DropUndoFileNotSupported;
+ execute(signal, op->m_callback, 0);
+}
+
+void
+Dbdict::drop_file_commit_start(Signal* signal, SchemaOp* op)
+{
+ send_drop_file(signal, op, DropFileImplReq::Commit);
+}
+
+void
+Dbdict::drop_file_commit_complete(Signal* signal, SchemaOp* op)
+{
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ decrease_ref_count(fg_ptr.p->m_obj_ptr_i);
+ release_object(f_ptr.p->m_obj_ptr_i);
+
+ execute(signal, op->m_callback, 0);
+}
+
+void
+Dbdict::drop_file_abort_start(Signal* signal, SchemaOp* op)
+{
+ send_drop_file(signal, op, DropFileImplReq::Abort);
+}
+
+void
+Dbdict::send_drop_file(Signal* signal, SchemaOp* op,
+ DropFileImplReq::RequestInfo type)
+{
+ DropFileImplReq* req = (DropFileImplReq*)signal->getDataPtrSend();
+
+ FilePtr f_ptr;
+ c_file_pool.getPtr(f_ptr, op->m_obj_ptr_i);
+
+ FilegroupPtr fg_ptr;
+ ndbrequire(c_filegroup_hash.find(fg_ptr, f_ptr.p->m_filegroup_id));
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ req->requestInfo = type;
+
+ req->file_id = f_ptr.p->key;
+ req->filegroup_id = f_ptr.p->m_filegroup_id;
+ req->filegroup_version = fg_ptr.p->m_version;
+
+ Uint32 ref= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Datafile:
+ ref = TSMAN_REF;
+ break;
+ case DictTabInfo::Undofile:
+ ref = LGMAN_REF;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ sendSignal(ref, GSN_DROP_FILE_REQ, signal,
+ DropFileImplReq::SignalLength, JBB);
+}
+
+void
+Dbdict::execDROP_OBJ_REF(Signal* signal){
+ jamEntry();
+
+ DropObjRef * const ref = (DropObjRef*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, ref->senderData));
+
+ if(ref->errorCode != DropObjRef::NF_FakeErrorREF){
+ trans_ptr.p->setErrorCode(ref->errorCode);
+ }
+ Uint32 node = refToNode(ref->senderRef);
+ schemaOp_reply(signal, trans_ptr.p, node);
+}
+
+void
+Dbdict::execDROP_OBJ_CONF(Signal* signal){
+ jamEntry();
+
+ DropObjConf * const conf = (DropObjConf*)signal->getDataPtr();
+
+ Ptr<SchemaTransaction> trans_ptr;
+ ndbrequire(c_Trans.find(trans_ptr, conf->senderData));
+ schemaOp_reply(signal, trans_ptr.p, refToNode(conf->senderRef));
+}
+
+void
+Dbdict::execDROP_FILE_REF(Signal* signal){
+ jamEntry();
+
+ DropFileImplRef * ref = (DropFileImplRef*)signal->getDataPtr();
+
+ DropObjRecordPtr op_ptr;
+ ndbrequire(c_opDropObj.find(op_ptr, ref->senderData));
+ op_ptr.p->m_errorCode = ref->errorCode;
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::execDROP_FILE_CONF(Signal* signal){
+ jamEntry();
+
+ DropFileImplConf * rep =
+ (DropFileImplConf*)signal->getDataPtr();
+
+ DropObjRecordPtr op_ptr;
+ ndbrequire(c_opDropObj.find(op_ptr, rep->senderData));
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::execDROP_FILEGROUP_REF(Signal* signal){
+ jamEntry();
+
+ DropFilegroupImplRef * ref = (DropFilegroupImplRef*)signal->getDataPtr();
+
+ DropObjRecordPtr op_ptr;
+ ndbrequire(c_opDropObj.find(op_ptr, ref->senderData));
+ op_ptr.p->m_errorCode = ref->errorCode;
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::execDROP_FILEGROUP_CONF(Signal* signal){
+ jamEntry();
+
+ DropFilegroupImplConf * rep =
+ (DropFilegroupImplConf*)signal->getDataPtr();
+
+ DropObjRecordPtr op_ptr;
+ ndbrequire(c_opDropObj.find(op_ptr, rep->senderData));
+
+ execute(signal, op_ptr.p->m_callback, 0);
+}
+
+void
+Dbdict::drop_fg_prepare_start(Signal* signal, SchemaOp* op)
+{
+ FilegroupPtr fg_ptr;
+ c_filegroup_pool.getPtr(fg_ptr, op->m_obj_ptr_i);
+
+ DictObject * obj = c_obj_pool.getPtr(fg_ptr.p->m_obj_ptr_i);
+ if (obj->m_ref_count)
+ {
+ op->m_errorCode = DropFilegroupRef::FilegroupInUse;
+ execute(signal, op->m_callback, 0);
+ }
+ else
+ {
+ send_drop_fg(signal, op, DropFilegroupImplReq::Prepare);
+ }
+}
+
+void
+Dbdict::drop_fg_commit_start(Signal* signal, SchemaOp* op)
+{
+ FilegroupPtr fg_ptr;
+ c_filegroup_pool.getPtr(fg_ptr, op->m_obj_ptr_i);
+ if (op->m_obj_type == DictTabInfo::LogfileGroup)
+ {
+
+ /**
+ * Mark all undofiles as dropped
+ */
+ Ptr<File> filePtr;
+ LocalDLList<File> list(c_file_pool, fg_ptr.p->m_logfilegroup.m_files);
+ XSchemaFile * xsf = &c_schemaFile[c_schemaRecord.schemaPage != 0];
+ for(list.first(filePtr); !filePtr.isNull(); list.next(filePtr))
+ {
+ Uint32 objId = filePtr.p->key;
+ SchemaFile::TableEntry * tableEntry = getTableEntry(xsf, objId);
+ tableEntry->m_tableState = SchemaFile::DROP_TABLE_COMMITTED;
+ computeChecksum(xsf, objId / NDB_SF_PAGE_ENTRIES);
+ release_object(filePtr.p->m_obj_ptr_i);
+ }
+ list.release();
+ }
+ else if(op->m_obj_type == DictTabInfo::Tablespace)
+ {
+ FilegroupPtr lg_ptr;
+ ndbrequire(c_filegroup_hash.
+ find(lg_ptr,
+ fg_ptr.p->m_tablespace.m_default_logfile_group_id));
+
+ decrease_ref_count(lg_ptr.p->m_obj_ptr_i);
+ }
+
+ send_drop_fg(signal, op, DropFilegroupImplReq::Commit);
+}
+
+void
+Dbdict::drop_fg_commit_complete(Signal* signal, SchemaOp* op)
+{
+ FilegroupPtr fg_ptr;
+ c_filegroup_pool.getPtr(fg_ptr, op->m_obj_ptr_i);
+
+ release_object(fg_ptr.p->m_obj_ptr_i);
+
+ execute(signal, op->m_callback, 0);
+}
+
+void
+Dbdict::drop_fg_abort_start(Signal* signal, SchemaOp* op)
+{
+ send_drop_fg(signal, op, DropFilegroupImplReq::Abort);
+}
+
+void
+Dbdict::send_drop_fg(Signal* signal, SchemaOp* op,
+ DropFilegroupImplReq::RequestInfo type)
+{
+ DropFilegroupImplReq* req = (DropFilegroupImplReq*)signal->getDataPtrSend();
+
+ FilegroupPtr fg_ptr;
+ c_filegroup_pool.getPtr(fg_ptr, op->m_obj_ptr_i);
+
+ req->senderData = op->key;
+ req->senderRef = reference();
+ req->requestInfo = type;
+
+ req->filegroup_id = fg_ptr.p->key;
+ req->filegroup_version = fg_ptr.p->m_version;
+
+ Uint32 ref= 0;
+ switch(op->m_obj_type){
+ case DictTabInfo::Tablespace:
+ ref = TSMAN_REF;
+ break;
+ case DictTabInfo::LogfileGroup:
+ ref = LGMAN_REF;
+ break;
+ default:
+ ndbrequire(false);
+ }
+
+ sendSignal(ref, GSN_DROP_FILEGROUP_REQ, signal,
+ DropFilegroupImplReq::SignalLength, JBB);
+}
+
--- 1.21/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2005-11-07 11:57:34 +01:00
+++ 1.22/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp 2005-11-09 10:17:31 +01:00
@@ -20,14 +20,16 @@
/**
* Dict : Dictionary Block
*/
-
#include <ndb_limits.h>
#include <trigger_definitions.h>
#include <pc.hpp>
#include <ArrayList.hpp>
#include <DLHashTable.hpp>
+#include <DLFifoList.hpp>
#include <CArray.hpp>
+#include <KeyTable.hpp>
#include <KeyTable2.hpp>
+#include <KeyTable2Ref.hpp>
#include <SimulatedBlock.hpp>
#include <SimpleProperties.hpp>
#include <SignalCounter.hpp>
@@ -54,6 +56,10 @@
#include <blocks/mutexes.hpp>
#include <SafeCounter.hpp>
#include <RequestTracker.hpp>
+#include <Rope.hpp>
+#include <signaldata/DictObjOp.hpp>
+#include <signaldata/DropFilegroupImpl.hpp>
+#include <SLList.hpp>
#ifdef DBDICT_C
// Debug Macros
@@ -105,8 +111,6 @@
/**
* Systable NDB$EVENTS_0
*/
-
-#define EVENT_SYSTEM_TABLE_NAME "sys/def/NDB$EVENTS_0"
#define EVENT_SYSTEM_TABLE_LENGTH 8
struct sysTab_NDBEVENTS_0 {
@@ -128,11 +132,151 @@
/*
* 2.3 RECORD AND FILESIZES
*/
+
+ /**
+ * Table attributes. Permanent data.
+ *
+ * Indexes have an attribute list which duplicates primary table
+ * attributes. This is wrong but convenient.
+ */
+ struct AttributeRecord {
+ AttributeRecord(){}
+
+ /* attribute id */
+ Uint16 attributeId;
+
+ /* Attribute number within tuple key (counted from 1) */
+ Uint16 tupleKey;
+
+ /* Attribute name (unique within table) */
+ RopeHandle attributeName;
+
+ /* Attribute description (old-style packed descriptor) */
+ Uint32 attributeDescriptor;
+
+ /* Extended attributes */
+ Uint32 extType;
+ Uint32 extPrecision;
+ Uint32 extScale;
+ Uint32 extLength;
+
+ /* Autoincrement flag, only for ODBC/SQL */
+ bool autoIncrement;
+
+ /* Default value as null-terminated string, only for ODBC/SQL */
+ RopeHandle defaultValue;
+
+ struct {
+ Uint32 m_name_len;
+ const char * m_name_ptr;
+ RopePool * m_pool;
+ } m_key;
+
+ union {
+ Uint32 nextPool;
+ Uint32 nextList;
+ };
+ Uint32 prevList;
+ Uint32 nextHash;
+ Uint32 prevHash;
+
+ Uint32 hashValue() const { return attributeName.hashValue();}
+ bool equal(const AttributeRecord& obj) const {
+ if(obj.hashValue() == hashValue()){
+ ConstRope r(* m_key.m_pool, obj.attributeName);
+ return r.compare(m_key.m_name_ptr, m_key.m_name_len) == 0;
+ }
+ return false;
+ }
+
+ /** Singly linked in internal (attributeId) order */
+ // TODO use DL template when possible to have more than 1
+ Uint32 nextAttributeIdPtrI;
+ };
+ typedef Ptr<AttributeRecord> AttributeRecordPtr;
+ ArrayPool<AttributeRecord> c_attributeRecordPool;
+ DLHashTable<AttributeRecord> c_attributeRecordHash;
+
/**
* Shared table / index record. Most of this is permanent data stored
* on disk. Index trigger ids are volatile.
*/
- struct TableRecord : public MetaData::Table {
+ struct TableRecord {
+ TableRecord(){}
+ /* Table id (array index in DICT and other blocks) */
+ Uint32 tableId;
+ Uint32 m_obj_ptr_i;
+
+ /* Table version (incremented when tableId is re-used) */
+ Uint32 tableVersion;
+
+ /* Table name (may not be unique under "alter table") */
+ RopeHandle tableName;
+
+ /* Type of table or index */
+ DictTabInfo::TableType tableType;
+
+ /* Is table or index online (this flag is not used in DICT) */
+ bool online;
+
+ /* Primary table of index otherwise RNIL */
+ Uint32 primaryTableId;
+
+ /* Type of fragmentation (small/medium/large) */
+ DictTabInfo::FragmentType fragmentType;
+
+ /* Global checkpoint identity when table created */
+ Uint32 gciTableCreated;
+
+ /* Number of attibutes in table */
+ Uint16 noOfAttributes;
+
+ /* Number of null attributes in table (should be computed) */
+ Uint16 noOfNullAttr;
+
+ /* Number of primary key attributes (should be computed) */
+ Uint16 noOfPrimkey;
+
+ /* Length of primary key in words (should be computed) */
+ /* For ordered index this is tree node size in words */
+ Uint16 tupKeyLength;
+
+ /** */
+ Uint16 noOfCharsets;
+
+ /* K value for LH**3 algorithm (only 6 allowed currently) */
+ Uint8 kValue;
+
+ /* Local key length in words (currently 1) */
+ Uint8 localKeyLen;
+
+ /*
+ * Parameter for hash algorithm that specifies the load factor in
+ * percentage of fill level in buckets. A high value means we are
+ * splitting early and that buckets are only lightly used. A high
+ * value means that we have fill the buckets more and get more
+ * likelihood of overflow buckets.
+ */
+ Uint8 maxLoadFactor;
+
+ /*
+ * Used when shrinking to decide when to merge buckets. Hysteresis
+ * is thus possible. Should be smaller but not much smaller than
+ * maxLoadFactor
+ */
+ Uint8 minLoadFactor;
+
+ /* Is the table logged (i.e. data survives system restart) */
+ bool storedTable;
+
+ /* Convenience routines */
+ bool isTable() const;
+ bool isIndex() const;
+ bool isUniqueIndex() const;
+ bool isNonUniqueIndex() const;
+ bool isHashIndex() const;
+ bool isOrderedIndex() const;
+
/****************************************************
* Support variables for table handling
****************************************************/
@@ -144,30 +288,13 @@
Uint32 filePtr[2];
/** Pointer to first attribute in table */
- Uint32 firstAttribute;
+ DLFifoList<AttributeRecord>::Head m_attributes;
/* Pointer to first page of table description */
Uint32 firstPage;
- /** Pointer to last attribute in table */
- Uint32 lastAttribute;
-
-#ifdef HAVE_TABLE_REORG
- /* Second table used by this table (for table reorg) */
- Uint32 secondTable;
-#endif
- /* Next record in Pool */
Uint32 nextPool;
- /* Next record in hash table */
- Uint32 nextHash;
-
- /* Previous record in Pool */
- Uint32 prevPool;
-
- /* Previous record in hash table */
- Uint32 prevHash;
-
enum TabState {
NOT_DEFINED = 0,
REORG_TABLE_PREPARED = 1,
@@ -218,75 +345,26 @@
Uint32 noOfNullBits;
- inline bool equal(TableRecord & rec) const {
- return strcmp(tableName, rec.tableName) == 0;
- }
-
- inline Uint32 hashValue() const {
- Uint32 h = 0;
- for (const char* p = tableName; *p != 0; p++)
- h = (h << 5) + h + (*p);
- return h;
- }
-
/** frm data for this table */
- /** TODO Could preferrably be made dynamic size */
- Uint32 frmLen;
- char frmData[MAX_FRM_DATA_SIZE];
+ RopeHandle frmData;
/** Node Group and Tablespace id for this table */
/** TODO Could preferrably be made dynamic size */
Uint32 ngLen;
Uint16 ngData[MAX_NDB_PARTITIONS];
Uint32 fragmentCount;
+ Uint32 m_tablespace_id;
};
typedef Ptr<TableRecord> TableRecordPtr;
ArrayPool<TableRecord> c_tableRecordPool;
- DLHashTable<TableRecord> c_tableRecordHash;
-
- /**
- * Table attributes. Permanent data.
- *
- * Indexes have an attribute list which duplicates primary table
- * attributes. This is wrong but convenient.
- */
- struct AttributeRecord : public MetaData::Attribute {
- union {
- /** Pointer to the next attribute used by ArrayPool */
- Uint32 nextPool;
-
- /** Pointer to the next attribute used by DLHash */
- Uint32 nextHash;
- };
-
- /** Pointer to the previous attribute used by DLHash */
- Uint32 prevHash;
-
- /** Pointer to the next attribute in table */
- Uint32 nextAttrInTable;
-
- inline bool equal(AttributeRecord & rec) const {
- return strcmp(attributeName, rec.attributeName) == 0;
- }
-
- inline Uint32 hashValue() const {
- Uint32 h = 0;
- for (const char* p = attributeName; *p != 0; p++)
- h = (h << 5) + h + (*p);
- return h;
- }
- };
-
- typedef Ptr<AttributeRecord> AttributeRecordPtr;
- ArrayPool<AttributeRecord> c_attributeRecordPool;
- DLHashTable<AttributeRecord> c_attributeRecordHash;
/**
* Triggers. This is volatile data not saved on disk. Setting a
* trigger online creates the trigger in TC (if index) and LQH-TUP.
*/
struct TriggerRecord {
+ TriggerRecord() {}
/** Trigger state */
enum TriggerState {
@@ -307,10 +385,11 @@
Uint32 triggerLocal;
/** Trigger name, used by DICT to identify the trigger */
- char triggerName[MAX_TAB_NAME_SIZE];
+ RopeHandle triggerName;
/** Trigger id, used by TRIX, TC, LQH, and TUP to identify the trigger */
Uint32 triggerId;
+ Uint32 m_obj_ptr_i;
/** Table id, the table the trigger is defined on */
Uint32 tableId;
@@ -339,39 +418,17 @@
/** Index id, only used by secondary_index triggers */
Uint32 indexId;
- union {
/** Pointer to the next attribute used by ArrayPool */
Uint32 nextPool;
-
- /** Next record in hash table */
- Uint32 nextHash;
- };
-
- /** Previous record in hash table */
- Uint32 prevHash;
-
- /** Equal function, used by DLHashTable */
- inline bool equal(TriggerRecord & rec) const {
- return strcmp(triggerName, rec.triggerName) == 0;
- }
-
- /** Hash value function, used by DLHashTable */
- inline Uint32 hashValue() const {
- Uint32 h = 0;
- for (const char* p = triggerName; *p != 0; p++)
- h = (h << 5) + h + (*p);
- return h;
- }
};
Uint32 c_maxNoOfTriggers;
typedef Ptr<TriggerRecord> TriggerRecordPtr;
ArrayPool<TriggerRecord> c_triggerRecordPool;
- DLHashTable<TriggerRecord> c_triggerRecordHash;
/**
* Information for each FS connection.
- ****************************************************************************/
+ ***************************************************************************/
struct FsConnectRecord {
enum FsState {
IDLE = 0,
@@ -410,7 +467,7 @@
/**
* This record stores all the information about a node and all its attributes
- ****************************************************************************/
+ ***************************************************************************/
struct NodeRecord {
enum NodeState {
API_NODE = 0,
@@ -425,9 +482,6 @@
CArray<NodeRecord> c_nodes;
NdbNodeBitmask c_aliveNodes;
- /**
- * This record stores all the information about a table and all its attributes
- ****************************************************************************/
struct PageRecord {
Uint32 word[8192];
};
@@ -446,6 +500,119 @@
*/
PageRecord c_indexPage;
+ struct File {
+ File() {}
+
+ Uint32 key;
+ Uint32 m_obj_ptr_i;
+ Uint32 m_filegroup_id;
+ Uint32 m_type;
+ Uint64 m_file_size;
+ RopeHandle m_path;
+
+ Uint32 nextList;
+ union {
+ Uint32 prevList;
+ Uint32 nextPool;
+ };
+ Uint32 nextHash, prevHash;
+
+ Uint32 hashValue() const { return key;}
+ bool equal(const File& obj) const { return key == obj.key;}
+ };
+ typedef Ptr<File> FilePtr;
+
+ struct Filegroup {
+ Filegroup(){}
+
+ Uint32 key;
+ Uint32 m_obj_ptr_i;
+
+ Uint32 m_type;
+ Uint32 m_version;
+ RopeHandle m_name;
+
+ union {
+ struct {
+ Uint32 m_extent_size;
+ Uint32 m_default_logfile_group_id;
+ } m_tablespace;
+
+ struct {
+ Uint32 m_undo_buffer_size;
+ DLList<File>::HeadPOD m_files;
+ } m_logfilegroup;
+ };
+
+ union {
+ Uint32 nextPool;
+ Uint32 nextList;
+ Uint32 nextHash;
+ };
+ Uint32 prevHash;
+
+ Uint32 hashValue() const { return key;}
+ bool equal(const Filegroup& obj) const { return key == obj.key;}
+ };
+ typedef Ptr<Filegroup> FilegroupPtr;
+
+ ArrayPool<File> c_file_pool;
+ KeyTable<File> c_file_hash;
+ ArrayPool<Filegroup> c_filegroup_pool;
+ KeyTable<Filegroup> c_filegroup_hash;
+
+ RopePool c_rope_pool;
+
+ struct DictObject {
+ DictObject() {}
+ Uint32 m_id;
+ Uint32 m_type;
+ Uint32 m_ref_count;
+ RopeHandle m_name;
+ union {
+ struct {
+ Uint32 m_name_len;
+ const char * m_name_ptr;
+ RopePool * m_pool;
+ } m_key;
+ Uint32 nextPool;
+ Uint32 nextList;
+ };
+ Uint32 nextHash;
+ Uint32 prevHash;
+
+ Uint32 hashValue() const { return m_name.hashValue();}
+ bool equal(const DictObject& obj) const {
+ if(obj.hashValue() == hashValue()){
+ ConstRope r(* m_key.m_pool, obj.m_name);
+ return r.compare(m_key.m_name_ptr, m_key.m_name_len) == 0;
+ }
+ return false;
+ }
+ };
+
+ DLHashTable<DictObject> c_obj_hash; // Name
+ ArrayPool<DictObject> c_obj_pool;
+
+ DictObject * get_object(const char * name){
+ return get_object(name, strlen(name) + 1);
+ }
+
+ DictObject * get_object(const char * name, Uint32 len){
+ return get_object(name, len, Rope::hash(name, len));
+ }
+
+ DictObject * get_object(const char * name, Uint32 len, Uint32 hash);
+
+ void release_object(Uint32 obj_ptr_i){
+ release_object(obj_ptr_i, c_obj_pool.getPtr(obj_ptr_i));
+ }
+
+ void release_object(Uint32 obj_ptr_i, DictObject* obj_ptr_p);
+
+ void increase_ref_count(Uint32 obj_ptr_i);
+ void decrease_ref_count(Uint32 obj_ptr_i);
+
public:
Dbdict(const class Configuration &);
virtual ~Dbdict();
@@ -590,6 +757,21 @@
void execALTER_TAB_CONF(Signal* signal);
bool check_ndb_versions() const;
+ void execCREATE_FILE_REQ(Signal* signal);
+ void execCREATE_FILEGROUP_REQ(Signal* signal);
+ void execDROP_FILE_REQ(Signal* signal);
+ void execDROP_FILEGROUP_REQ(Signal* signal);
+
+ // Internal
+ void execCREATE_FILE_REF(Signal* signal);
+ void execCREATE_FILE_CONF(Signal* signal);
+ void execCREATE_FILEGROUP_REF(Signal* signal);
+ void execCREATE_FILEGROUP_CONF(Signal* signal);
+ void execDROP_FILE_REF(Signal* signal);
+ void execDROP_FILE_CONF(Signal* signal);
+ void execDROP_FILEGROUP_REF(Signal* signal);
+ void execDROP_FILEGROUP_CONF(Signal* signal);
+
/*
* 2.4 COMMON STORED VARIABLES
*/
@@ -620,7 +802,7 @@
****************************************************************************/
struct ReadTableRecord {
/** Number of Pages */
- Uint32 noOfPages;
+ Uint32 no_of_words;
/** Page Id*/
Uint32 pageId;
/** Table Id of read table */
@@ -637,7 +819,7 @@
****************************************************************************/
struct WriteTableRecord {
/** Number of Pages */
- Uint32 noOfPages;
+ Uint32 no_of_words;
/** Page Id*/
Uint32 pageId;
/** Table Files Handled, local state variable */
@@ -713,6 +895,8 @@
/** The active table at restart process */
BlockReference returnBlockRef;
+
+ Uint32 m_pass; // 0 tablespaces/logfilegroups, 1 tables, 2 indexes
};
RestartRecord c_restartRecord;
@@ -740,6 +924,8 @@
/** Table id of retrieved table */
Uint32 tableId;
+ Uint32 m_table_type;
+
/** Starting page to retrieve data from */
Uint32 retrievePage;
@@ -832,10 +1018,7 @@
enum PackTableState {
PTS_IDLE = 0,
- PTS_ADD_TABLE_MASTER = 1,
- PTS_ADD_TABLE_SLAVE = 2,
- PTS_GET_TAB = 3,
- PTS_RESTART = 4
+ PTS_GET_TAB = 3
} m_state;
} c_packTable;
@@ -1677,6 +1860,64 @@
};
typedef Ptr<OpAlterTrigger> OpAlterTriggerPtr;
+public:
+ struct SchemaOp : OpRecordCommon {
+
+ Uint32 m_clientRef; // API (for take-over)
+ Uint32 m_clientData;// API
+
+ Uint32 m_senderRef; //
+ Uint32 m_senderData;// transaction key value
+
+ Uint32 m_errorCode;
+
+ Uint32 m_obj_id;
+ Uint32 m_obj_type;
+ Uint32 m_obj_version;
+ Uint32 m_obj_ptr_i;
+ Uint32 m_vt_index;
+ Callback m_callback;
+ };
+ typedef Ptr<SchemaOp> SchemaOpPtr;
+
+ struct SchemaTransaction : OpRecordCommon {
+ Uint32 m_senderRef; // API
+ Uint32 m_senderData;// API
+
+ Callback m_callback;
+ SafeCounterHandle m_counter;
+ NodeBitmask m_nodes;
+
+ Uint32 m_errorCode;
+ void setErrorCode(Uint32 c){ if(m_errorCode == 0) m_errorCode = c;}
+
+ /**
+ * This should contain "lists" with operations
+ */
+ struct {
+ Uint32 m_key; // Operation key
+ Uint32 m_vt_index; // Operation type
+ Uint32 m_obj_id;
+ DictObjOp::State m_state;
+ } m_op;
+ };
+private:
+
+ struct OpCreateObj : public SchemaOp {
+ Uint32 m_gci;
+ Uint32 m_obj_info_ptr_i;
+ Uint32 m_restart;
+ };
+ typedef Ptr<OpCreateObj> CreateObjRecordPtr;
+
+ struct OpDropObj : public SchemaOp
+ {
+ };
+ typedef Ptr<OpDropObj> DropObjRecordPtr;
+
+ /**
+ * Only used at coordinator/master
+ */
// Common operation record pool
public:
STATIC_CONST( opCreateTableSize = sizeof(CreateTableRecord) );
@@ -1692,6 +1933,7 @@
STATIC_CONST( opCreateTriggerSize = sizeof(OpCreateTrigger) );
STATIC_CONST( opDropTriggerSize = sizeof(OpDropTrigger) );
STATIC_CONST( opAlterTriggerSize = sizeof(OpAlterTrigger) );
+ STATIC_CONST( opCreateObjSize = sizeof(OpCreateObj) );
private:
#define PTR_ALIGN(n) ((((n)+sizeof(void*)-1)>>2)&~((sizeof(void*)-1)>>2))
union OpRecordUnion {
@@ -1708,6 +1950,7 @@
Uint32 u_opCreateTrigger[PTR_ALIGN(opCreateTriggerSize)];
Uint32 u_opDropTrigger [PTR_ALIGN(opDropTriggerSize)];
Uint32 u_opAlterTrigger [PTR_ALIGN(opAlterTriggerSize)];
+ Uint32 u_opCreateObj [PTR_ALIGN(opCreateObjSize)];
Uint32 nextPool;
};
ArrayPool<OpRecordUnion> c_opRecordPool;
@@ -1726,6 +1969,10 @@
KeyTable2<OpCreateTrigger, OpRecordUnion> c_opCreateTrigger;
KeyTable2<OpDropTrigger, OpRecordUnion> c_opDropTrigger;
KeyTable2<OpAlterTrigger, OpRecordUnion> c_opAlterTrigger;
+ KeyTable2<SchemaOp, OpRecordUnion> c_schemaOp;
+ KeyTable2<SchemaTransaction, OpRecordUnion> c_Trans;
+ KeyTable2Ref<OpCreateObj, SchemaOp, OpRecordUnion> c_opCreateObj;
+ KeyTable2Ref<OpDropObj, SchemaOp, OpRecordUnion> c_opDropObj;
// Unique key for operation XXX move to some system table
Uint32 c_opRecordSequence;
@@ -1747,13 +1994,15 @@
/* ------------------------------------------------------------ */
// General Stuff
/* ------------------------------------------------------------ */
+ Uint32 getFreeObjId(Uint32 minId);
Uint32 getFreeTableRecord(Uint32 primaryTableId);
Uint32 getFreeTriggerRecord();
bool getNewAttributeRecord(TableRecordPtr tablePtr,
AttributeRecordPtr & attrPtr);
- void packTableIntoPages(Signal* signal, Uint32 tableId, Uint32 pageId);
- void packTableIntoPagesImpl(SimpleProperties::Writer &, TableRecordPtr,
- Signal* signal= 0);
+ void packTableIntoPages(Signal* signal);
+ void packTableIntoPages(SimpleProperties::Writer &, TableRecordPtr, Signal* =0);
+ void packFilegroupIntoPages(SimpleProperties::Writer &, FilegroupPtr);
+ void packFileIntoPages(SimpleProperties::Writer &, FilePtr, const Uint32);
void sendGET_TABINFOREQ(Signal* signal,
Uint32 tableId);
@@ -1776,7 +2025,8 @@
void handleTabInfoInit(SimpleProperties::Reader &,
ParseDictTabInfoRecord *,
bool checkExist = true);
- void handleTabInfo(SimpleProperties::Reader & it, ParseDictTabInfoRecord *);
+ void handleTabInfo(SimpleProperties::Reader & it, ParseDictTabInfoRecord *,
+ Uint32 tablespaceVersion);
void handleAddTableFailure(Signal* signal,
Uint32 failureLine,
@@ -2139,7 +2389,9 @@
void createTab_reply(Signal* signal, CreateTableRecordPtr, Uint32 nodeId);
void alterTab_activate(Signal*, CreateTableRecordPtr, Callback*);
- void restartCreateTab(Signal*, Uint32, const SchemaFile::TableEntry *, bool);
+ void restartCreateTab(Signal*, Uint32,
+ const SchemaFile::TableEntry *,
+ const SchemaFile::TableEntry *, bool);
void restartCreateTab_readTableConf(Signal* signal, Uint32 callback, Uint32);
void restartCreateTab_writeTableConf(Signal* signal, Uint32 callback, Uint32);
void restartCreateTab_dihComplete(Signal* signal, Uint32 callback, Uint32);
@@ -2154,13 +2406,128 @@
void sendSchemaComplete(Signal*, Uint32 callbackData, Uint32);
- // global metadata support
- friend class MetaData;
- int getMetaTablePtr(TableRecordPtr& tablePtr, Uint32 tableId, Uint32 tableVersion);
- int getMetaTable(MetaData::Table& table, Uint32 tableId, Uint32 tableVersion);
- int getMetaTable(MetaData::Table& table, const char* tableName);
- int getMetaAttribute(MetaData::Attribute& attribute, const MetaData::Table& table, Uint32 attributeId);
- int getMetaAttribute(MetaData::Attribute& attribute, const MetaData::Table& table, const char* attributeName);
+ void execCREATE_OBJ_REQ(Signal* signal);
+ void execCREATE_OBJ_REF(Signal* signal);
+ void execCREATE_OBJ_CONF(Signal* signal);
+
+ void createObj_prepare_start_done(Signal* signal, Uint32 callback, Uint32);
+ void createObj_writeSchemaConf1(Signal* signal, Uint32 callback, Uint32);
+ void createObj_writeObjConf(Signal* signal, Uint32 callbackData, Uint32);
+ void createObj_prepare_complete_done(Signal*, Uint32 callbackData, Uint32);
+ void createObj_commit_start_done(Signal* signal, Uint32 callback, Uint32);
+ void createObj_writeSchemaConf2(Signal* signal, Uint32 callbackData, Uint32);
+ void createObj_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
+ void createObj_abort(Signal*, struct CreateObjReq*);
+ void createObj_abort_start_done(Signal*, Uint32 callbackData, Uint32);
+ void createObj_abort_writeSchemaConf(Signal*, Uint32 callbackData, Uint32);
+ void createObj_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
+
+ void schemaOp_reply(Signal* signal, SchemaTransaction *, Uint32);
+ void trans_commit_start_done(Signal*, Uint32 callbackData, Uint32);
+ void trans_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
+ void trans_abort_start_done(Signal*, Uint32 callbackData, Uint32);
+ void trans_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
+
+ void execDROP_OBJ_REQ(Signal* signal);
+ void execDROP_OBJ_REF(Signal* signal);
+ void execDROP_OBJ_CONF(Signal* signal);
+
+ void dropObj_prepare_start_done(Signal* signal, Uint32 callback, Uint32);
+ void dropObj_prepare_writeSchemaConf(Signal*, Uint32 callback, Uint32);
+ void dropObj_prepare_complete_done(Signal*, Uint32 callbackData, Uint32);
+ void dropObj_commit_start_done(Signal*, Uint32 callbackData, Uint32);
+ void dropObj_commit_writeSchemaConf(Signal*, Uint32 callback, Uint32);
+ void dropObj_commit_complete_done(Signal*, Uint32 callbackData, Uint32);
+ void dropObj_abort_start_done(Signal*, Uint32 callbackData, Uint32);
+ void dropObj_abort_writeSchemaConf(Signal*, Uint32 callback, Uint32);
+ void dropObj_abort_complete_done(Signal*, Uint32 callbackData, Uint32);
+
+ void restartCreateObj(Signal*, Uint32,
+ const SchemaFile::TableEntry *,
+ const SchemaFile::TableEntry *, bool);
+ void restartCreateObj_readConf(Signal*, Uint32, Uint32);
+ void restartCreateObj_getTabInfoConf(Signal*);
+ void restartCreateObj_prepare_start_done(Signal*, Uint32, Uint32);
+ void restartCreateObj_write_complete(Signal*, Uint32, Uint32);
+ void restartCreateObj_prepare_complete_done(Signal*, Uint32, Uint32);
+ void restartCreateObj_commit_start_done(Signal*, Uint32, Uint32);
+ void restartCreateObj_commit_complete_done(Signal*, Uint32, Uint32);
+
+ void execDICT_COMMIT_REQ(Signal*);
+ void execDICT_COMMIT_REF(Signal*);
+ void execDICT_COMMIT_CONF(Signal*);
+
+ void execDICT_ABORT_REQ(Signal*);
+ void execDICT_ABORT_REF(Signal*);
+ void execDICT_ABORT_CONF(Signal*);
+
+public:
+ void createObj_commit(Signal*, struct SchemaOp*);
+ void createObj_abort(Signal*, struct SchemaOp*);
+
+ void create_fg_prepare_start(Signal* signal, SchemaOp*);
+ void create_fg_prepare_complete(Signal* signal, SchemaOp*);
+ void create_fg_abort_start(Signal* signal, SchemaOp*);
+ void create_fg_abort_complete(Signal* signal, SchemaOp*);
+
+ void create_file_prepare_start(Signal* signal, SchemaOp*);
+ void create_file_prepare_complete(Signal* signal, SchemaOp*);
+ void create_file_commit_start(Signal* signal, SchemaOp*);
+ void create_file_abort_start(Signal* signal, SchemaOp*);
+ void create_file_abort_complete(Signal* signal, SchemaOp*);
+
+ void dropObj_commit(Signal*, struct SchemaOp*);
+ void dropObj_abort(Signal*, struct SchemaOp*);
+ void drop_file_prepare_start(Signal* signal, SchemaOp*);
+ void drop_file_commit_start(Signal* signal, SchemaOp*);
+ void drop_file_commit_complete(Signal* signal, SchemaOp*);
+ void drop_file_abort_start(Signal* signal, SchemaOp*);
+ void send_drop_file(Signal*, SchemaOp*, DropFileImplReq::RequestInfo);
+
+ void drop_fg_prepare_start(Signal* signal, SchemaOp*);
+ void drop_fg_commit_start(Signal* signal, SchemaOp*);
+ void drop_fg_commit_complete(Signal* signal, SchemaOp*);
+ void drop_fg_abort_start(Signal* signal, SchemaOp*);
+ void send_drop_fg(Signal*, SchemaOp*, DropFilegroupImplReq::RequestInfo);
+
+ void drop_undofile_prepare_start(Signal* signal, SchemaOp*);
};
+
+inline bool
+Dbdict::TableRecord::isTable() const
+{
+ return DictTabInfo::isTable(tableType);
+}
+
+inline bool
+Dbdict::TableRecord::isIndex() const
+{
+ return DictTabInfo::isIndex(tableType);
+}
+
+inline bool
+Dbdict::TableRecord::isUniqueIndex() const
+{
+ return DictTabInfo::isUniqueIndex(tableType);
+}
+
+inline bool
+Dbdict::TableRecord::isNonUniqueIndex() const
+{
+ return DictTabInfo::isNonUniqueIndex(tableType);
+}
+
+inline bool
+Dbdict::TableRecord::isHashIndex() const
+{
+ return DictTabInfo::isHashIndex(tableType);
+}
+
+inline bool
+Dbdict::TableRecord::isOrderedIndex() const
+{
+ return DictTabInfo::isOrderedIndex(tableType);
+}
+
#endif
--- 1.41/storage/ndb/src/ndbapi/NdbDictionary.cpp 2005-09-16 09:32:21 +02:00
+++ 1.42/storage/ndb/src/ndbapi/NdbDictionary.cpp 2005-11-09 10:17:32 +01:00
@@ -178,12 +178,12 @@
void
NdbDictionary::Column::setPartitionKey(bool val){
- m_impl.m_distributionKey = val;
+ m_impl.m_distributionKey = (val ? 2 : 0);
}
bool
NdbDictionary::Column::getPartitionKey() const{
- return m_impl.m_distributionKey;
+ return (bool)m_impl.m_distributionKey;
}
const NdbDictionary::Table *
@@ -223,7 +223,12 @@
int
NdbDictionary::Column::getColumnNo() const {
- return m_impl.m_attrId;
+ return m_impl.m_column_no;
+}
+
+int
+NdbDictionary::Column::getAttrId() const {
+ return m_impl.m_attrId;;
}
bool
@@ -237,6 +242,30 @@
return m_impl.m_attrSize * m_impl.m_arraySize;
}
+void
+NdbDictionary::Column::setArrayType(ArrayType type)
+{
+ m_impl.m_arrayType = type;
+}
+
+NdbDictionary::Column::ArrayType
+NdbDictionary::Column::getArrayType() const
+{
+ return (ArrayType)m_impl.m_arrayType;
+}
+
+void
+NdbDictionary::Column::setStorageType(StorageType type)
+{
+ m_impl.m_storageType = type;
+}
+
+NdbDictionary::Column::StorageType
+NdbDictionary::Column::getStorageType() const
+{
+ return (StorageType)m_impl.m_storageType;
+}
+
/*****************************************************************
* Table facade
*/
@@ -247,8 +276,7 @@
}
NdbDictionary::Table::Table(const NdbDictionary::Table & org)
- : NdbDictionary::Object(),
- m_impl(* new NdbTableImpl(* this))
+ : Object(org), m_impl(* new NdbTableImpl(* this))
{
m_impl.assign(org.m_impl);
}
@@ -291,7 +319,7 @@
int
NdbDictionary::Table::getTableId() const {
- return m_impl.m_tableId;
+ return m_impl.m_id;
}
void
@@ -299,12 +327,7 @@
NdbColumnImpl* col = new NdbColumnImpl;
(* col) = NdbColumnImpl::getImpl(c);
m_impl.m_columns.push_back(col);
- if(c.getPrimaryKey()){
- m_impl.m_noOfKeys++;
- }
- if (col->getBlobType()) {
- m_impl.m_noOfBlobs++;
- }
+ m_impl.computeAggregates();
m_impl.buildColumnHash();
}
@@ -474,6 +497,20 @@
return pNdb->getDictionary()->createTable(* this);
}
+void
+NdbDictionary::Table::setTablespace(const char * name){
+ m_impl.m_tablespace_id = ~0;
+ m_impl.m_tablespace_version = ~0;
+ m_impl.m_tablespace_name.assign(name);
+}
+
+void
+NdbDictionary::Table::setTablespace(const NdbDictionary::Tablespace & ts){
+ m_impl.m_tablespace_id = NdbTablespaceImpl::getImpl(ts).m_id;
+ m_impl.m_tablespace_version = ts.getObjectVersion();
+ m_impl.m_tablespace_name.assign(ts.getName());
+}
+
/*****************************************************************
* Index facade
*/
@@ -579,12 +616,12 @@
void
NdbDictionary::Index::setType(NdbDictionary::Index::Type t){
- m_impl.m_type = t;
+ m_impl.m_type = (NdbDictionary::Object::Type)t;
}
NdbDictionary::Index::Type
NdbDictionary::Index::getType() const {
- return m_impl.m_type;
+ return (NdbDictionary::Index::Type)m_impl.m_type;
}
void
@@ -734,6 +771,295 @@
}
/*****************************************************************
+ * Tablespace facade
+ */
+NdbDictionary::Tablespace::Tablespace()
+ : m_impl(* new NdbTablespaceImpl(* this))
+{
+}
+
+NdbDictionary::Tablespace::Tablespace(NdbTablespaceImpl & impl)
+ : m_impl(impl)
+{
+}
+
+NdbDictionary::Tablespace::~Tablespace(){
+ NdbTablespaceImpl * tmp = &m_impl;
+ if(this != tmp){
+ delete tmp;
+ }
+}
+
+void
+NdbDictionary::Tablespace::setName(const char * name){
+ m_impl.m_name.assign(name);
+}
+
+const char *
+NdbDictionary::Tablespace::getName() const {
+ return m_impl.m_name.c_str();
+}
+
+void
+NdbDictionary::Tablespace::setAutoGrowSpecification
+(const NdbDictionary::AutoGrowSpecification& spec){
+ m_impl.m_grow_spec = spec;
+}
+const NdbDictionary::AutoGrowSpecification&
+NdbDictionary::Tablespace::getAutoGrowSpecification() const {
+ return m_impl.m_grow_spec;
+}
+
+void
+NdbDictionary::Tablespace::setExtentSize(Uint32 sz){
+ m_impl.m_extent_size = sz;
+}
+
+Uint32
+NdbDictionary::Tablespace::getExtentSize() const {
+ return m_impl.m_extent_size;
+}
+
+void
+NdbDictionary::Tablespace::setDefaultLogfileGroup(const char * name){
+ m_impl.m_logfile_group_id = ~0;
+ m_impl.m_logfile_group_version = ~0;
+ m_impl.m_logfile_group_name.assign(name);
+}
+
+void
+NdbDictionary::Tablespace::setDefaultLogfileGroup
+(const NdbDictionary::LogfileGroup & lg){
+ m_impl.m_logfile_group_id = NdbLogfileGroupImpl::getImpl(lg).m_id;
+ m_impl.m_logfile_group_version = lg.getObjectVersion();
+ m_impl.m_logfile_group_name.assign(lg.getName());
+}
+
+const char *
+NdbDictionary::Tablespace::getDefaultLogfileGroup() const {
+ return m_impl.m_logfile_group_name.c_str();
+}
+
+NdbDictionary::Object::Status
+NdbDictionary::Tablespace::getObjectStatus() const {
+ return m_impl.m_status;
+}
+
+int
+NdbDictionary::Tablespace::getObjectVersion() const {
+ return m_impl.m_version;
+}
+
+/*****************************************************************
+ * LogfileGroup facade
+ */
+NdbDictionary::LogfileGroup::LogfileGroup()
+ : m_impl(* new NdbLogfileGroupImpl(* this))
+{
+}
+
+NdbDictionary::LogfileGroup::LogfileGroup(NdbLogfileGroupImpl & impl)
+ : m_impl(impl)
+{
+}
+
+NdbDictionary::LogfileGroup::~LogfileGroup(){
+ NdbLogfileGroupImpl * tmp = &m_impl;
+ if(this != tmp){
+ delete tmp;
+ }
+}
+
+void
+NdbDictionary::LogfileGroup::setName(const char * name){
+ m_impl.m_name.assign(name);
+}
+
+const char *
+NdbDictionary::LogfileGroup::getName() const {
+ return m_impl.m_name.c_str();
+}
+
+void
+NdbDictionary::LogfileGroup::setUndoBufferSize(Uint32 sz){
+ m_impl.m_undo_buffer_size = sz;
+}
+
+Uint32
+NdbDictionary::LogfileGroup::getUndoBufferSize() const {
+ return m_impl.m_undo_buffer_size;
+}
+
+void
+NdbDictionary::LogfileGroup::setAutoGrowSpecification
+(const NdbDictionary::AutoGrowSpecification& spec){
+ m_impl.m_grow_spec = spec;
+}
+const NdbDictionary::AutoGrowSpecification&
+NdbDictionary::LogfileGroup::getAutoGrowSpecification() const {
+ return m_impl.m_grow_spec;
+}
+
+NdbDictionary::Object::Status
+NdbDictionary::LogfileGroup::getObjectStatus() const {
+ return m_impl.m_status;
+}
+
+int
+NdbDictionary::LogfileGroup::getObjectVersion() const {
+ return m_impl.m_version;
+}
+
+/*****************************************************************
+ * Datafile facade
+ */
+NdbDictionary::Datafile::Datafile()
+ : m_impl(* new NdbDatafileImpl(* this))
+{
+}
+
+NdbDictionary::Datafile::Datafile(NdbDatafileImpl & impl)
+ : m_impl(impl)
+{
+}
+
+NdbDictionary::Datafile::~Datafile(){
+ NdbDatafileImpl * tmp = &m_impl;
+ if(this != tmp){
+ delete tmp;
+ }
+}
+
+void
+NdbDictionary::Datafile::setPath(const char * path){
+ m_impl.m_path.assign(path);
+}
+
+const char *
+NdbDictionary::Datafile::getPath() const {
+ return m_impl.m_path.c_str();
+}
+
+void
+NdbDictionary::Datafile::setSize(Uint64 sz){
+ m_impl.m_size = sz;
+}
+
+Uint64
+NdbDictionary::Datafile::getSize() const {
+ return m_impl.m_size;
+}
+
+Uint64
+NdbDictionary::Datafile::getFree() const {
+ return m_impl.m_free;
+}
+
+void
+NdbDictionary::Datafile::setTablespace(const char * tablespace){
+ m_impl.m_filegroup_id = ~0;
+ m_impl.m_filegroup_version = ~0;
+ m_impl.m_filegroup_name.assign(tablespace);
+}
+
+void
+NdbDictionary::Datafile::setTablespace(const NdbDictionary::Tablespace & ts){
+ m_impl.m_filegroup_id = NdbTablespaceImpl::getImpl(ts).m_id;
+ m_impl.m_filegroup_version = ts.getObjectVersion();
+ m_impl.m_filegroup_name.assign(ts.getName());
+}
+
+const char *
+NdbDictionary::Datafile::getTablespace() const {
+ return m_impl.m_filegroup_name.c_str();
+}
+
+NdbDictionary::Object::Status
+NdbDictionary::Datafile::getObjectStatus() const {
+ return m_impl.m_status;
+}
+
+int
+NdbDictionary::Datafile::getObjectVersion() const {
+ return m_impl.m_version;
+}
+
+/*****************************************************************
+ * Undofile facade
+ */
+NdbDictionary::Undofile::Undofile()
+ : m_impl(* new NdbUndofileImpl(* this))
+{
+}
+
+NdbDictionary::Undofile::Undofile(NdbUndofileImpl & impl)
+ : m_impl(impl)
+{
+}
+
+NdbDictionary::Undofile::~Undofile(){
+ NdbUndofileImpl * tmp = &m_impl;
+ if(this != tmp){
+ delete tmp;
+ }
+}
+
+void
+NdbDictionary::Undofile::setPath(const char * path){
+ m_impl.m_path.assign(path);
+}
+
+const char *
+NdbDictionary::Undofile::getPath() const {
+ return m_impl.m_path.c_str();
+}
+
+void
+NdbDictionary::Undofile::setSize(Uint64 sz){
+ m_impl.m_size = sz;
+}
+
+Uint64
+NdbDictionary::Undofile::getSize() const {
+ return m_impl.m_size;
+}
+
+Uint64
+NdbDictionary::Undofile::getFree() const {
+ return m_impl.m_free;
+}
+
+void
+NdbDictionary::Undofile::setLogfileGroup(const char * logfileGroup){
+ m_impl.m_filegroup_id = ~0;
+ m_impl.m_filegroup_version = ~0;
+ m_impl.m_filegroup_name.assign(logfileGroup);
+}
+
+void
+NdbDictionary::Undofile::setLogfileGroup
+(const NdbDictionary::LogfileGroup & ts){
+ m_impl.m_filegroup_id = NdbLogfileGroupImpl::getImpl(ts).m_id;
+ m_impl.m_filegroup_version = ts.getObjectVersion();
+ m_impl.m_filegroup_name.assign(ts.getName());
+}
+
+const char *
+NdbDictionary::Undofile::getLogfileGroup() const {
+ return m_impl.m_filegroup_name.c_str();
+}
+
+NdbDictionary::Object::Status
+NdbDictionary::Undofile::getObjectStatus() const {
+ return m_impl.m_status;
+}
+
+int
+NdbDictionary::Undofile::getObjectVersion() const {
+ return m_impl.m_version;
+}
+
+/*****************************************************************
* Dictionary facade
*/
NdbDictionary::Dictionary::Dictionary(Ndb & ndb)
@@ -1062,6 +1388,7 @@
break;
}
}
+
if (col.getPrimaryKey())
out << " PRIMARY KEY";
else if (! col.getNullable())
@@ -1072,13 +1399,115 @@
if(col.getDistributionKey())
out << " DISTRIBUTION KEY";
+ switch (col.getArrayType()) {
+ case NDB_ARRAYTYPE_FIXED:
+ out << " AT=FIXED";
+ break;
+ case NDB_ARRAYTYPE_SHORT_VAR:
+ out << " AT=SHORT_VAR";
+ break;
+ case NDB_ARRAYTYPE_MEDIUM_VAR:
+ out << " AT=MEDIUM_VAR";
+ break;
+ default:
+ out << " AT=" << col.getArrayType() << "?";
+ break;
+ }
+
+ switch (col.getStorageType()) {
+ case NDB_STORAGETYPE_MEMORY:
+ out << " ST=MEMORY";
+ break;
+ case NDB_STORAGETYPE_DISK:
+ out << " ST=DISK";
+ break;
+ default:
+ out << " ST=" << col.getStorageType() << "?";
+ break;
+ }
+
return out;
}
+int
+NdbDictionary::Dictionary::createLogfileGroup(const LogfileGroup & lg){
+ return m_impl.createLogfileGroup(NdbLogfileGroupImpl::getImpl(lg));
+}
+
+int
+NdbDictionary::Dictionary::dropLogfileGroup(const LogfileGroup & lg){
+ return m_impl.dropLogfileGroup(NdbLogfileGroupImpl::getImpl(lg));
+}
+
+NdbDictionary::LogfileGroup
+NdbDictionary::Dictionary::getLogfileGroup(const char * name){
+ NdbDictionary::LogfileGroup tmp;
+ m_impl.m_receiver.get_filegroup(NdbLogfileGroupImpl::getImpl(tmp),
+ NdbDictionary::Object::LogfileGroup, name);
+ return tmp;
+}
+
+int
+NdbDictionary::Dictionary::createTablespace(const Tablespace & lg){
+ return m_impl.createTablespace(NdbTablespaceImpl::getImpl(lg));
+}
+
+int
+NdbDictionary::Dictionary::dropTablespace(const Tablespace & lg){
+ return m_impl.dropTablespace(NdbTablespaceImpl::getImpl(lg));
+}
+
+NdbDictionary::Tablespace
+NdbDictionary::Dictionary::getTablespace(const char * name){
+ NdbDictionary::Tablespace tmp;
+ m_impl.m_receiver.get_filegroup(NdbTablespaceImpl::getImpl(tmp),
+ NdbDictionary::Object::Tablespace, name);
+ return tmp;
+}
+
+int
+NdbDictionary::Dictionary::createDatafile(const Datafile & df, bool force){
+ return m_impl.createDatafile(NdbDatafileImpl::getImpl(df), force);
+}
+
+int
+NdbDictionary::Dictionary::dropDatafile(const Datafile& df){
+ return m_impl.dropDatafile(NdbDatafileImpl::getImpl(df));
+}
+
+NdbDictionary::Datafile
+NdbDictionary::Dictionary::getDatafile(Uint32 node, const char * path){
+ NdbDictionary::Datafile tmp;
+ m_impl.m_receiver.get_file(NdbDatafileImpl::getImpl(tmp),
+ NdbDictionary::Object::Datafile,
+ node ? (int)node : -1, path);
+ return tmp;
+}
+
+int
+NdbDictionary::Dictionary::createUndofile(const Undofile & df, bool force){
+ return m_impl.createUndofile(NdbUndofileImpl::getImpl(df), force);
+}
+
+int
+NdbDictionary::Dictionary::dropUndofile(const Undofile& df){
+ return m_impl.dropUndofile(NdbUndofileImpl::getImpl(df));
+}
+
+NdbDictionary::Undofile
+NdbDictionary::Dictionary::getUndofile(Uint32 node, const char * path){
+ NdbDictionary::Undofile tmp;
+ m_impl.m_receiver.get_file(NdbUndofileImpl::getImpl(tmp),
+ NdbDictionary::Object::Undofile,
+ node ? (int)node : -1, path);
+ return tmp;
+}
+
const NdbDictionary::Column * NdbDictionary::Column::FRAGMENT = 0;
const NdbDictionary::Column * NdbDictionary::Column::FRAGMENT_MEMORY = 0;
const NdbDictionary::Column * NdbDictionary::Column::ROW_COUNT = 0;
const NdbDictionary::Column * NdbDictionary::Column::COMMIT_COUNT = 0;
const NdbDictionary::Column * NdbDictionary::Column::ROW_SIZE = 0;
const NdbDictionary::Column * NdbDictionary::Column::RANGE_NO = 0;
+const NdbDictionary::Column * NdbDictionary::Column::DISK_REF = 0;
const NdbDictionary::Column * NdbDictionary::Column::RECORDS_IN_RANGE = 0;
--- 1.94/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2005-09-16 10:13:59 +02:00
+++ 1.95/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2005-11-09 10:19:28 +01:00
@@ -29,6 +29,8 @@
#include <signaldata/AlterTable.hpp>
#include <signaldata/DropIndx.hpp>
#include <signaldata/ListTables.hpp>
+#include <signaldata/DropFilegroup.hpp>
+#include <signaldata/CreateFilegroup.hpp>
#include <signaldata/WaitGCP.hpp>
#include <SimpleProperties.hpp>
#include <Bitmask.hpp>
@@ -39,6 +41,7 @@
#include "NdbBlobImpl.hpp"
#include <AttributeHeader.hpp>
#include <my_sys.h>
+#include <NdbEnv.h>
#define DEBUG_PRINT 0
#define INCOMPATIBLE_VERSION -2
@@ -80,8 +83,11 @@
m_defaultValue = col.m_defaultValue;
m_attrSize = col.m_attrSize;
m_arraySize = col.m_arraySize;
+ m_arrayType = col.m_arrayType;
+ m_storageType = col.m_storageType;
m_keyInfoPos = col.m_keyInfoPos;
m_blobTable = col.m_blobTable;
+ m_column_no = col.m_column_no;
// Do not copy m_facade !!
return *this;
@@ -111,6 +117,7 @@
m_scale = 0;
m_length = 1;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Olddecimal:
case Olddecimalunsigned:
@@ -120,34 +127,57 @@
m_scale = 0;
m_length = 1;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Char:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = default_cs;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
+ break;
case Varchar:
m_precision = 0;
m_scale = 0;
m_length = 1;
m_cs = default_cs;
+ m_arrayType = NDB_ARRAYTYPE_SHORT_VAR;
break;
case Binary:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
+ break;
case Varbinary:
+ m_precision = 0;
+ m_scale = 0;
+ m_length = 1;
+ m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_SHORT_VAR;
+ break;
case Datetime:
case Date:
m_precision = 0;
m_scale = 0;
m_length = 1;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Blob:
m_precision = 256;
m_scale = 8000;
m_length = 4;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Text:
m_precision = 256;
m_scale = 8000;
m_length = 4;
m_cs = default_cs;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Time:
case Year:
@@ -156,24 +186,28 @@
m_scale = 0;
m_length = 1;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Bit:
m_precision = 0;
m_scale = 0;
m_length = 1;
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_FIXED;
break;
case Longvarchar:
m_precision = 0;
m_scale = 0;
m_length = 1; // legal
m_cs = default_cs;
+ m_arrayType = NDB_ARRAYTYPE_MEDIUM_VAR;
break;
case Longvarbinary:
m_precision = 0;
m_scale = 0;
m_length = 1; // legal
m_cs = NULL;
+ m_arrayType = NDB_ARRAYTYPE_MEDIUM_VAR;
break;
default:
case Undefined:
@@ -190,6 +224,11 @@
m_autoIncrement = false;
m_autoIncrementInitialValue = 1;
m_blobTable = NULL;
+ m_storageType = NDB_STORAGETYPE_MEMORY;
+#ifdef VM_TRACE
+ if(NdbEnv_GetEnv("NDB_DEFAULT_DISK", (char *)0, 0))
+ m_storageType = NDB_STORAGETYPE_DISK;
+#endif
}
NdbColumnImpl::~NdbColumnImpl()
@@ -212,13 +251,11 @@
if(m_nullable != col.m_nullable){
DBUG_RETURN(false);
}
-#ifdef ndb_dictionary_dkey_fixed
- if(m_pk){
- if(m_distributionKey != col.m_distributionKey){
+ if (m_pk) {
+ if ((bool)m_distributionKey != (bool)col.m_distributionKey) {
DBUG_RETURN(false);
}
}
-#endif
if (m_precision != col.m_precision ||
m_scale != col.m_scale ||
m_length != col.m_length ||
@@ -232,6 +269,10 @@
DBUG_RETURN(false);
}
+ if (m_arrayType != col.m_arrayType || m_storageType != col.m_storageType){
+ DBUG_RETURN(false);
+ }
+
DBUG_RETURN(true);
}
@@ -269,6 +310,11 @@
col->m_impl.m_attrId = AttributeHeader::RANGE_NO;
col->m_impl.m_attrSize = 4;
col->m_impl.m_arraySize = 1;
+ } else if(!strcmp(name, "NDB$DISK_REF")){
+ col->setType(NdbDictionary::Column::Bigunsigned);
+ col->m_impl.m_attrId = AttributeHeader::DISK_REF;
+ col->m_impl.m_attrSize = 8;
+ col->m_impl.m_arraySize = 1;
} else if(!strcmp(name, "NDB$RECORDS_IN_RANGE")){
col->setType(NdbDictionary::Column::Unsigned);
col->m_impl.m_attrId = AttributeHeader::RECORDS_IN_RANGE;
@@ -285,13 +331,15 @@
*/
NdbTableImpl::NdbTableImpl()
- : NdbDictionary::Table(* this), m_facade(this)
+ : NdbDictionary::Table(* this),
+ NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(this)
{
init();
}
NdbTableImpl::NdbTableImpl(NdbDictionary::Table & f)
- : NdbDictionary::Table(* this), m_facade(&f)
+ : NdbDictionary::Table(* this),
+ NdbDictObjectImpl(NdbDictionary::Object::UserTable), m_facade(&f)
{
init();
}
@@ -309,7 +357,7 @@
void
NdbTableImpl::init(){
m_changeMask= 0;
- m_tableId= RNIL;
+ m_id= RNIL;
m_primaryTableId= RNIL;
m_frm.clear();
m_newFrm.clear();
@@ -324,11 +372,12 @@
m_fragmentCount= 0;
m_dictionary= NULL;
m_index= NULL;
- m_indexType= NdbDictionary::Index::Undefined;
+ m_indexType= NdbDictionary::Object::TypeUndefined;
m_noOfKeys= 0;
m_noOfDistributionKeys= 0;
m_noOfBlobs= 0;
m_replicaCount= 0;
+ m_tablespace_id = ~0;
}
bool
@@ -388,14 +437,13 @@
DBUG_PRINT("info",("m_maxLoadFactor %d != %d",m_maxLoadFactor,obj.m_maxLoadFactor));
DBUG_RETURN(false);
}
-
- DBUG_RETURN(true);
+
+ DBUG_RETURN(true);
}
void
NdbTableImpl::assign(const NdbTableImpl& org)
{
- m_tableId = org.m_tableId;
m_internalName.assign(org.m_internalName);
updateMysqlName();
m_externalName.assign(org.m_externalName);
@@ -427,8 +475,13 @@
m_keyLenInWords = org.m_keyLenInWords;
m_noOfBlobs = org.m_noOfBlobs;
+ m_id = org.m_id;
m_version = org.m_version;
m_status = org.m_status;
+
+ m_tablespace_name = org.m_tablespace_name;
+ m_tablespace_id= org.m_tablespace_id;
+ m_tablespace_version = org.m_tablespace_version;
}
void NdbTableImpl::setName(const char * name)
@@ -445,6 +498,66 @@
return m_newExternalName.c_str();
}
+void
+NdbTableImpl::computeAggregates()
+{
+ m_noOfKeys = 0;
+ m_keyLenInWords = 0;
+ m_noOfDistributionKeys = 0;
+ m_noOfBlobs = 0;
+ Uint32 i, n;
+ for (i = 0; i < m_columns.size(); i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ m_noOfKeys++;
+ m_keyLenInWords += (col->m_attrSize * col->m_arraySize + 3) / 4;
+ }
+ if (col->m_distributionKey == 2) // set by user
+ m_noOfDistributionKeys++;
+
+ if (col->getBlobType())
+ m_noOfBlobs++;
+ col->m_keyInfoPos = ~0;
+ }
+ if (m_noOfDistributionKeys == m_noOfKeys) {
+ // all is none!
+ m_noOfDistributionKeys = 0;
+ }
+
+ if (m_noOfDistributionKeys == 0)
+ {
+ // none is all!
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ col->m_distributionKey = true; // set by us
+ n--;
+ }
+ }
+ }
+ else
+ {
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk)
+ {
+ if(col->m_distributionKey == 1)
+ col->m_distributionKey = 0;
+ n--;
+ }
+ }
+ }
+
+ Uint32 keyInfoPos = 0;
+ for (i = 0, n = m_noOfKeys; n != 0; i++) {
+ NdbColumnImpl* col = m_columns[i];
+ if (col->m_pk) {
+ col->m_keyInfoPos = keyInfoPos++;
+ n--;
+ }
+ }
+}
+
void NdbTableImpl::setFrm(const void* data, Uint32 len)
{
m_newFrm.assign(data, len);
@@ -483,7 +596,6 @@
void
NdbTableImpl::buildColumnHash(){
const Uint32 size = m_columns.size();
-
int i;
for(i = 31; i >= 0; i--){
if(((1 << i) & size) != 0){
@@ -589,22 +701,22 @@
NdbIndexImpl::NdbIndexImpl() :
NdbDictionary::Index(* this),
- m_facade(this)
+ NdbDictObjectImpl(NdbDictionary::Object::OrderedIndex), m_facade(this)
{
init();
}
NdbIndexImpl::NdbIndexImpl(NdbDictionary::Index & f) :
NdbDictionary::Index(* this),
- m_facade(&f)
+ NdbDictObjectImpl(NdbDictionary::Object::OrderedIndex), m_facade(&f)
{
init();
}
void NdbIndexImpl::init()
{
- m_indexId= RNIL;
- m_type= NdbDictionary::Index::Undefined;
+ m_id= RNIL;
+ m_type= NdbDictionary::Object::TypeUndefined;
m_logging= true;
m_table= NULL;
}
@@ -649,14 +761,14 @@
NdbEventImpl::NdbEventImpl() :
NdbDictionary::Event(* this),
- m_facade(this)
+ NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(this)
{
init();
}
NdbEventImpl::NdbEventImpl(NdbDictionary::Event & f) :
NdbDictionary::Event(* this),
- m_facade(&f)
+ NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined), m_facade(&f)
{
init();
}
@@ -777,6 +889,7 @@
delete NdbDictionary::Column::COMMIT_COUNT;
delete NdbDictionary::Column::ROW_SIZE;
delete NdbDictionary::Column::RANGE_NO;
+ delete NdbDictionary::Column::DISK_REF;
delete NdbDictionary::Column::RECORDS_IN_RANGE;
NdbDictionary::Column::FRAGMENT= 0;
NdbDictionary::Column::FRAGMENT_MEMORY= 0;
@@ -784,6 +897,7 @@
NdbDictionary::Column::COMMIT_COUNT= 0;
NdbDictionary::Column::ROW_SIZE= 0;
NdbDictionary::Column::RANGE_NO= 0;
+ NdbDictionary::Column::DISK_REF= 0;
NdbDictionary::Column::RECORDS_IN_RANGE= 0;
}
m_globalHash->unlock();
@@ -857,6 +971,8 @@
NdbColumnImpl::create_pseudo("NDB$ROW_SIZE");
NdbDictionary::Column::RANGE_NO=
NdbColumnImpl::create_pseudo("NDB$RANGE_NO");
+ NdbDictionary::Column::DISK_REF=
+ NdbColumnImpl::create_pseudo("NDB$DISK_REF");
NdbDictionary::Column::RECORDS_IN_RANGE=
NdbColumnImpl::create_pseudo("NDB$RECORDS_IN_RANGE");
}
@@ -987,6 +1103,30 @@
case GSN_LIST_TABLES_CONF:
tmp->execLIST_TABLES_CONF(signal, ptr);
break;
+ case GSN_CREATE_FILEGROUP_REF:
+ tmp->execCREATE_FILEGROUP_REF(signal, ptr);
+ break;
+ case GSN_CREATE_FILEGROUP_CONF:
+ tmp->execCREATE_FILEGROUP_CONF(signal, ptr);
+ break;
+ case GSN_CREATE_FILE_REF:
+ tmp->execCREATE_FILE_REF(signal, ptr);
+ break;
+ case GSN_CREATE_FILE_CONF:
+ tmp->execCREATE_FILE_CONF(signal, ptr);
+ break;
+ case GSN_DROP_FILEGROUP_REF:
+ tmp->execDROP_FILEGROUP_REF(signal, ptr);
+ break;
+ case GSN_DROP_FILEGROUP_CONF:
+ tmp->execDROP_FILEGROUP_CONF(signal, ptr);
+ break;
+ case GSN_DROP_FILE_REF:
+ tmp->execDROP_FILE_REF(signal, ptr);
+ break;
+ case GSN_DROP_FILE_CONF:
+ tmp->execDROP_FILE_CONF(signal, ptr);
+ break;
case GSN_WAIT_GCP_CONF:
tmp->execWAIT_GCP_CONF(signal, ptr);
break;
@@ -1014,20 +1154,16 @@
}
int
-NdbDictInterface::dictSignal(NdbApiSignal* signal,
- LinearSectionPtr ptr[3],int noLSP,
- const int useMasterNodeId,
- const Uint32 RETRIES,
- const WaitSignalType wst,
- const int theWait,
- const int *errcodes,
- const int noerrcodes,
- const int temporaryMask)
+NdbDictInterface::dictSignal(NdbApiSignal* sig,
+ LinearSectionPtr ptr[3], int secs,
+ int node_specification,
+ WaitSignalType wst,
+ int timeout, Uint32 RETRIES,
+ const int *errcodes, int temporaryMask)
{
DBUG_ENTER("NdbDictInterface::dictSignal");
- DBUG_PRINT("enter", ("useMasterNodeId: %d", useMasterNodeId));
+ DBUG_PRINT("enter", ("useMasterNodeId: %d", node_specification));
for(Uint32 i = 0; i<RETRIES; i++){
- //if (useMasterNodeId == 0)
m_buffer.clear();
// Protected area
@@ -1038,44 +1174,33 @@
break, continue or simply end of statement block
*/
PollGuard poll_guard(m_transporter, &m_waiter, refToBlock(m_reference));
- Uint32 aNodeId;
- if (useMasterNodeId) {
- if ((m_masterNodeId == 0) ||
- (!m_transporter->get_node_alive(m_masterNodeId))) {
- m_masterNodeId = m_transporter->get_an_alive_node();
- }//if
- aNodeId = m_masterNodeId;
- } else {
- aNodeId = m_transporter->get_an_alive_node();
+ Uint32 node;
+ switch(node_specification){
+ case 0:
+ node = (m_transporter->get_node_alive(m_masterNodeId) ? m_masterNodeId :
+ (m_masterNodeId = m_transporter->get_an_alive_node()));
+ break;
+ case -1:
+ node = m_transporter->get_an_alive_node();
+ break;
+ default:
+ node = node_specification;
}
- if(aNodeId == 0){
+ DBUG_PRINT("info", ("node %d", node));
+ if(node == 0){
m_error.code= 4009;
DBUG_RETURN(-1);
}
- {
- int r;
- if (ptr) {
-#ifdef EVENT_DEBUG
- printf("Long signal %d ptr", noLSP);
- for (int q=0;q<noLSP;q++) {
- printf(" sz %d", ptr[q].sz);
- }
- printf("\n");
-#endif
- r = m_transporter->sendFragmentedSignal(signal, aNodeId, ptr, noLSP);
- } else {
-#ifdef EVENT_DEBUG
- printf("Short signal\n");
-#endif
- r = m_transporter->sendSignal(signal, aNodeId);
- }
- if(r != 0){
- continue;
- }
- }
+ int res = (ptr ?
+ m_transporter->sendFragmentedSignal(sig, node, ptr, secs):
+ m_transporter->sendSignal(sig, node));
+ if(res != 0){
+ DBUG_PRINT("info", ("dictSignal failed to send signal"));
+ continue;
+ }
m_error.code= 0;
- int ret_val= poll_guard.wait_n_unlock(theWait, aNodeId, wst);
+ int ret_val= poll_guard.wait_n_unlock(timeout, node, wst);
// End of Protected area
if(ret_val == 0 && m_error.code == 0){
@@ -1087,10 +1212,12 @@
* Handle error codes
*/
if(ret_val == -2) //WAIT_NODE_FAILURE
+ {
continue;
-
+ }
if(m_waiter.m_state == WST_WAIT_TIMEOUT)
{
+ DBUG_PRINT("info", ("dictSignal caught time-out"));
m_error.code = 4008;
DBUG_RETURN(-1);
}
@@ -1104,18 +1231,20 @@
else if ( (temporaryMask & m_error.code) != 0 ) {
continue;
}
- if (errcodes) {
- int doContinue = 0;
- for (int j=0; j < noerrcodes; j++)
- if(m_error.code == errcodes[j]) {
- doContinue = 1;
+ DBUG_PRINT("info", ("dictSignal caught error= %d", m_error.code));
+
+ if(m_error.code && errcodes)
+ {
+ for(int j = 0; errcodes[j] ; j++){
+ if(m_error.code == errcodes[j]){
+ m_error.code = 0;
break;
}
- if (doContinue)
+ }
+ if(!m_error.code) // Accepted error code
continue;
}
-
- DBUG_RETURN(-1);
+ break;
}
DBUG_RETURN(-1);
}
@@ -1130,8 +1259,8 @@
NdbDictInterface::getTable(int tableId, bool fullyQualifiedNames)
{
NdbApiSignal tSignal(m_reference);
- GetTabInfoReq* const req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
-
+ GetTabInfoReq * req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
+
req->senderRef = m_reference;
req->senderData = 0;
req->requestType =
@@ -1190,21 +1319,23 @@
LinearSectionPtr ptr[3],
Uint32 noOfSections, bool fullyQualifiedNames)
{
- int errCodes[] = {GetTabInfoRef::Busy };
-
- int r = dictSignal(signal,ptr,noOfSections,
- 0/*do not use masternode id*/,
- 100,
+ int errCodes[] = {GetTabInfoRef::Busy, 0 };
+ int r = dictSignal(signal, ptr, noOfSections,
+ -1, // any node
WAIT_GET_TAB_INFO_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes, 1);
- if (r) return 0;
+ WAITFOR_RESPONSE_TIMEOUT, 100, errCodes);
+ if (r)
+ return 0;
+
NdbTableImpl * rt = 0;
- m_error.code= parseTableInfo(&rt,
- (Uint32*)m_buffer.get_data(),
- m_buffer.length() / 4, fullyQualifiedNames);
- rt->buildColumnHash();
+ m_error.code = parseTableInfo(&rt,
+ (Uint32*)m_buffer.get_data(),
+ m_buffer.length() / 4,
+ fullyQualifiedNames);
+ if(rt)
+ rt->buildColumnHash();
+
return rt;
}
@@ -1236,8 +1367,9 @@
NdbDictInterface::execGET_TABINFO_REF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
- const GetTabInfoRef* ref = CAST_CONSTPTR(GetTabInfoRef, signal->getDataPtr());
-
+ const GetTabInfoRef* ref = CAST_CONSTPTR(GetTabInfoRef,
+ signal->getDataPtr());
+
m_error.code= ref->errorCode;
m_waiter.signal(NO_WAIT);
}
@@ -1302,6 +1434,10 @@
{ DictTabInfo::IndexTrigger, NdbDictionary::Object::IndexTrigger },
{ DictTabInfo::SubscriptionTrigger,NdbDictionary::Object::SubscriptionTrigger },
{ DictTabInfo::ReadOnlyConstraint ,NdbDictionary::Object::ReadOnlyConstraint },
+ { DictTabInfo::Tablespace, NdbDictionary::Object::Tablespace },
+ { DictTabInfo::LogfileGroup, NdbDictionary::Object::LogfileGroup },
+ { DictTabInfo::Datafile, NdbDictionary::Object::Datafile },
+ { DictTabInfo::Undofile, NdbDictionary::Object::Undofile },
{ -1, -1 }
};
@@ -1355,7 +1491,7 @@
const char * externalName = Ndb::externalizeTableName(internalName, fullyQualifiedNames);
NdbTableImpl * impl = new NdbTableImpl();
- impl->m_tableId = tableDesc.TableId;
+ impl->m_id = tableDesc.TableId;
impl->m_version = tableDesc.TableVersion;
impl->m_status = NdbDictionary::Object::Retrieved;
impl->m_internalName.assign(internalName);
@@ -1375,23 +1511,18 @@
impl->m_minLoadFactor = tableDesc.MinLoadFactor;
impl->m_maxLoadFactor = tableDesc.MaxLoadFactor;
- impl->m_indexType = (NdbDictionary::Index::Type)
+ impl->m_indexType = (NdbDictionary::Object::Type)
getApiConstant(tableDesc.TableType,
indexTypeMapping,
- NdbDictionary::Index::Undefined);
+ NdbDictionary::Object::TypeUndefined);
- if(impl->m_indexType == NdbDictionary::Index::Undefined){
+ if(impl->m_indexType == NdbDictionary::Object::TypeUndefined){
} else {
const char * externalPrimary =
Ndb::externalizeTableName(tableDesc.PrimaryTable, fullyQualifiedNames);
impl->m_primaryTable.assign(externalPrimary);
}
- Uint32 keyInfoPos = 0;
- Uint32 keyCount = 0;
- Uint32 blobCount = 0;
- Uint32 distKeys = 0;
-
Uint32 i;
for(i = 0; i < tableDesc.NoOfAttributes; i++) {
DictTabInfo::Attribute attrDesc; attrDesc.init();
@@ -1434,46 +1565,27 @@
}
col->m_attrSize = (1 << attrDesc.AttributeSize) / 8;
col->m_arraySize = attrDesc.AttributeArraySize;
+ col->m_arrayType = attrDesc.AttributeArrayType;
if(attrDesc.AttributeSize == 0)
{
col->m_attrSize = 4;
col->m_arraySize = (attrDesc.AttributeArraySize + 31) >> 5;
}
+ col->m_storageType = attrDesc.AttributeStorageType;
col->m_pk = attrDesc.AttributeKeyFlag;
- col->m_distributionKey = attrDesc.AttributeDKey;
+ col->m_distributionKey = attrDesc.AttributeDKey ? 2 : 0;
col->m_nullable = attrDesc.AttributeNullableFlag;
col->m_autoIncrement = (attrDesc.AttributeAutoIncrement ? true : false);
col->m_autoIncrementInitialValue = ~0;
col->m_defaultValue.assign(attrDesc.AttributeDefaultValue);
- if(attrDesc.AttributeKeyFlag){
- col->m_keyInfoPos = keyInfoPos + 1;
- keyInfoPos += ((col->m_attrSize * col->m_arraySize + 3) / 4);
- keyCount++;
-
- if(attrDesc.AttributeDKey)
- distKeys++;
- } else {
- col->m_keyInfoPos = 0;
- }
- if (col->getBlobType())
- blobCount++;
- NdbColumnImpl * null = 0;
- impl->m_columns.fill(attrDesc.AttributeId, null);
- if(impl->m_columns[attrDesc.AttributeId] != 0){
- delete col;
- delete impl;
- DBUG_RETURN(703);
- }
- impl->m_columns[attrDesc.AttributeId] = col;
+ col->m_column_no = impl->m_columns.size();
+ impl->m_columns.push_back(col);
it.next();
}
- impl->m_noOfKeys = keyCount;
- impl->m_keyLenInWords = keyInfoPos;
- impl->m_noOfBlobs = blobCount;
- impl->m_noOfDistributionKeys = distKeys;
+ impl->computeAggregates();
if(tableDesc.FragmentDataLen > 0)
{
@@ -1503,14 +1615,8 @@
impl->m_hashpointerValue = 0;
}
- if(distKeys == 0)
- {
- for(i = 0; i < tableDesc.NoOfAttributes; i++)
- {
- if(impl->m_columns[i]->getPrimaryKey())
- impl->m_columns[i]->m_distributionKey = true;
- }
- }
+ impl->m_tablespace_id = tableDesc.TablespaceId;
+ impl->m_tablespace_version = tableDesc.TablespaceVersion;
* ret = impl;
@@ -1539,7 +1645,7 @@
m_error.code= 709;
DBUG_RETURN(-1);
}
- if (createBlobTables(*(info->m_table_impl)) != 0) {
+ if (createBlobTables(t, *(info->m_table_impl)) != 0) {
int save_code = m_error.code;
(void)dropTable(t);
m_error.code= save_code;
@@ -1549,15 +1655,19 @@
}
int
-NdbDictionaryImpl::createBlobTables(NdbTableImpl &t)
+NdbDictionaryImpl::createBlobTables(NdbTableImpl& org, NdbTableImpl &t)
{
DBUG_ENTER("NdbDictionaryImpl::createBlobTables");
for (unsigned i = 0; i < t.m_columns.size(); i++) {
NdbColumnImpl & c = *t.m_columns[i];
+ NdbColumnImpl & oc = *org.m_columns[i];
if (! c.getBlobType() || c.getPartSize() == 0)
continue;
NdbTableImpl bt;
+ NdbDictionary::Column::StorageType save = c.getStorageType();
+ c.setStorageType(oc.getStorageType());
NdbBlob::getBlobTable(bt, &t, &c);
+ c.setStorageType(save);
if (createTable(bt) != 0)
{
DBUG_RETURN(-1);
@@ -1648,6 +1758,9 @@
{
DBUG_ENTER("NdbDictInterface::createOrAlterTable");
unsigned i;
+
+ impl.computeAggregates();
+
if((unsigned)impl.getNoOfPrimaryKeys() > NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY){
m_error.code= 4317;
DBUG_RETURN(-1);
@@ -1686,7 +1799,6 @@
ndb.internalize_table_name(impl.m_externalName.c_str()));
impl.m_internalName.assign(internalName);
impl.updateMysqlName();
- UtilBufferWriter w(m_buffer);
DictTabInfo::Table tmpTab;
tmpTab.init();
BaseString::snprintf(tmpTab.TableName,
@@ -1709,7 +1821,9 @@
autoIncrementValue = col->m_autoIncrementInitialValue;
}
if (col->m_distributionKey)
+ {
distKeys++;
+ }
}
if (distKeys == impl.m_noOfKeys)
distKeys= 0;
@@ -1739,6 +1853,41 @@
DictTabInfo::AllNodesSmallTable);
tmpTab.TableVersion = rand();
+ const char* tablespace_name= impl.m_tablespace_name.c_str();
+loop:
+ if(impl.m_tablespace_id != ~(Uint32)0)
+ {
+ tmpTab.TablespaceId = impl.m_tablespace_id;
+ tmpTab.TablespaceVersion = impl.m_tablespace_version;
+ }
+ else if(strlen(tablespace_name))
+ {
+ NdbTablespaceImpl tmp;
+ if(get_filegroup(tmp, NdbDictionary::Object::Tablespace,
+ tablespace_name) == 0)
+ {
+ tmpTab.TablespaceId = tmp.m_id;
+ tmpTab.TablespaceVersion = tmp.m_version;
+ }
+ else
+ {
+ // error set by get filegroup
+ return -1;
+ }
+ }
+ else
+ {
+ for(i = 0; i<sz; i++)
+ {
+ if(impl.m_columns[i]->m_storageType == NDB_STORAGETYPE_DISK)
+ {
+ tablespace_name = "DEFAULT-TS";
+ goto loop;
+ }
+ }
+ }
+
+ UtilBufferWriter w(m_buffer);
SimpleProperties::UnpackStatus s;
s = SimpleProperties::pack(w,
&tmpTab,
@@ -1765,16 +1914,28 @@
DictTabInfo::Attribute tmpAttr; tmpAttr.init();
BaseString::snprintf(tmpAttr.AttributeName, sizeof(tmpAttr.AttributeName),
col->m_name.c_str());
- tmpAttr.AttributeId = i;
+ tmpAttr.AttributeId = col->m_attrId;
tmpAttr.AttributeKeyFlag = col->m_pk;
tmpAttr.AttributeNullableFlag = col->m_nullable;
- tmpAttr.AttributeDKey = distKeys ? col->m_distributionKey : 0;
+ tmpAttr.AttributeDKey = distKeys ? (bool)col->m_distributionKey : 0;
tmpAttr.AttributeExtType = (Uint32)col->m_type;
tmpAttr.AttributeExtPrecision = ((unsigned)col->m_precision & 0xFFFF);
tmpAttr.AttributeExtScale = col->m_scale;
tmpAttr.AttributeExtLength = col->m_length;
+ if(col->m_storageType == NDB_STORAGETYPE_DISK)
+ tmpAttr.AttributeArrayType = NDB_ARRAYTYPE_FIXED;
+ else
+ tmpAttr.AttributeArrayType = col->m_arrayType;
+
+ if(col->m_pk)
+ tmpAttr.AttributeStorageType = NDB_STORAGETYPE_MEMORY;
+ else
+ tmpAttr.AttributeStorageType = col->m_storageType;
+ if(col->getBlobType())
+ tmpAttr.AttributeStorageType = NDB_STORAGETYPE_MEMORY;
+
// check type and compute attribute size and array size
if (! tmpAttr.translateExtType()) {
m_error.code= 703;
@@ -1817,77 +1978,65 @@
w.add(DictTabInfo::AttributeEnd, 1);
}
- NdbApiSignal tSignal(m_reference);
- tSignal.theReceiversBlockNumber = DBDICT;
+ int ret;
LinearSectionPtr ptr[1];
ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = m_buffer.length() / 4;
- int ret;
- if (alter)
- {
- AlterTableReq * const req =
- CAST_PTR(AlterTableReq, tSignal.getDataPtrSend());
+ NdbApiSignal tSignal(m_reference);
+ tSignal.theReceiversBlockNumber = DBDICT;
+ if (alter) {
+ tSignal.theVerId_signalNumber = GSN_ALTER_TABLE_REQ;
+ tSignal.theLength = AlterTableReq::SignalLength;
+
+ AlterTableReq * req = CAST_PTR(AlterTableReq, tSignal.getDataPtrSend());
req->senderRef = m_reference;
req->senderData = 0;
req->changeMask = impl.m_changeMask;
- req->tableId = impl.m_tableId;
+ req->tableId = impl.m_id;
req->tableVersion = impl.m_version;;
- tSignal.theVerId_signalNumber = GSN_ALTER_TABLE_REQ;
- tSignal.theLength = AlterTableReq::SignalLength;
- ret= alterTable(&tSignal, ptr);
- }
- else
- {
- CreateTableReq * const req =
- CAST_PTR(CreateTableReq, tSignal.getDataPtrSend());
+
+ int errCodes[] = { AlterTableRef::NotMaster, AlterTableRef::Busy, 0 };
+ ret = dictSignal(&tSignal, ptr, 1,
+ 0, // master
+ WAIT_ALTER_TAB_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes);
- req->senderRef = m_reference;
- req->senderData = 0;
+ if(m_error.code == AlterTableRef::InvalidTableVersion) {
+ // Clear caches and try again
+ return INCOMPATIBLE_VERSION;
+ }
+ } else {
tSignal.theVerId_signalNumber = GSN_CREATE_TABLE_REQ;
tSignal.theLength = CreateTableReq::SignalLength;
- ret= createTable(&tSignal, ptr);
-
- if (ret)
- DBUG_RETURN(ret);
- if (haveAutoIncrement) {
- if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(),
- autoIncrementValue)) {
- if (ndb.theError.code == 0) {
- m_error.code= 4336;
- ndb.theError = m_error;
- } else
- m_error= ndb.theError;
- ret = -1; // errorcode set in initialize_autoincrement
- }
+ CreateTableReq * req = CAST_PTR(CreateTableReq, tSignal.getDataPtrSend());
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ int errCodes[] = { CreateTableRef::Busy, CreateTableRef::NotMaster, 0 };
+ ret = dictSignal(&tSignal, ptr, 1,
+ 0, // master node
+ WAIT_CREATE_INDX_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes);
+ }
+
+ if (!ret && !alter && haveAutoIncrement) {
+ if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(),
+ autoIncrementValue)) {
+ if (ndb.theError.code == 0) {
+ m_error.code = 4336;
+ ndb.theError = m_error;
+ } else
+ m_error= ndb.theError;
+ ret = -1; // errorcode set in initialize_autoincrement
}
}
DBUG_RETURN(ret);
}
-int
-NdbDictInterface::createTable(NdbApiSignal* signal, LinearSectionPtr ptr[3])
-{
-#if DEBUG_PRINT
- ndbout_c("BufferLen = %d", ptr[0].sz);
- SimplePropertiesLinearReader r(ptr[0].p, ptr[0].sz);
- r.printAll(ndbout);
-#endif
- const int noErrCodes = 2;
- int errCodes[noErrCodes] =
- {CreateTableRef::Busy,
- CreateTableRef::NotMaster};
- return dictSignal(signal,ptr,1,
- 1/*use masternode id*/,
- 100,
- WAIT_CREATE_INDX_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes,noErrCodes);
-}
-
-
void
NdbDictInterface::execCREATE_TABLE_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
@@ -1902,55 +2051,27 @@
}
void
-NdbDictInterface::execCREATE_TABLE_REF(NdbApiSignal * signal,
+NdbDictInterface::execCREATE_TABLE_REF(NdbApiSignal * sig,
LinearSectionPtr ptr[3])
{
- const CreateTableRef* const ref=
- CAST_CONSTPTR(CreateTableRef, signal->getDataPtr());
+ const CreateTableRef* ref = CAST_CONSTPTR(CreateTableRef, sig->getDataPtr());
m_error.code= ref->errorCode;
m_masterNodeId = ref->masterNodeId;
m_waiter.signal(NO_WAIT);
}
-int
-NdbDictInterface::alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3])
-{
-#if DEBUG_PRINT
- ndbout_c("BufferLen = %d", ptr[0].sz);
- SimplePropertiesLinearReader r(ptr[0].p, ptr[0].sz);
- r.printAll(ndbout);
-#endif
- const int noErrCodes = 2;
- int errCodes[noErrCodes] =
- {AlterTableRef::NotMaster,
- AlterTableRef::Busy};
- int r = dictSignal(signal,ptr,1,
- 1/*use masternode id*/,
- 100,WAIT_ALTER_TAB_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes, noErrCodes);
- if(m_error.code == AlterTableRef::InvalidTableVersion) {
- // Clear caches and try again
- return INCOMPATIBLE_VERSION;
- }
-
- return r;
-}
-
void
NdbDictInterface::execALTER_TABLE_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
- //AlterTableConf* const conf = CAST_CONSTPTR(AlterTableConf, signal->getDataPtr());
m_waiter.signal(NO_WAIT);
}
void
-NdbDictInterface::execALTER_TABLE_REF(NdbApiSignal * signal,
+NdbDictInterface::execALTER_TABLE_REF(NdbApiSignal * sig,
LinearSectionPtr ptr[3])
{
- const AlterTableRef * const ref =
- CAST_CONSTPTR(AlterTableRef, signal->getDataPtr());
+ const AlterTableRef * ref = CAST_CONSTPTR(AlterTableRef, sig->getDataPtr());
m_error.code= ref->errorCode;
m_masterNodeId = ref->masterNodeId;
m_waiter.signal(NO_WAIT);
@@ -1973,7 +2094,6 @@
// we must clear the cache and try again
if (ret == INCOMPATIBLE_VERSION) {
const BaseString internalTableName(m_ndb.internalize_table_name(name));
-
DBUG_PRINT("info",("INCOMPATIBLE_VERSION internal_name: %s", internalTableName.c_str()));
m_localHash.drop(internalTableName.c_str());
m_globalHash->lock();
@@ -1982,7 +2102,7 @@
m_globalHash->unlock();
DBUG_RETURN(dropTable(name));
}
-
+
DBUG_RETURN(ret);
}
@@ -1995,13 +2115,14 @@
return dropTable(name);
}
- if (impl.m_indexType != NdbDictionary::Index::Undefined) {
+ if (impl.m_indexType != NdbDictionary::Object::TypeUndefined)
+ {
m_receiver.m_error.code= 1228;
return -1;
}
List list;
- if ((res = listIndexes(list, impl.m_tableId)) == -1){
+ if ((res = listIndexes(list, impl.m_id)) == -1){
return -1;
}
for (unsigned i = 0; i < list.count; i++) {
@@ -2019,7 +2140,7 @@
}
int ret = m_receiver.dropTable(impl);
- if(ret == 0 || m_error.code == 709){
+ if(ret == 0 || m_error.code == 709 || m_error.code == 723){
const char * internalTableName = impl.m_internalName.c_str();
@@ -2046,7 +2167,7 @@
char btname[NdbBlobImpl::BlobTableNameSize];
NdbBlob::getBlobTableName(btname, &t, &c);
if (dropTable(btname) != 0) {
- if (m_error.code != 709){
+ if (m_error.code != 709 && m_error.code != 723){
DBUG_PRINT("exit",("error %u - exiting",m_error.code));
DBUG_RETURN(-1);
}
@@ -2064,28 +2185,21 @@
tSignal.theVerId_signalNumber = GSN_DROP_TABLE_REQ;
tSignal.theLength = DropTableReq::SignalLength;
- DropTableReq * const req = CAST_PTR(DropTableReq, tSignal.getDataPtrSend());
+ DropTableReq * req = CAST_PTR(DropTableReq, tSignal.getDataPtrSend());
req->senderRef = m_reference;
req->senderData = 0;
- req->tableId = impl.m_tableId;
+ req->tableId = impl.m_id;
req->tableVersion = impl.m_version;
- return dropTable(&tSignal, 0);
-}
-
-int
-NdbDictInterface::dropTable(NdbApiSignal* signal, LinearSectionPtr ptr[3])
-{
- const int noErrCodes = 3;
- int errCodes[noErrCodes] =
- {DropTableRef::NoDropTableRecordAvailable,
- DropTableRef::NotMaster,
- DropTableRef::Busy};
- int r = dictSignal(signal,NULL,0,
- 1/*use masternode id*/,
- 100,WAIT_DROP_TAB_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes, noErrCodes);
+ int errCodes[] =
+ { DropTableRef::NoDropTableRecordAvailable,
+ DropTableRef::NotMaster,
+ DropTableRef::Busy, 0 };
+ int r = dictSignal(&tSignal, 0, 0,
+ 0, // master
+ WAIT_DROP_TAB_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes);
if(m_error.code == DropTableRef::InvalidTableVersion) {
// Clear caches and try again
return INCOMPATIBLE_VERSION;
@@ -2109,7 +2223,7 @@
LinearSectionPtr ptr[3])
{
DBUG_ENTER("NdbDictInterface::execDROP_TABLE_REF");
- const DropTableRef* const ref = CAST_CONSTPTR(DropTableRef, signal->getDataPtr());
+ const DropTableRef* ref = CAST_CONSTPTR(DropTableRef, signal->getDataPtr());
m_error.code= ref->errorCode;
m_masterNodeId = ref->masterNodeId;
m_waiter.signal(NO_WAIT);
@@ -2157,7 +2271,8 @@
}
NdbTableImpl * tab = info->m_table_impl;
- if(tab->m_indexType == NdbDictionary::Index::Undefined){
+ if(tab->m_indexType == NdbDictionary::Object::TypeUndefined)
+ {
// Not an index
m_error.code = 4243;
return 0;
@@ -2192,10 +2307,10 @@
NdbIndexImpl *idx = new NdbIndexImpl();
idx->m_version = tab->m_version;
idx->m_status = tab->m_status;
- idx->m_indexId = tab->m_tableId;
+ idx->m_id = tab->m_id;
idx->m_externalName.assign(tab->getName());
idx->m_tableName.assign(prim->m_externalName);
- NdbDictionary::Index::Type type = idx->m_type = tab->m_indexType;
+ NdbDictionary::Object::Type type = idx->m_type = tab->m_indexType;
idx->m_logging = tab->m_logging;
// skip last attribute (NDB$PK or NDB$TNODE)
@@ -2221,7 +2336,7 @@
idx->m_key_ids[key_id] = i;
col->m_keyInfoPos = key_id;
- if(type == NdbDictionary::Index::OrderedIndex &&
+ if(type == NdbDictionary::Object::OrderedIndex &&
(primCol->m_distributionKey ||
(distKeys == 0 && primCol->getPrimaryKey())))
{
@@ -2262,7 +2377,7 @@
int
NdbDictInterface::createIndex(Ndb & ndb,
- NdbIndexImpl & impl,
+ const NdbIndexImpl & impl,
const NdbTableImpl & table)
{
//validate();
@@ -2276,8 +2391,6 @@
}
const BaseString internalName(
ndb.internalize_index_name(&table, impl.getName()));
- impl.m_internalName.assign(internalName);
-
w.add(DictTabInfo::TableName, internalName.c_str());
w.add(DictTabInfo::TableLoggedFlag, impl.m_logging);
@@ -2302,7 +2415,7 @@
}
req->setIndexType((DictTabInfo::TableType) it);
- req->setTableId(table.m_tableId);
+ req->setTableId(table.m_id);
req->setOnline(true);
AttributeList attributeList;
attributeList.sz = impl.m_columns.size();
@@ -2313,7 +2426,7 @@
m_error.code = 4247;
return -1;
}
- // Copy column definition
+ // Copy column definition XXX must be wrong, overwrites
*impl.m_columns[i] = *col;
// index key type check
@@ -2324,44 +2437,35 @@
m_error.code = 743;
return -1;
}
- attributeList.id[i] = col->m_attrId;
+ // API uses external column number to talk to DICT
+ attributeList.id[i] = col->m_column_no;
}
LinearSectionPtr ptr[2];
ptr[0].p = (Uint32*)&attributeList;
ptr[0].sz = 1 + attributeList.sz;
ptr[1].p = (Uint32*)m_buffer.get_data();
ptr[1].sz = m_buffer.length() >> 2; //BUG?
- return createIndex(&tSignal, ptr);
-}
-int
-NdbDictInterface::createIndex(NdbApiSignal* signal,
- LinearSectionPtr ptr[3])
-{
- const int noErrCodes = 2;
- int errCodes[noErrCodes] = {CreateIndxRef::Busy, CreateIndxRef::NotMaster};
- return dictSignal(signal,ptr,2,
- 1 /*use masternode id*/,
- 100,
+ int errCodes[] = { CreateIndxRef::Busy, CreateIndxRef::NotMaster, 0 };
+ return dictSignal(&tSignal, ptr, 2,
+ 0, // master
WAIT_CREATE_INDX_REQ,
- -1,
- errCodes,noErrCodes);
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes);
}
void
NdbDictInterface::execCREATE_INDX_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
- //CreateTableConf* const conf = CAST_CONSTPTR(CreateTableConf, signal->getDataPtr());
-
m_waiter.signal(NO_WAIT);
}
void
-NdbDictInterface::execCREATE_INDX_REF(NdbApiSignal * signal,
+NdbDictInterface::execCREATE_INDX_REF(NdbApiSignal * sig,
LinearSectionPtr ptr[3])
{
- const CreateIndxRef* const ref = CAST_CONSTPTR(CreateIndxRef, signal->getDataPtr());
+ const CreateIndxRef* ref = CAST_CONSTPTR(CreateIndxRef, sig->getDataPtr());
m_error.code = ref->getErrorCode();
if(m_error.code == ref->NotMaster)
m_masterNodeId= ref->masterNodeId;
@@ -2452,23 +2556,15 @@
req->setConnectionPtr(0);
req->setRequestType(DropIndxReq::RT_USER);
req->setTableId(~0); // DICT overwrites
- req->setIndexId(timpl.m_tableId);
+ req->setIndexId(timpl.m_id);
req->setIndexVersion(timpl.m_version);
- return dropIndex(&tSignal, 0);
-}
-
-int
-NdbDictInterface::dropIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3])
-{
- const int noErrCodes = 2;
- int errCodes[noErrCodes] = {DropIndxRef::Busy, DropIndxRef::NotMaster};
- int r = dictSignal(signal,NULL,0,
- 1/*Use masternode id*/,
- 100,
+ int errCodes[] = { DropIndxRef::Busy, DropIndxRef::NotMaster, 0 };
+ int r = dictSignal(&tSignal, 0, 0,
+ 0, // master
WAIT_DROP_INDX_REQ,
- WAITFOR_RESPONSE_TIMEOUT,
- errCodes,noErrCodes);
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes);
if(m_error.code == DropIndxRef::InvalidIndexVersion) {
// Clear caches and try again
return INCOMPATIBLE_VERSION;
@@ -2487,7 +2583,7 @@
NdbDictInterface::execDROP_INDX_REF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
- const DropIndxRef* const ref = CAST_CONSTPTR(DropIndxRef, signal->getDataPtr());
+ const DropIndxRef* ref = CAST_CONSTPTR(DropIndxRef, signal->getDataPtr());
m_error.code = ref->getErrorCode();
if(m_error.code == ref->NotMaster)
m_masterNodeId= ref->masterNodeId;
@@ -2514,9 +2610,9 @@
}
}
- DBUG_PRINT("info",("Table: id: %d version: %d", tab->m_tableId, tab->m_version));
+ DBUG_PRINT("info",("Table: id: %d version: %d", tab->m_id, tab->m_version));
- evnt.m_tableId = tab->m_tableId;
+ evnt.m_tableId = tab->m_id;
evnt.m_tableVersion = tab->m_version;
evnt.m_tableImpl = tab;
NdbTableImpl &table = *evnt.m_tableImpl;
@@ -2649,12 +2745,17 @@
ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = (m_buffer.length()+3) >> 2;
- int ret = createEvent(&tSignal, ptr, 1);
+ int errCodes[] = { CreateEvntRef::Busy, 0 };
+ int ret = dictSignal(&tSignal,ptr, 1,
+ 0, // master
+ WAIT_CREATE_INDX_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ errCodes, 0);
if (ret) {
DBUG_RETURN(ret);
}
-
+
char *dataPtr = (char *)m_buffer.get_data();
unsigned int lenCreateEvntConf = *((unsigned int *)dataPtr);
dataPtr += sizeof(lenCreateEvntConf);
@@ -2686,18 +2787,6 @@
}
int
-NdbDictInterface::createEvent(NdbApiSignal* signal,
- LinearSectionPtr ptr[3], int noLSP)
-{
- return dictSignal(signal,ptr,noLSP,
- 1 /*use masternode id*/,
- 100,
- WAIT_CREATE_INDX_REQ /*WAIT_CREATE_EVNT_REQ*/,
- -1,
- NULL,0, -1);
-}
-
-int
NdbDictionaryImpl::executeSubscribeEvent(NdbEventOperationImpl & ev_op)
{
// NdbDictInterface m_receiver;
@@ -2726,13 +2815,12 @@
"subscriberData=%d",req->subscriptionId,
req->subscriptionKey,req->subscriberData));
- int errCodes[] = { SubStartRef::Busy };
+ int errCodes[] = { SubStartRef::Busy, 0 };
DBUG_RETURN(dictSignal(&tSignal,NULL,0,
- 1 /*use masternode id*/,
- 100,
+ 0 /*use masternode id*/,
WAIT_CREATE_INDX_REQ /*WAIT_CREATE_EVNT_REQ*/,
- -1,
- errCodes, sizeof(errCodes)/sizeof(errCodes[0])));
+ -1, 100,
+ errCodes, 0));
}
int
@@ -2766,13 +2854,12 @@
"subscriberData=%d",req->subscriptionId,
req->subscriptionKey,req->subscriberData));
- int errCodes[] = { SubStopRef::Busy };
+ int errCodes[] = { SubStopRef::Busy, 0 };
DBUG_RETURN(dictSignal(&tSignal,NULL,0,
- 1 /*use masternode id*/,
- 100,
+ 0 /*use masternode id*/,
WAIT_CREATE_INDX_REQ /*WAIT_SUB_STOP__REQ*/,
- -1,
- errCodes, sizeof(errCodes)/sizeof(errCodes[0])));
+ -1, 100,
+ errCodes, 0));
}
NdbEventImpl *
@@ -2809,7 +2896,7 @@
DBUG_RETURN(NULL);
}
- if (ev->m_tableId == info->m_table_impl->m_tableId &&
+ if (ev->m_tableId == info->m_table_impl->m_id &&
ev->m_tableVersion == info->m_table_impl->m_version)
break;
if (retry)
@@ -2817,7 +2904,7 @@
m_error.code= 241;
DBUG_PRINT("error",("%s: table version mismatch, event: [%u,%u] table: [%u,%u]",
ev->getTableName(), ev->m_tableId, ev->m_tableVersion,
- info->m_table_impl->m_tableId, info->m_table_impl->m_version));
+ info->m_table_impl->m_id, info->m_table_impl->m_version));
delete ev;
DBUG_RETURN(NULL);
}
@@ -2834,7 +2921,7 @@
AttributeMask & mask = ev->m_attrListBitmask;
unsigned attributeList_sz = mask.count();
- DBUG_PRINT("info",("Table: id: %d version: %d", table.m_tableId, table.m_version));
+ DBUG_PRINT("info",("Table: id: %d version: %d", table.m_id, table.m_version));
#ifndef DBUG_OFF
char buf[128] = {0};
@@ -3035,21 +3122,14 @@
ptr[0].p = (Uint32*)m_buffer.get_data();
ptr[0].sz = (m_buffer.length()+3) >> 2;
- return dropEvent(&tSignal, ptr, 1);
-}
-
-int
-NdbDictInterface::dropEvent(NdbApiSignal* signal,
- LinearSectionPtr ptr[3], int noLSP)
-{
//TODO
- return dictSignal(signal,ptr,noLSP,
- 1 /*use masternode id*/,
- 100,
- WAIT_CREATE_INDX_REQ /*WAIT_CREATE_EVNT_REQ*/,
- -1,
- NULL,0, -1);
+ return dictSignal(&tSignal,ptr, 1,
+ 0 /*use masternode id*/,
+ WAIT_CREATE_INDX_REQ,
+ -1, 100,
+ 0, 0);
}
+
void
NdbDictInterface::execDROP_EVNT_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
@@ -3300,9 +3380,568 @@
m_waiter.signal(NO_WAIT);
}
+NdbFilegroupImpl::NdbFilegroupImpl(NdbDictionary::Object::Type t)
+ : NdbDictObjectImpl(t)
+{
+ m_extent_size = 0;
+ m_undo_buffer_size = 0;
+ m_logfile_group_id = ~0;
+ m_logfile_group_version = ~0;
+}
+
+NdbTablespaceImpl::NdbTablespaceImpl() :
+ NdbDictionary::Tablespace(* this),
+ NdbFilegroupImpl(NdbDictionary::Object::Tablespace), m_facade(this)
+{
+}
+
+NdbTablespaceImpl::NdbTablespaceImpl(NdbDictionary::Tablespace & f) :
+ NdbDictionary::Tablespace(* this),
+ NdbFilegroupImpl(NdbDictionary::Object::Tablespace), m_facade(&f)
+{
+}
+
+NdbTablespaceImpl::~NdbTablespaceImpl(){
+}
+
+NdbLogfileGroupImpl::NdbLogfileGroupImpl() :
+ NdbDictionary::LogfileGroup(* this),
+ NdbFilegroupImpl(NdbDictionary::Object::LogfileGroup), m_facade(this)
+{
+}
+
+NdbLogfileGroupImpl::NdbLogfileGroupImpl(NdbDictionary::LogfileGroup & f) :
+ NdbDictionary::LogfileGroup(* this),
+ NdbFilegroupImpl(NdbDictionary::Object::LogfileGroup), m_facade(&f)
+{
+}
+
+NdbLogfileGroupImpl::~NdbLogfileGroupImpl(){
+}
+
+NdbFileImpl::NdbFileImpl(NdbDictionary::Object::Type t)
+ : NdbDictObjectImpl(t)
+{
+ m_size = 0;
+ m_free = 0;
+ m_filegroup_id = ~0;
+ m_filegroup_version = ~0;
+}
+
+NdbDatafileImpl::NdbDatafileImpl() :
+ NdbDictionary::Datafile(* this),
+ NdbFileImpl(NdbDictionary::Object::Datafile), m_facade(this)
+{
+}
+
+NdbDatafileImpl::NdbDatafileImpl(NdbDictionary::Datafile & f) :
+ NdbDictionary::Datafile(* this),
+ NdbFileImpl(NdbDictionary::Object::Datafile), m_facade(&f)
+{
+}
+
+NdbDatafileImpl::~NdbDatafileImpl(){
+}
+
+NdbUndofileImpl::NdbUndofileImpl() :
+ NdbDictionary::Undofile(* this),
+ NdbFileImpl(NdbDictionary::Object::Undofile), m_facade(this)
+{
+}
+
+NdbUndofileImpl::NdbUndofileImpl(NdbDictionary::Undofile & f) :
+ NdbDictionary::Undofile(* this),
+ NdbFileImpl(NdbDictionary::Object::Undofile), m_facade(&f)
+{
+}
+
+NdbUndofileImpl::~NdbUndofileImpl(){
+}
+
+int
+NdbDictionaryImpl::createDatafile(const NdbDatafileImpl & file, bool force){
+ DBUG_ENTER("NdbDictionaryImpl::createDatafile");
+ NdbFilegroupImpl tmp(NdbDictionary::Object::Tablespace);
+ if(file.m_filegroup_version != ~(Uint32)0){
+ tmp.m_id = file.m_filegroup_id;
+ tmp.m_version = file.m_filegroup_version;
+ DBUG_RETURN(m_receiver.create_file(file, tmp));
+ }
+
+
+ if(m_receiver.get_filegroup(tmp, NdbDictionary::Object::Tablespace,
+ file.m_filegroup_name.c_str()) == 0){
+ DBUG_RETURN(m_receiver.create_file(file, tmp, force));
+ }
+ DBUG_RETURN(-1);
+}
+
+int
+NdbDictionaryImpl::dropDatafile(const NdbDatafileImpl & file){
+ return m_receiver.drop_file(file);
+}
+
+int
+NdbDictionaryImpl::createUndofile(const NdbUndofileImpl & file, bool force){
+ DBUG_ENTER("NdbDictionaryImpl::createUndofile");
+ NdbFilegroupImpl tmp(NdbDictionary::Object::LogfileGroup);
+ if(file.m_filegroup_version != ~(Uint32)0){
+ tmp.m_id = file.m_filegroup_id;
+ tmp.m_version = file.m_filegroup_version;
+ DBUG_RETURN(m_receiver.create_file(file, tmp));
+ }
+
+
+ if(m_receiver.get_filegroup(tmp, NdbDictionary::Object::LogfileGroup,
+ file.m_filegroup_name.c_str()) == 0){
+ DBUG_RETURN(m_receiver.create_file(file, tmp, force));
+ }
+ DBUG_PRINT("info", ("Failed to find filegroup"));
+ DBUG_RETURN(-1);
+}
+
+int
+NdbDictionaryImpl::dropUndofile(const NdbUndofileImpl & file){
+ return m_receiver.drop_file(file);
+}
+
+int
+NdbDictionaryImpl::createTablespace(const NdbTablespaceImpl & fg){
+ return m_receiver.create_filegroup(fg);
+}
+
+int
+NdbDictionaryImpl::dropTablespace(const NdbTablespaceImpl & fg){
+ return m_receiver.drop_filegroup(fg);
+}
+
+int
+NdbDictionaryImpl::createLogfileGroup(const NdbLogfileGroupImpl & fg){
+ return m_receiver.create_filegroup(fg);
+}
+
+int
+NdbDictionaryImpl::dropLogfileGroup(const NdbLogfileGroupImpl & fg){
+ return m_receiver.drop_filegroup(fg);
+}
+
+int
+NdbDictInterface::create_file(const NdbFileImpl & file,
+ const NdbFilegroupImpl & group,
+ bool overwrite){
+ DBUG_ENTER("NdbDictInterface::create_file");
+ UtilBufferWriter w(m_buffer);
+ DictFilegroupInfo::File f; f.init();
+ snprintf(f.FileName, sizeof(f.FileName), file.m_path.c_str());
+ f.FileType = file.m_type;
+ f.FilegroupId = group.m_id;
+ f.FilegroupVersion = group.m_version;
+ f.FileSizeHi = (file.m_size >> 32);
+ f.FileSizeLo = (file.m_size & 0xFFFFFFFF);
+
+ SimpleProperties::UnpackStatus s;
+ s = SimpleProperties::pack(w,
+ &f,
+ DictFilegroupInfo::FileMapping,
+ DictFilegroupInfo::FileMappingSize, true);
+
+ if(s != SimpleProperties::Eof){
+ abort();
+ }
+
+ NdbApiSignal tSignal(m_reference);
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_CREATE_FILE_REQ;
+ tSignal.theLength = CreateFileReq::SignalLength;
+
+ CreateFileReq* req = CAST_PTR(CreateFileReq, tSignal.getDataPtrSend());
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->objType = file.m_type;
+ req->requestInfo = 0;
+ if (overwrite)
+ req->requestInfo |= CreateFileReq::ForceCreateFile;
+
+ LinearSectionPtr ptr[3];
+ ptr[0].p = (Uint32*)m_buffer.get_data();
+ ptr[0].sz = m_buffer.length() / 4;
+
+ int err[] = { CreateFileRef::Busy, 0};
+ /*
+ Send signal without time-out since creating files can take a very long
+ time if the file is very big.
+ */
+ DBUG_RETURN(dictSignal(&tSignal, ptr, 1,
+ 0, // master
+ WAIT_CREATE_INDX_REQ,
+ -1, 100,
+ err));
+}
+
+void
+NdbDictInterface::execCREATE_FILE_CONF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ m_waiter.signal(NO_WAIT);
+}
+
+void
+NdbDictInterface::execCREATE_FILE_REF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ const CreateFileRef* ref =
+ CAST_CONSTPTR(CreateFileRef, signal->getDataPtr());
+ m_error.code = ref->errorCode;
+ m_masterNodeId = ref->masterNodeId;
+ m_waiter.signal(NO_WAIT);
+}
+
+int
+NdbDictInterface::drop_file(const NdbFileImpl & file){
+ DBUG_ENTER("NdbDictInterface::drop_file");
+ NdbApiSignal tSignal(m_reference);
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_DROP_FILE_REQ;
+ tSignal.theLength = DropFileReq::SignalLength;
+
+ DropFileReq* req = CAST_PTR(DropFileReq, tSignal.getDataPtrSend());
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->file_id = file.m_id;
+ req->file_version = file.m_version;
+
+ int err[] = { DropFileRef::Busy, 0};
+ DBUG_RETURN(dictSignal(&tSignal, 0, 0,
+ 0, // master
+ WAIT_CREATE_INDX_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ err));
+}
+
+void
+NdbDictInterface::execDROP_FILE_CONF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ m_waiter.signal(NO_WAIT);
+}
+
+void
+NdbDictInterface::execDROP_FILE_REF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ const DropFileRef* ref =
+ CAST_CONSTPTR(DropFileRef, signal->getDataPtr());
+ m_error.code = ref->errorCode;
+ m_masterNodeId = ref->masterNodeId;
+ m_waiter.signal(NO_WAIT);
+}
+
+int
+NdbDictInterface::create_filegroup(const NdbFilegroupImpl & group){
+ DBUG_ENTER("NdbDictInterface::create_filegroup");
+ UtilBufferWriter w(m_buffer);
+ DictFilegroupInfo::Filegroup fg; fg.init();
+ snprintf(fg.FilegroupName, sizeof(fg.FilegroupName), group.m_name.c_str());
+ switch(group.m_type){
+ case NdbDictionary::Object::Tablespace:
+ {
+ fg.FilegroupType = DictTabInfo::Tablespace;
+ //fg.TS_DataGrow = group.m_grow_spec;
+ fg.TS_ExtentSize = group.m_extent_size;
+
+ if(group.m_logfile_group_version != ~(Uint32)0)
+ {
+ fg.TS_LogfileGroupId = group.m_logfile_group_id;
+ fg.TS_LogfileGroupVersion = group.m_logfile_group_version;
+ }
+ else
+ {
+ NdbLogfileGroupImpl tmp;
+ if(get_filegroup(tmp, NdbDictionary::Object::LogfileGroup,
+ group.m_logfile_group_name.c_str()) == 0)
+ {
+ fg.TS_LogfileGroupId = tmp.m_id;
+ fg.TS_LogfileGroupVersion = tmp.m_version;
+ }
+ else // error set by get filegroup
+ {
+ DBUG_RETURN(-1);
+ }
+ }
+ }
+ break;
+ case NdbDictionary::Object::LogfileGroup:
+ fg.LF_UndoBufferSize = group.m_undo_buffer_size;
+ fg.FilegroupType = DictTabInfo::LogfileGroup;
+ //fg.LF_UndoGrow = group.m_grow_spec;
+ break;
+ default:
+ abort();
+ DBUG_RETURN(-1);
+ };
+
+ SimpleProperties::UnpackStatus s;
+ s = SimpleProperties::pack(w,
+ &fg,
+ DictFilegroupInfo::Mapping,
+ DictFilegroupInfo::MappingSize, true);
+
+ if(s != SimpleProperties::Eof){
+ abort();
+ }
+
+ NdbApiSignal tSignal(m_reference);
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_CREATE_FILEGROUP_REQ;
+ tSignal.theLength = CreateFilegroupReq::SignalLength;
+
+ CreateFilegroupReq* req =
+ CAST_PTR(CreateFilegroupReq, tSignal.getDataPtrSend());
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->objType = fg.FilegroupType;
+
+ LinearSectionPtr ptr[3];
+ ptr[0].p = (Uint32*)m_buffer.get_data();
+ ptr[0].sz = m_buffer.length() / 4;
+
+ int err[] = { CreateFilegroupRef::Busy, CreateFilegroupRef::NotMaster, 0};
+ DBUG_RETURN(dictSignal(&tSignal, ptr, 1,
+ 0, // master
+ WAIT_CREATE_INDX_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ err));
+}
+
+void
+NdbDictInterface::execCREATE_FILEGROUP_CONF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ m_waiter.signal(NO_WAIT);
+}
+
+void
+NdbDictInterface::execCREATE_FILEGROUP_REF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ const CreateFilegroupRef* ref =
+ CAST_CONSTPTR(CreateFilegroupRef, signal->getDataPtr());
+ m_error.code = ref->errorCode;
+ m_masterNodeId = ref->masterNodeId;
+ m_waiter.signal(NO_WAIT);
+}
+
+int
+NdbDictInterface::drop_filegroup(const NdbFilegroupImpl & group){
+ DBUG_ENTER("NdbDictInterface::drop_filegroup");
+ NdbApiSignal tSignal(m_reference);
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_DROP_FILEGROUP_REQ;
+ tSignal.theLength = DropFilegroupReq::SignalLength;
+
+ DropFilegroupReq* req = CAST_PTR(DropFilegroupReq, tSignal.getDataPtrSend());
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->filegroup_id = group.m_id;
+ req->filegroup_version = group.m_version;
+
+ int err[] = { DropFilegroupRef::Busy, DropFilegroupRef::NotMaster, 0};
+ DBUG_RETURN(dictSignal(&tSignal, 0, 0,
+ 0, // master
+ WAIT_CREATE_INDX_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100,
+ err));
+}
+
+void
+NdbDictInterface::execDROP_FILEGROUP_CONF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ m_waiter.signal(NO_WAIT);
+}
+
+void
+NdbDictInterface::execDROP_FILEGROUP_REF(NdbApiSignal * signal,
+ LinearSectionPtr ptr[3])
+{
+ const DropFilegroupRef* ref =
+ CAST_CONSTPTR(DropFilegroupRef, signal->getDataPtr());
+ m_error.code = ref->errorCode;
+ m_masterNodeId = ref->masterNodeId;
+ m_waiter.signal(NO_WAIT);
+}
+
+
+int
+NdbDictInterface::get_filegroup(NdbFilegroupImpl & dst,
+ NdbDictionary::Object::Type type,
+ const char * name){
+ DBUG_ENTER("NdbDictInterface::get_filegroup");
+ NdbApiSignal tSignal(m_reference);
+ GetTabInfoReq * req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
+
+ size_t strLen = strlen(name) + 1;
+
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->requestType =
+ GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
+ req->tableNameLen = strLen;
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
+ tSignal.theLength = GetTabInfoReq::SignalLength;
+
+ LinearSectionPtr ptr[1];
+ ptr[0].p = (Uint32*)name;
+ ptr[0].sz = (strLen + 3)/4;
+
+ int r = dictSignal(&tSignal, ptr, 1,
+ -1, // any node
+ WAIT_GET_TAB_INFO_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100);
+ if (r)
+ {
+ DBUG_PRINT("info", ("get_filegroup failed dictSignal"));
+ DBUG_RETURN(-1);
+ }
+
+ m_error.code = parseFilegroupInfo(dst,
+ (Uint32*)m_buffer.get_data(),
+ m_buffer.length() / 4);
+
+ if(m_error.code)
+ {
+ DBUG_PRINT("info", ("get_filegroup failed parseFilegroupInfo %d",
+ m_error.code));
+ DBUG_RETURN(m_error.code);
+ }
+
+ if(dst.m_type == type)
+ {
+ DBUG_RETURN(0);
+ }
+ DBUG_PRINT("info", ("get_filegroup failed no such filegroup"));
+ DBUG_RETURN(m_error.code = GetTabInfoRef::TableNotDefined);
+}
+
+int
+NdbDictInterface::parseFilegroupInfo(NdbFilegroupImpl &dst,
+ const Uint32 * data, Uint32 len)
+
+{
+ SimplePropertiesLinearReader it(data, len);
+
+ SimpleProperties::UnpackStatus status;
+ DictFilegroupInfo::Filegroup fg; fg.init();
+ status = SimpleProperties::unpack(it, &fg,
+ DictFilegroupInfo::Mapping,
+ DictFilegroupInfo::MappingSize,
+ true, true);
+
+ if(status != SimpleProperties::Eof){
+ return CreateFilegroupRef::InvalidFormat;
+ }
+
+ dst.m_id = fg.FilegroupId;
+ dst.m_version = fg.FilegroupVersion;
+ dst.m_type = (NdbDictionary::Object::Type)fg.FilegroupType;
+ dst.m_status = NdbDictionary::Object::Retrieved;
+
+ dst.m_name.assign(fg.FilegroupName);
+ dst.m_extent_size = fg.TS_ExtentSize;
+ dst.m_undo_buffer_size = fg.LF_UndoBufferSize;
+ dst.m_logfile_group_id = fg.TS_LogfileGroupId;
+ dst.m_logfile_group_version = fg.TS_LogfileGroupVersion;
+ return 0;
+}
+
+int
+NdbDictInterface::get_file(NdbFileImpl & dst,
+ NdbDictionary::Object::Type type,
+ int node,
+ const char * name){
+ DBUG_ENTER("NdbDictInterface::get_file");
+ NdbApiSignal tSignal(m_reference);
+ GetTabInfoReq * req = CAST_PTR(GetTabInfoReq, tSignal.getDataPtrSend());
+
+ size_t strLen = strlen(name) + 1;
+
+ req->senderRef = m_reference;
+ req->senderData = 0;
+ req->requestType =
+ GetTabInfoReq::RequestByName | GetTabInfoReq::LongSignalConf;
+ req->tableNameLen = strLen;
+ tSignal.theReceiversBlockNumber = DBDICT;
+ tSignal.theVerId_signalNumber = GSN_GET_TABINFOREQ;
+ tSignal.theLength = GetTabInfoReq::SignalLength;
+
+ LinearSectionPtr ptr[1];
+ ptr[0].p = (Uint32*)name;
+ ptr[0].sz = (strLen + 3)/4;
+
+ int r = dictSignal(&tSignal, ptr, 1,
+ node,
+ WAIT_GET_TAB_INFO_REQ,
+ WAITFOR_RESPONSE_TIMEOUT, 100);
+ if (r)
+ {
+ DBUG_PRINT("info", ("get_file failed dictSignal"));
+ DBUG_RETURN(-1);
+ }
+
+ m_error.code = parseFileInfo(dst,
+ (Uint32*)m_buffer.get_data(),
+ m_buffer.length() / 4);
+
+ if(m_error.code)
+ {
+ DBUG_PRINT("info", ("get_file failed parseFileInfo %d",
+ m_error.code));
+ DBUG_RETURN(m_error.code);
+ }
+
+ if(dst.m_type == type)
+ {
+ DBUG_RETURN(0);
+ }
+ DBUG_PRINT("info", ("get_file failed no such file"));
+ DBUG_RETURN(m_error.code = GetTabInfoRef::TableNotDefined);
+}
+
+int
+NdbDictInterface::parseFileInfo(NdbFileImpl &dst,
+ const Uint32 * data, Uint32 len)
+{
+ SimplePropertiesLinearReader it(data, len);
+
+ SimpleProperties::UnpackStatus status;
+ DictFilegroupInfo::File f; f.init();
+ status = SimpleProperties::unpack(it, &f,
+ DictFilegroupInfo::FileMapping,
+ DictFilegroupInfo::FileMappingSize,
+ true, true);
+
+ if(status != SimpleProperties::Eof){
+ return CreateFilegroupRef::InvalidFormat;
+ }
+
+ dst.m_type= (NdbDictionary::Object::Type)f.FileType;
+ dst.m_id= f.FileNo;
+
+ dst.m_size= ((Uint64)f.FileSizeHi << 32) | (f.FileSizeLo);
+ dst.m_free= f.FileFreeExtents;
+ dst.m_path.assign(f.FileName);
+ //dst.m_filegroup_name
+ dst.m_filegroup_id= f.FilegroupId;
+ dst.m_filegroup_version= f.FilegroupVersion;
+
+ return 0;
+}
+
template class Vector<int>;
template class Vector<Uint16>;
template class Vector<Uint32>;
template class Vector<Vector<Uint32> >;
template class Vector<NdbTableImpl*>;
template class Vector<NdbColumnImpl*>;
+
--- 1.37/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2005-09-16 10:13:59 +02:00
+++ 1.38/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp 2005-11-09 10:17:32 +01:00
@@ -32,13 +32,17 @@
class NdbDictObjectImpl {
public:
+ int m_id;
Uint32 m_version;
+ NdbDictionary::Object::Type m_type;
NdbDictionary::Object::Status m_status;
bool change();
protected:
- NdbDictObjectImpl() :
+ NdbDictObjectImpl(NdbDictionary::Object::Type type) :
+ m_type(type),
m_status(NdbDictionary::Object::New) {
+ m_id = -1;
}
};
@@ -59,10 +63,15 @@
int m_precision;
int m_scale;
int m_length;
+ int m_column_no;
CHARSET_INFO * m_cs; // not const in MySQL
bool m_pk;
- bool m_distributionKey;
+ /*
+ * Since "none" is "all" we distinguish between
+ * 1-set by us, 2-set by user
+ */
+ Uint32 m_distributionKey;
bool m_nullable;
bool m_autoIncrement;
Uint64 m_autoIncrementInitialValue;
@@ -73,7 +82,13 @@
* Internal types and sizes, and aggregates
*/
Uint32 m_attrSize; // element size (size when arraySize==1)
- Uint32 m_arraySize; // length or length+2 for Var* types
+ Uint32 m_arraySize; // length or maxlength+1/2 for Var* types
+ Uint32 m_arrayType; // NDB_ARRAYTYPE_FIXED or _VAR
+ Uint32 m_storageType; // NDB_STORAGETYPE_MEMORY or _DISK
+ /*
+ * NdbTableImpl: if m_pk, 0-based index of key in m_attrId order
+ * NdbIndexImpl: m_column_no of primary table column
+ */
Uint32 m_keyInfoPos;
// TODO: use bits in attr desc 2
bool getInterpretableType() const ;
@@ -91,6 +106,9 @@
NdbDictionary::Column * m_facade;
static NdbDictionary::Column * create_pseudo(const char *);
+
+ // Get total length in bytes, used by NdbOperation
+ bool get_var_length(const void* value, Uint32& len) const;
};
class NdbTableImpl : public NdbDictionary::Table, public NdbDictObjectImpl {
@@ -109,7 +127,6 @@
void updateMysqlName();
Uint32 m_changeMask;
- Uint32 m_tableId;
Uint32 m_primaryTableId;
BaseString m_internalName;
BaseString m_externalName;
@@ -126,6 +143,7 @@
Uint32 m_columnHashMask;
Vector<Uint32> m_columnHash;
Vector<NdbColumnImpl *> m_columns;
+ void computeAggregates();
void buildColumnHash();
/**
@@ -153,12 +171,13 @@
* Index only stuff
*/
BaseString m_primaryTable;
- NdbDictionary::Index::Type m_indexType;
+ NdbDictionary::Object::Type m_indexType;
/**
* Aggregates
*/
Uint8 m_noOfKeys;
+ // if all pk = dk then this is zero!
Uint8 m_noOfDistributionKeys;
Uint8 m_noOfBlobs;
@@ -178,6 +197,13 @@
* Return count
*/
Uint32 get_nodes(Uint32 hashValue, const Uint16** nodes) const ;
+
+ /**
+ * Disk stuff
+ */
+ BaseString m_tablespace_name;
+ Uint32 m_tablespace_id;
+ Uint32 m_tablespace_version;
};
class NdbIndexImpl : public NdbDictionary::Index, public NdbDictObjectImpl {
@@ -193,13 +219,11 @@
const char * getTable() const;
const NdbTableImpl * getIndexTable() const;
- Uint32 m_indexId;
BaseString m_internalName;
BaseString m_externalName;
BaseString m_tableName;
Vector<NdbColumnImpl *> m_columns;
Vector<int> m_key_ids;
- NdbDictionary::Index::Type m_type;
bool m_logging;
@@ -254,6 +278,79 @@
NdbDictionary::Event * m_facade;
};
+struct NdbFilegroupImpl : public NdbDictObjectImpl {
+ NdbFilegroupImpl(NdbDictionary::Object::Type t);
+
+ BaseString m_name;
+ NdbDictionary::AutoGrowSpecification m_grow_spec;
+
+ union {
+ Uint32 m_extent_size;
+ Uint32 m_undo_buffer_size;
+ };
+
+ BaseString m_logfile_group_name;
+ Uint32 m_logfile_group_id;
+ Uint32 m_logfile_group_version;
+};
+
+class NdbTablespaceImpl : public NdbDictionary::Tablespace,
+ public NdbFilegroupImpl {
+public:
+ NdbTablespaceImpl();
+ NdbTablespaceImpl(NdbDictionary::Tablespace &);
+ ~NdbTablespaceImpl();
+
+ static NdbTablespaceImpl & getImpl(NdbDictionary::Tablespace & t);
+ static const NdbTablespaceImpl & getImpl(const NdbDictionary::Tablespace &);
+ NdbDictionary::Tablespace * m_facade;
+};
+
+class NdbLogfileGroupImpl : public NdbDictionary::LogfileGroup,
+ public NdbFilegroupImpl {
+public:
+ NdbLogfileGroupImpl();
+ NdbLogfileGroupImpl(NdbDictionary::LogfileGroup &);
+ ~NdbLogfileGroupImpl();
+
+ static NdbLogfileGroupImpl & getImpl(NdbDictionary::LogfileGroup & t);
+ static const NdbLogfileGroupImpl& getImpl(const
+ NdbDictionary::LogfileGroup&);
+ NdbDictionary::LogfileGroup * m_facade;
+};
+
+struct NdbFileImpl : public NdbDictObjectImpl {
+ NdbFileImpl(NdbDictionary::Object::Type t);
+
+ Uint64 m_size;
+ Uint32 m_free;
+ BaseString m_path;
+ BaseString m_filegroup_name;
+ Uint32 m_filegroup_id;
+ Uint32 m_filegroup_version;
+};
+
+class NdbDatafileImpl : public NdbDictionary::Datafile, public NdbFileImpl {
+public:
+ NdbDatafileImpl();
+ NdbDatafileImpl(NdbDictionary::Datafile &);
+ ~NdbDatafileImpl();
+
+ static NdbDatafileImpl & getImpl(NdbDictionary::Datafile & t);
+ static const NdbDatafileImpl & getImpl(const NdbDictionary::Datafile & t);
+ NdbDictionary::Datafile * m_facade;
+};
+
+class NdbUndofileImpl : public NdbDictionary::Undofile, public NdbFileImpl {
+public:
+ NdbUndofileImpl();
+ NdbUndofileImpl(NdbDictionary::Undofile &);
+ ~NdbUndofileImpl();
+
+ static NdbUndofileImpl & getImpl(NdbDictionary::Undofile & t);
+ static const NdbUndofileImpl & getImpl(const NdbDictionary::Undofile & t);
+ NdbDictionary::Undofile * m_facade;
+};
class NdbDictInterface {
public:
@@ -268,39 +365,22 @@
bool setTransporter(class TransporterFacade * tf);
// To abstract the stuff thats made in all create/drop/lists below
- int
- dictSignal(NdbApiSignal* signal,
- LinearSectionPtr ptr[3], int noLPTR,
- const int useMasterNodeId,
- const Uint32 RETRIES,
- const WaitSignalType wst,
- const int theWait,
- const int *errcodes,
- const int noerrcodes,
- const int temporaryMask = 0);
+ int dictSignal(NdbApiSignal* signal, LinearSectionPtr ptr[3], int secs,
+ int nodeId, // -1 any, 0 = master, >1 = specified
+ WaitSignalType wst,
+ int timeout, Uint32 RETRIES,
+ const int *errcodes = 0, int temporaryMask = 0);
int createOrAlterTable(class Ndb & ndb, NdbTableImpl &, bool alter);
int createTable(class Ndb & ndb, NdbTableImpl &);
- int createTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
-
int alterTable(class Ndb & ndb, NdbTableImpl &);
- int alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
-
- int createIndex(class Ndb & ndb,
- NdbIndexImpl &,
- const NdbTableImpl &);
- int createIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
-
- int createEvent(class Ndb & ndb, NdbEventImpl &, int getFlag);
- int createEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP);
-
int dropTable(const NdbTableImpl &);
- int dropTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
+ int createIndex(class Ndb & ndb, const NdbIndexImpl &, const NdbTableImpl &);
int dropIndex(const NdbIndexImpl &, const NdbTableImpl &);
- int dropIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
-
+
+ int createEvent(class Ndb & ndb, NdbEventImpl &, int getFlag);
int dropEvent(const NdbEventImpl &);
int dropEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP);
@@ -321,10 +401,27 @@
static int parseTableInfo(NdbTableImpl ** dst,
const Uint32 * data, Uint32 len,
bool fullyQualifiedNames);
+
+ static int parseFileInfo(NdbFileImpl &dst,
+ const Uint32 * data, Uint32 len);
+
+ static int parseFilegroupInfo(NdbFilegroupImpl &dst,
+ const Uint32 * data, Uint32 len);
+
+ int create_file(const NdbFileImpl &, const NdbFilegroupImpl&, bool overwrite = false);
+ int drop_file(const NdbFileImpl &);
+ int create_filegroup(const NdbFilegroupImpl &);
+ int drop_filegroup(const NdbFilegroupImpl &);
+
+ int get_filegroup(NdbFilegroupImpl&, NdbDictionary::Object::Type, int);
+ int get_filegroup(NdbFilegroupImpl&,NdbDictionary::Object::Type,const char*);
+ int get_file(NdbFileImpl&, NdbDictionary::Object::Type, int, int);
+ int get_file(NdbFileImpl&, NdbDictionary::Object::Type, int, const char *);
static int create_index_obj_from_table(NdbIndexImpl ** dst,
NdbTableImpl* index_table,
const NdbTableImpl* primary_table);
+
const NdbError &getNdbError() const;
NdbError & m_error;
private:
@@ -367,6 +464,18 @@
void execDROP_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
void execLIST_TABLES_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+ void execCREATE_FILE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+ void execCREATE_FILE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+
+ void execCREATE_FILEGROUP_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+ void execCREATE_FILEGROUP_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+
+ void execDROP_FILE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+ void execDROP_FILE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+
+ void execDROP_FILEGROUP_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+ void execDROP_FILEGROUP_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
+
void execWAIT_GCP_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
void execWAIT_GCP_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
@@ -384,7 +493,7 @@
bool setTransporter(class TransporterFacade * tf);
int createTable(NdbTableImpl &t);
- int createBlobTables(NdbTableImpl &);
+ int createBlobTables(NdbTableImpl& org, NdbTableImpl & created);
int addBlobTables(NdbTableImpl &);
int alterTable(NdbTableImpl &t);
int dropTable(const char * name);
@@ -418,7 +527,18 @@
const char * tableName);
NdbEventImpl * getEvent(const char * eventName);
NdbEventImpl * getEventImpl(const char * internalName);
-
+
+ int createDatafile(const NdbDatafileImpl &, bool force = false);
+ int dropDatafile(const NdbDatafileImpl &);
+ int createUndofile(const NdbUndofileImpl &, bool force = false);
+ int dropUndofile(const NdbUndofileImpl &);
+
+ int createTablespace(const NdbTablespaceImpl &);
+ int dropTablespace(const NdbTablespaceImpl &);
+
+ int createLogfileGroup(const NdbLogfileGroupImpl &);
+ int dropLogfileGroup(const NdbLogfileGroupImpl &);
+
const NdbError & getNdbError() const;
NdbError m_error;
Uint32 m_local_table_data_size;
@@ -497,6 +617,25 @@
}
inline
+bool
+NdbColumnImpl::get_var_length(const void* value, Uint32& len) const
+{
+ Uint32 max_len = m_attrSize * m_arraySize;
+ switch (m_arrayType) {
+ case NDB_ARRAYTYPE_SHORT_VAR:
+ len = 1 + *((Uint8*)value);
+ break;
+ case NDB_ARRAYTYPE_MEDIUM_VAR:
+ len = 2 + uint2korr((char*)value);
+ break;
+ default:
+ len = max_len;
+ return true;
+ }
+ return (len <= max_len);
+}
+
+inline
NdbTableImpl &
NdbTableImpl::getImpl(NdbDictionary::Table & t){
return t.m_impl;
@@ -714,5 +853,55 @@
m_error.code= 4243;
return 0;
}
+
+inline
+NdbTablespaceImpl &
+NdbTablespaceImpl::getImpl(NdbDictionary::Tablespace & t){
+ return t.m_impl;
+}
+
+inline
+const NdbTablespaceImpl &
+NdbTablespaceImpl::getImpl(const NdbDictionary::Tablespace & t){
+ return t.m_impl;
+}
+
+inline
+NdbLogfileGroupImpl &
+NdbLogfileGroupImpl::getImpl(NdbDictionary::LogfileGroup & t){
+ return t.m_impl;
+}
+
+inline
+const NdbLogfileGroupImpl &
+NdbLogfileGroupImpl::getImpl(const NdbDictionary::LogfileGroup & t){
+ return t.m_impl;
+}
+
+inline
+NdbDatafileImpl &
+NdbDatafileImpl::getImpl(NdbDictionary::Datafile & t){
+ return t.m_impl;
+}
+
+inline
+const NdbDatafileImpl &
+NdbDatafileImpl::getImpl(const NdbDictionary::Datafile & t){
+ return t.m_impl;
+}
+
+inline
+NdbUndofileImpl &
+NdbUndofileImpl::getImpl(NdbDictionary::Undofile & t){
+ return t.m_impl;
+}
+
+inline
+const NdbUndofileImpl &
+NdbUndofileImpl::getImpl(const NdbDictionary::Undofile & t){
+ return t.m_impl;
+}
+
+
#endif
--- 1.212/sql/ha_ndbcluster.cc 2005-11-07 11:57:33 +01:00
+++ 1.213/sql/ha_ndbcluster.cc 2005-11-09 10:17:31 +01:00
@@ -26,18 +26,23 @@
#include "mysql_priv.h"
-#ifdef HAVE_NDBCLUSTER_DB
#include <my_dir.h>
#include "ha_ndbcluster.h"
#include <ndbapi/NdbApi.hpp>
#include <ndbapi/NdbScanFilter.hpp>
+#include <../util/Bitmask.hpp>
#include <ndbapi/NdbIndexStat.hpp>
// options from from mysqld.cc
extern my_bool opt_ndb_optimized_node_selection;
-extern enum ndb_distribution opt_ndb_distribution_id;
extern const char *opt_ndbcluster_connectstring;
+const char *ndb_distribution_names[]= {"KEYHASH", "LINHASH", NullS};
+TYPELIB ndb_distribution_typelib= { array_elements(ndb_distribution_names)-1,
+ "", ndb_distribution_names, NULL };
+const char *opt_ndb_distribution= ndb_distribution_names[ND_KEYHASH];
+enum ndb_distribution opt_ndb_distribution_id= ND_KEYHASH;
+
// Default value for parallelism
static const int parallelism= 0;
@@ -51,6 +56,7 @@
static int ndbcluster_close_connection(THD *thd);
static int ndbcluster_commit(THD *thd, bool all);
static int ndbcluster_rollback(THD *thd, bool all);
+static handler* ndbcluster_create_handler(TABLE *table);
handlerton ndbcluster_hton = {
"ndbcluster",
@@ -73,9 +79,23 @@
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
+ ndbcluster_create_handler, /* Create a new handler */
+ ndbcluster_drop_database, /* Drop a database */
+ ndbcluster_end, /* Panic call */
+ NULL, /* Release temporary latches */
+ NULL, /* Update Statistics */
+ NULL, /* Start Consistent Snapshot */
+ NULL, /* Flush logs */
+ ndbcluster_show_status, /* Show status */
+ NULL, /* Replication Report Sent Binlog */
HTON_NO_FLAGS
};
+static handler *ndbcluster_create_handler(TABLE *table)
+{
+ return new ha_ndbcluster(table);
+}
+
#define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8
#define NDB_FAILED_AUTO_INCREMENT ~(Uint64)0
@@ -566,7 +586,7 @@
{
err= dict->getNdbError();
DBUG_PRINT("info", ("Table not found, error: %d", err.code));
- if (err.code != 709)
+ if (err.code != 709 && err.code != 723)
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("Table exists but must have changed"));
@@ -666,8 +686,7 @@
uint fieldnr, const byte *field_ptr)
{
DBUG_ENTER("set_hidden_key");
- DBUG_RETURN(ndb_op->equal(fieldnr, (char*)field_ptr,
- NDB_HIDDEN_PRIMARY_KEY_LENGTH) != 0);
+ DBUG_RETURN(ndb_op->equal(fieldnr, (char*)field_ptr) != 0);
}
@@ -729,12 +748,10 @@
{
DBUG_PRINT("info", ("field is NULL"));
// Set value to NULL
- DBUG_RETURN((ndb_op->setValue(fieldnr,
- (char*)NULL, pack_len) != 0));
+ DBUG_RETURN((ndb_op->setValue(fieldnr, (char*)NULL) != 0));
}
// Common implementation for most field types
- DBUG_RETURN(ndb_op->setValue(fieldnr,
- (char*)field_ptr, pack_len) != 0);
+ DBUG_RETURN(ndb_op->setValue(fieldnr, (char*)field_ptr) != 0);
}
else // if (field->type() == MYSQL_TYPE_BIT)
{
@@ -745,17 +762,16 @@
DBUG_ASSERT(pack_len <= 8);
if (field->is_null(row_offset))
// Set value to NULL
- DBUG_RETURN((ndb_op->setValue(fieldnr, (char*)NULL, pack_len) != 0));
+ DBUG_RETURN((ndb_op->setValue(fieldnr, (char*)NULL) != 0));
DBUG_PRINT("info", ("bit field"));
DBUG_DUMP("value", (char*)&bits, pack_len);
#ifdef WORDS_BIGENDIAN
if (pack_len < 5)
{
- DBUG_RETURN(ndb_op->setValue(fieldnr,
- ((char*)&bits)+4, pack_len) != 0);
+ DBUG_RETURN(ndb_op->setValue(fieldnr, ((char*)&bits)+4) != 0);
}
#endif
- DBUG_RETURN(ndb_op->setValue(fieldnr, (char*)&bits, pack_len) != 0);
+ DBUG_RETURN(ndb_op->setValue(fieldnr, (char*)&bits) != 0);
}
}
// Blob type
@@ -3980,11 +3996,40 @@
field->pack_length()));
if ((my_errno= create_ndb_column(col, field, info)))
DBUG_RETURN(my_errno);
+
+ if (
+#ifdef NDB_DISKDATA
+ info->store_on_disk ||
+#else
+ getenv("NDB_DEFAULT_DISK"))
+#endif
+ col.setStorageType(NdbDictionary::Column::StorageTypeDisk);
+ else
+ col.setStorageType(NdbDictionary::Column::StorageTypeMemory);
+
tab.addColumn(col);
if (col.getPrimaryKey())
pk_length += (field->pack_length() + 3) / 4;
}
-
+
+ KEY* key_info;
+ for (i= 0, key_info= form->key_info; i < form->s->keys; i++, key_info++)
+ {
+ KEY_PART_INFO *key_part= key_info->key_part;
+ KEY_PART_INFO *end= key_part + key_info->key_parts;
+ for (; key_part != end; key_part++)
+ tab.getColumn(key_part->fieldnr-1)->setStorageType(
+ NdbDictionary::Column::StorageTypeMemory);
+ }
+
+#ifdef NDB_DISKDATA
+ if (info->store_on_disk)
+ if (info->tablespace)
+ tab.setTablespace(info->tablespace);
+ else
+ tab.setTablespace("DEFAULT-TS");
+#endif
+
// No primary key, create shadow key as 64 bit, auto increment
if (form->s->primary_key == MAX_KEY)
{
@@ -4282,7 +4327,6 @@
if (!(orig_tab= dict->getTable(m_tabname)))
ERR_RETURN(dict->getNdbError());
}
-
m_table= (void *)orig_tab;
// Change current database to that of target table
set_dbname(to);
@@ -4392,7 +4436,6 @@
DBUG_ENTER("drop_table");
DBUG_PRINT("enter", ("Deleting %s", m_tabname));
-
release_metadata();
if (dict->dropTable(m_tabname))
ERR_RETURN(dict->getNdbError());
@@ -4718,7 +4761,7 @@
if (!(tab= dict->getTable(name)))
{
const NdbError err= dict->getNdbError();
- if (err.code == 709)
+ if (err.code == 709 || err.code == 723)
DBUG_RETURN(-1);
ERR_RETURN(err);
}
@@ -4765,7 +4808,7 @@
if (!(tab= dict->getTable(name)))
{
const NdbError err= dict->getNdbError();
- if (err.code == 709)
+ if (err.code == 709 || err.code == 723)
DBUG_RETURN(0);
ERR_RETURN(err);
}
@@ -4786,9 +4829,10 @@
/*
Drop a database in NDB Cluster
- */
+ NOTE add a dummy void function, since stupid handlerton is returning void instead of int...
+*/
-int ndbcluster_drop_database(const char *path)
+int ndbcluster_drop_database_impl(const char *path)
{
DBUG_ENTER("ndbcluster_drop_database");
THD *thd= current_thd;
@@ -4803,13 +4847,13 @@
DBUG_PRINT("enter", ("db: %s", dbname));
if (!(ndb= check_ndb_in_thd(thd)))
- DBUG_RETURN(HA_ERR_NO_CONNECTION);
+ DBUG_RETURN(-1);
// List tables in NDB
NDBDICT *dict= ndb->getDictionary();
if (dict->listObjects(list,
NdbDictionary::Object::UserTable) != 0)
- ERR_RETURN(dict->getNdbError());
+ DBUG_RETURN(-1);
for (i= 0 ; i < list.count ; i++)
{
NdbDictionary::Dictionary::List::Element& elmt= list.elements[i];
@@ -4832,7 +4876,7 @@
if (ha_ndbcluster::delete_table(0, ndb, full_path, dbname, tabname))
{
const NdbError err= dict->getNdbError();
- if (err.code != 709)
+ if (err.code != 709 && err.code != 723)
{
ERR_PRINT(err);
ret= ndb_to_mysql_error(&err);
@@ -4842,6 +4886,10 @@
DBUG_RETURN(ret);
}
+void ndbcluster_drop_database(char *path)
+{
+ ndbcluster_drop_database_impl(path);
+}
/*
find all tables in ndb and discover those needed
*/
@@ -5176,7 +5224,6 @@
(void) hash_init(&ndbcluster_open_tables,system_charset_info,32,0,0,
(hash_get_key) ndbcluster_get_key,0,0);
pthread_mutex_init(&ndbcluster_mutex,MY_MUTEX_INIT_FAST);
-
pthread_mutex_init(&LOCK_ndb_util_thread, MY_MUTEX_INIT_FAST);
pthread_cond_init(&COND_ndb_util_thread, NULL);
@@ -5214,7 +5261,7 @@
ndbcluster_init()
*/
-bool ndbcluster_end()
+int ndbcluster_end(ha_panic_function type)
{
DBUG_ENTER("ndbcluster_end");
@@ -8098,29 +8145,21 @@
/*
Implements the SHOW NDB STATUS command.
*/
-int
-ndbcluster_show_status(THD* thd)
+bool
+ndbcluster_show_status(THD* thd, stat_print_fn *stat_print,
+ enum ha_stat_type stat_type)
{
- Protocol *protocol= thd->protocol;
-
+ char buf[IO_SIZE];
DBUG_ENTER("ndbcluster_show_status");
if (have_ndbcluster != SHOW_OPTION_YES)
{
- my_message(ER_NOT_SUPPORTED_YET,
- "Cannot call SHOW NDBCLUSTER STATUS because skip-ndbcluster is defined",
- MYF(0));
- DBUG_RETURN(TRUE);
+ DBUG_RETURN(FALSE);
+ }
+ if (stat_type != HA_ENGINE_STATUS)
+ {
+ DBUG_RETURN(FALSE);
}
-
- List<Item> field_list;
- field_list.push_back(new Item_empty_string("free_list", 255));
- field_list.push_back(new Item_return_int("created", 10,MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("free", 10,MYSQL_TYPE_LONG));
- field_list.push_back(new Item_return_int("sizeof", 10,MYSQL_TYPE_LONG));
-
- if (protocol->send_fields(&field_list, Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
- DBUG_RETURN(TRUE);
if (get_thd_ndb(thd) && get_thd_ndb(thd)->ndb)
{
@@ -8128,14 +8167,11 @@
Ndb::Free_list_usage tmp; tmp.m_name= 0;
while (ndb->get_free_list_usage(&tmp))
{
- protocol->prepare_for_resend();
-
- protocol->store(tmp.m_name, &my_charset_bin);
- protocol->store((uint)tmp.m_created);
- protocol->store((uint)tmp.m_free);
- protocol->store((uint)tmp.m_sizeof);
- if (protocol->write())
- DBUG_RETURN(TRUE);
+ my_snprintf(buf, sizeof(buf),
+ "created=%u, free=%u, sizeof=%u",
+ tmp.m_created, tmp.m_free, tmp.m_sizeof);
+ if (stat_print(thd, ndbcluster_hton.name, tmp.m_name, buf))
+ DBUG_RETURN(TRUE);
}
}
send_eof(thd);
@@ -8322,7 +8358,6 @@
DBUG_VOID_RETURN;
}
-
bool ha_ndbcluster::check_if_incompatible_data(HA_CREATE_INFO *info,
uint table_changes)
{
@@ -8349,4 +8384,222 @@
return COMPATIBLE_DATA_YES;
}
-#endif /* HAVE_NDBCLUSTER_DB */
+#ifdef NDB_DISKDATA
+bool set_up_tablespace(st_alter_tablespace *info,
+ NdbDictionary::Tablespace *ndb_ts)
+{
+ ndb_ts->setName(info->tablespace_name);
+ ndb_ts->setExtentSize(info->extent_size);
+ ndb_ts->setDefaultLogfileGroup(info->logfile_group_name);
+ return false;
+}
+
+bool set_up_datafile(st_alter_tablespace *info,
+ NdbDictionary::Datafile *ndb_df)
+{
+ if (info->max_size > 0)
+ {
+ my_error(ER_TABLESPACE_AUTO_EXTEND_ERROR, MYF(0));
+ return true;
+ }
+ ndb_df->setPath(info->data_file_name);
+ ndb_df->setSize(info->initial_size);
+ ndb_df->setTablespace(info->tablespace_name);
+ return false;
+}
+
+bool set_up_logfile_group(st_alter_tablespace *info,
+ NdbDictionary::LogfileGroup *ndb_lg)
+{
+ ndb_lg->setName(info->logfile_group_name);
+ ndb_lg->setUndoBufferSize(info->undo_buffer_size);
+ return false;
+}
+
+bool set_up_undofile(st_alter_tablespace *info,
+ NdbDictionary::Undofile *ndb_uf)
+{
+ ndb_uf->setPath(info->undo_file_name);
+ ndb_uf->setSize(info->initial_size);
+ ndb_uf->setLogfileGroup(info->logfile_group_name);
+ return false;
+}
+
+int ha_ndbcluster::alter_tablespace(st_alter_tablespace *info)
+{
+ Ndb *ndb;
+ NDBDICT *dict;
+ int error;
+ DBUG_ENTER("ha_ndbcluster::alter_tablespace");
+ if (check_ndb_connection())
+ {
+ DBUG_RETURN(my_errno= HA_ERR_NO_CONNECTION);
+ }
+ ndb= get_ndb();
+ dict= ndb->getDictionary();
+ switch (info->ts_cmd_type){
+ case (CREATE_TABLESPACE):
+ {
+ NdbDictionary::Tablespace ndb_ts;
+ NdbDictionary::Datafile ndb_df;
+ if (set_up_tablespace(info, &ndb_ts))
+ {
+ DBUG_RETURN(1);
+ }
+ if (set_up_datafile(info, &ndb_df))
+ {
+ DBUG_RETURN(1);
+ }
+ if (error= dict->createTablespace(ndb_ts))
+ {
+ DBUG_PRINT("error", ("createTablespace returned %d", error));
+ my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "TABLESPACE");
+ DBUG_RETURN(1);
+ }
+ DBUG_PRINT("info", ("Successfully created Tablespace"));
+ if (error= dict->createDatafile(ndb_df))
+ {
+ DBUG_PRINT("error", ("createDatafile returned %d", error));
+ my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "DATAFILE");
+ DBUG_RETURN(1);
+ }
+ break;
+ }
+ case (ALTER_TABLESPACE):
+ {
+ if (info->ts_alter_tablespace_type == ALTER_TABLESPACE_ADD_FILE)
+ {
+ NdbDictionary::Datafile ndb_df;
+ if (set_up_datafile(info, &ndb_df))
+ {
+ DBUG_RETURN(1);
+ }
+ if (error= dict->createDatafile(ndb_df))
+ {
+ DBUG_PRINT("error", ("createDatafile returned %d", error));
+ my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), "CREATE DATAFILE");
+ DBUG_RETURN(1);
+ }
+ }
+ else if(info->ts_alter_tablespace_type == ALTER_TABLESPACE_DROP_FILE)
+ {
+ NdbDictionary::Datafile df = dict->getDatafile(0,
+ info->data_file_name);
+ if (strcmp(df.getPath(), info->data_file_name) == 0)
+ {
+ if (error= dict->dropDatafile(df))
+ {
+ DBUG_PRINT("error", ("createDatafile returned %d", error));
+ my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), " DROP DATAFILE");
+ DBUG_RETURN(1);
+ }
+ }
+ else
+ {
+ DBUG_PRINT("error", ("No such datafile"));
+ my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), " NO SUCH FILE");
+ DBUG_RETURN(1);
+ }
+ }
+ else
+ {
+ DBUG_PRINT("error", ("Unsupported alter tablespace: %d",
+ info->ts_alter_tablespace_type));
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ break;
+ }
+ case (CREATE_LOGFILE_GROUP):
+ {
+ NdbDictionary::LogfileGroup ndb_lg;
+ NdbDictionary::Undofile ndb_uf;
+ if (info->undo_file_name == NULL)
+ {
+ /*
+ REDO files in LOGFILE GROUP not supported yet
+ */
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ if (set_up_logfile_group(info, &ndb_lg))
+ {
+ DBUG_RETURN(1);
+ }
+ if (error= dict->createLogfileGroup(ndb_lg))
+ {
+ DBUG_PRINT("error", ("createLogfileGroup returned %d", error));
+ my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "LOGFILE GROUP");
+ DBUG_RETURN(1);
+ }
+ DBUG_PRINT("info", ("Successfully created Logfile Group"));
+ if (set_up_undofile(info, &ndb_uf))
+ {
+ DBUG_RETURN(1);
+ }
+ if (error= dict->createUndofile(ndb_uf))
+ {
+ DBUG_PRINT("error", ("createUndofile returned %d", error));
+ my_error(ER_CREATE_TABLESPACE_FAILED, MYF(0), "UNDOFILE");
+ DBUG_RETURN(1);
+ }
+ break;
+ }
+ case (ALTER_LOGFILE_GROUP):
+ {
+ if (info->undo_file_name == NULL)
+ {
+ /*
+ REDO files in LOGFILE GROUP not supported yet
+ */
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ NdbDictionary::Undofile ndb_uf;
+ if (set_up_undofile(info, &ndb_uf))
+ {
+ DBUG_RETURN(1);
+ }
+ if (error= dict->createUndofile(ndb_uf))
+ {
+ DBUG_PRINT("error", ("createUndofile returned %d", error));
+ my_error(ER_ALTER_TABLESPACE_FAILED, MYF(0), "CREATE UNDOFILE");
+ DBUG_RETURN(1);
+ }
+ break;
+ }
+ case (DROP_TABLESPACE):
+ {
+ if (error= dict->dropTablespace(
+ dict->getTablespace(info->tablespace_name)))
+ {
+ DBUG_PRINT("error", ("dropTablespace returned %d", error));
+ my_error(ER_DROP_TABLESPACE_FAILED, MYF(0), "TABLESPACE");
+ DBUG_RETURN(1);
+ }
+ break;
+ }
+ case (DROP_LOGFILE_GROUP):
+ {
+ if (error= dict->dropLogfileGroup(dict->getLogfileGroup(info->logfile_group_name)))
+ {
+ DBUG_PRINT("error", ("dropLogfileGroup returned %d", error));
+ my_error(ER_DROP_TABLESPACE_FAILED, MYF(0), "LOGFILE GROUP");
+ DBUG_RETURN(1);
+ }
+ break;
+ }
+ case (CHANGE_FILE_TABLESPACE):
+ {
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ case (ALTER_ACCESS_MODE_TABLESPACE):
+ {
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ default:
+ {
+ DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
+ }
+ }
+ DBUG_RETURN(FALSE);
+}
+
+#endif /* NDB_DISKDATA */
--- 1.97/sql/ha_ndbcluster.h 2005-11-07 11:57:34 +01:00
+++ 1.98/sql/ha_ndbcluster.h 2005-11-09 10:17:31 +01:00
@@ -25,7 +25,7 @@
#pragma interface /* gcc class implementation */
#endif
-#include <ndbapi/NdbApi.hpp>
+#include <NdbApi.hpp>
#include <ndbapi_limits.h>
class Ndb; // Forward declaration
@@ -145,7 +145,6 @@
NDB_FUNC_TYPE neg_fun;
};
-enum ndb_distribution { ND_KEYHASH= 0, ND_LINHASH= 1 };
/*
Define what functions can be negated in condition pushdown.
@@ -632,7 +631,7 @@
const char *tabname, bool global);
private:
- friend int ndbcluster_drop_database(const char *path);
+ friend int ndbcluster_drop_database_impl(const char *path);
int alter_table_name(const char *to);
static int delete_table(ha_ndbcluster *h, Ndb *ndb,
const char *path,
@@ -795,7 +794,7 @@
extern struct show_var_st ndb_status_variables[];
bool ndbcluster_init(void);
-bool ndbcluster_end(void);
+int ndbcluster_end(ha_panic_function flag);
int ndbcluster_discover(THD* thd, const char* dbname, const char* name,
const void** frmblob, uint* frmlen);
@@ -803,9 +802,9 @@
const char *wild, bool dir, List<char> *files);
int ndbcluster_table_exists_in_engine(THD* thd,
const char *db, const char *name);
-int ndbcluster_drop_database(const char* path);
+void ndbcluster_drop_database(char* path);
void ndbcluster_print_error(int error, const NdbOperation *error_op);
-int ndbcluster_show_status(THD*);
+bool ndbcluster_show_status(THD*,stat_print_fn *,enum ha_stat_type);
| Thread |
|---|
| • bk commit into 5.1 tree (mskold:1.1893) | Martin Skold | 9 Nov |