⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbdict.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 5 页
字号:
  tablePtr.p->noOfAttributes = ZNIL;  tablePtr.p->noOfNullAttr = 0;  tablePtr.p->frmLen = 0;  memset(tablePtr.p->frmData, 0, sizeof(tablePtr.p->frmData));  /*    tablePtr.p->lh3PageIndexBits = 0;    tablePtr.p->lh3DistrBits = 0;    tablePtr.p->lh3PageBits = 6;  */  tablePtr.p->kValue = 6;  tablePtr.p->localKeyLen = 1;  tablePtr.p->maxLoadFactor = 80;  tablePtr.p->minLoadFactor = 70;  tablePtr.p->noOfPrimkey = 1;  tablePtr.p->tupKeyLength = 1;  tablePtr.p->storedTable = true;  tablePtr.p->tableType = DictTabInfo::UserTable;  tablePtr.p->primaryTableId = RNIL;  // volatile elements  tablePtr.p->indexState = TableRecord::IS_UNDEFINED;  tablePtr.p->insertTriggerId = RNIL;  tablePtr.p->updateTriggerId = RNIL;  tablePtr.p->deleteTriggerId = RNIL;  tablePtr.p->customTriggerId = RNIL;  tablePtr.p->buildTriggerId = RNIL;  tablePtr.p->indexLocal = 0;}//Dbdict::initialiseTableRecord()void Dbdict::initTriggerRecords(){  TriggerRecordPtr triggerPtr;  while (1) {    jam();    refresh_watch_dog();    c_triggerRecordPool.seize(triggerPtr);    if (triggerPtr.i == RNIL) {      jam();      break;    }//if    initialiseTriggerRecord(triggerPtr);  }//while}void Dbdict::initialiseTriggerRecord(TriggerRecordPtr triggerPtr){  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;  triggerPtr.p->triggerActionTime = (TriggerActionTime::Value)~0;  triggerPtr.p->triggerEvent = (TriggerEvent::Value)~0;  triggerPtr.p->monitorReplicas = false;  triggerPtr.p->monitorAllAttributes = false;  triggerPtr.p->attributeMask.clear();  triggerPtr.p->indexId = RNIL;}Uint32 Dbdict::getFsConnRecord() {  FsConnectRecordPtr fsPtr;  c_fsConnectRecordPool.seize(fsPtr);  ndbrequire(fsPtr.i != RNIL);  fsPtr.p->filePtr = (Uint32)-1;  fsPtr.p->ownerPtr = RNIL;  fsPtr.p->fsState = FsConnectRecord::IDLE;  return fsPtr.i;}//Dbdict::getFsConnRecord()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) {    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) {    jam();    firstTablePtr.p->tabState = TableRecord::NOT_DEFINED;    return RNIL;  }//if#endif  return firstTablePtr.i;}//Dbdict::getFreeTableRecord()Uint32 Dbdict::getFreeTriggerRecord(){  const Uint32 size = c_triggerRecordPool.getSize();  TriggerRecordPtr triggerPtr;  for (triggerPtr.i = 0; triggerPtr.i < size; triggerPtr.i++) {    jam();    c_triggerRecordPool.getPtr(triggerPtr);    if (triggerPtr.p->triggerState == TriggerRecord::TS_NOT_DEFINED) {      jam();      initialiseTriggerRecord(triggerPtr);      return triggerPtr.i;    }  }  return RNIL;}boolDbdict::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 ------------------------ *//* ---------------------------------------------------------------- *//*                                                                  *//* This module contains the code that is common for all             *//* start/restart types.                                             *//* ---------------------------------------------------------------- *//* **************************************************************** *//* ---------------------------------------------------------------- */// This is sent as the first signal during start/restart./* ---------------------------------------------------------------- */void Dbdict::execSTTOR(Signal* signal) {  jamEntry();  c_startPhase = signal->theData[1];  switch (c_startPhase) {  case 1:    break;  case 3:    c_restartType = signal->theData[7];         /* valid if 3 */    ndbrequire(c_restartType == NodeState::ST_INITIAL_START ||               c_restartType == NodeState::ST_SYSTEM_RESTART ||               c_restartType == NodeState::ST_INITIAL_NODE_RESTART ||               c_restartType == NodeState::ST_NODE_RESTART);    break;  }  sendSTTORRY(signal);}//execSTTOR()void Dbdict::sendSTTORRY(Signal* signal){  signal->theData[0] = 0;       /* garbage SIGNAL KEY */  signal->theData[1] = 0;       /* garbage SIGNAL VERSION NUMBER  */  signal->theData[2] = 0;       /* garbage */  signal->theData[3] = 1;       /* first wanted start phase */  signal->theData[4] = 3;       /* get type of start */  signal->theData[5] = ZNOMOREPHASES;  sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 6, JBB);}/* ---------------------------------------------------------------- */// We receive information about sizes of records./* ---------------------------------------------------------------- */void Dbdict::execREAD_CONFIG_REQ(Signal* signal) {  const ReadConfigReq * req = (ReadConfigReq*)signal->getDataPtr();  Uint32 ref = req->senderRef;  Uint32 senderData = req->senderData;  ndbrequire(req->noOfParameters == 0);  jamEntry();   const ndb_mgm_configuration_iterator * p =     theConfiguration.getOwnConfigIterator();  ndbrequire(p != 0);    Uint32 attributesize, tablerecSize;  ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_ATTRIBUTE,&attributesize));  ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DICT_TABLE, &tablerecSize));  c_attributeRecordPool.setSize(attributesize);  c_attributeRecordHash.setSize(64);  c_fsConnectRecordPool.setSize(ZFS_CONNECT_SIZE);  c_nodes.setSize(MAX_NODES);  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_opRecordPool.setSize(256);   // XXX need config params  c_opCreateTable.setSize(8);  c_opDropTable.setSize(8);  c_opCreateIndex.setSize(8);  c_opCreateEvent.setSize(8);  c_opSubEvent.setSize(8);  c_opDropEvent.setSize(8);  c_opSignalUtil.setSize(8);  c_opDropIndex.setSize(8);  c_opAlterIndex.setSize(8);  c_opBuildIndex.setSize(8);  c_opCreateTrigger.setSize(8);  c_opDropTrigger.setSize(8);  c_opAlterTrigger.setSize(8);    // Initialize schema file copies  c_schemaFile[0].schemaPage =    (SchemaFile*)c_schemaPageRecordArray.getPtr(0 * NDB_SF_MAX_PAGES);  c_schemaFile[0].noOfPages = 0;  c_schemaFile[1].schemaPage =    (SchemaFile*)c_schemaPageRecordArray.getPtr(1 * NDB_SF_MAX_PAGES);  c_schemaFile[1].noOfPages = 0;  // Initialize BAT for interface to file system  NewVARIABLE* bat = allocateBat(2);  bat[0].WA = &c_schemaPageRecordArray.getPtr(0)->word[0];  bat[0].nrr = 2 * NDB_SF_MAX_PAGES;  bat[0].ClusterSize = NDB_SF_PAGE_SIZE;  bat[0].bits.q = NDB_SF_PAGE_SIZE_IN_WORDS_LOG2;  bat[0].bits.v = 5;  // 32 bits per element  bat[1].WA = &c_pageRecordArray.getPtr(0)->word[0];  bat[1].nrr = ZNUMBER_OF_PAGES;  bat[1].ClusterSize = ZSIZE_OF_PAGES_IN_WORDS * 4;  bat[1].bits.q = ZLOG_SIZE_OF_PAGES_IN_WORDS; // 2**13 = 8192 elements  bat[1].bits.v = 5;  // 32 bits per element  initCommonData();  initRecords();  ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend();  conf->senderRef = reference();  conf->senderData = senderData;  sendSignal(ref, GSN_READ_CONFIG_CONF, signal, 	     ReadConfigConf::SignalLength, JBB);}//execSIZEALT_REP()/* ---------------------------------------------------------------- */// Start phase signals sent by CNTR. We reply with NDB_STTORRY when// we completed this phase./* ---------------------------------------------------------------- */void Dbdict::execNDB_STTOR(Signal* signal) {  jamEntry();  c_startPhase = signal->theData[2];  const Uint32 restartType = signal->theData[3];  if (restartType == NodeState::ST_INITIAL_START) {    jam();    c_initialStart = true;  } else if (restartType == NodeState::ST_SYSTEM_RESTART) {    jam();    c_systemRestart = true;  } else if (restartType == NodeState::ST_INITIAL_NODE_RESTART) {    jam();    c_initialNodeRestart = true;  } else if (restartType == NodeState::ST_NODE_RESTART) {    jam();    c_nodeRestart = true;  } else {    ndbrequire(false);  }//if  switch (c_startPhase) {  case 1:    jam();    initSchemaFile(signal);    break;  case 3:    jam();    signal->theData[0] = reference();    sendSignal(NDBCNTR_REF, GSN_READ_NODESREQ, signal, 1, JBB);    break;  case 6:    jam();    c_initialStart = false;    c_systemRestart = false;    c_initialNodeRestart = false;    c_nodeRestart = false;    sendNDB_STTORRY(signal);    break;  case 7:    // uses c_restartType    if(restartType == NodeState::ST_SYSTEM_RESTART &&       c_masterNodeId == getOwnNodeId()){      rebuildIndexes(signal, 0);      return;    }    sendNDB_STTORRY(signal);    break;  default:    jam();    sendNDB_STTORRY(signal);    break;  }//switch}//execNDB_STTOR()void Dbdict::sendNDB_STTORRY(Signal* signal) {  signal->theData[0] = reference();  sendSignal(NDBCNTR_REF, GSN_NDB_STTORRY, signal, 1, JBB);  return;}//sendNDB_STTORRY()/* ---------------------------------------------------------------- */// We receive the information about which nodes that are up and down./* ---------------------------------------------------------------- */void Dbdict::execREAD_NODESCONF(Signal* signal) {  jamEntry();  ReadNodesConf * const readNodes = (ReadNodesConf *)&signal->theData[0];  c_numberNode   = readNodes->noOfNodes;  c_masterNodeId = readNodes->masterNodeId;  c_noNodesFailed = 0;  c_aliveNodes.clear();  for (unsigned i = 1; i < MAX_NDB_NODES; i++) {    jam();    NodeRecordPtr nodePtr;    c_nodes.getPtr(nodePtr, i);    if (NodeBitmask::get(readNodes->allNodes, i)) {      jam();      nodePtr.p->nodeState = NodeRecord::NDB_NODE_ALIVE;      if (NodeBitmask::get(readNodes->inactiveNodes, i)) {	jam();	/**-------------------------------------------------------------------	 *	 * THIS NODE IS DEFINED IN THE CLUSTER BUT IS NOT ALIVE CU

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -