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

📄 dbaccmain.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* --------------------------------------------------------------------------------- *//* ******************--------------------------------------------------------------- *//* ACCSEIZEREQ                                           SEIZE REQ                   *//*                                                    SENDER: LQH,    LEVEL B        *//*          ENTER ACCSEIZEREQ WITH                                                   *//*                    TUSERPTR ,                     CONECTION PTR OF LQH            *//*                    TUSERBLOCKREF                  BLOCK REFERENCE OF LQH          *//* ******************--------------------------------------------------------------- *//* ******************--------------------------------------------------------------- *//* ACCSEIZEREQ                                           SEIZE REQ                   *//* ******************------------------------------+                                 *//*   SENDER: LQH,    LEVEL B       */void Dbacc::execACCSEIZEREQ(Signal* signal) {  jamEntry();  tuserptr = signal->theData[0];  /* CONECTION PTR OF LQH            */  tuserblockref = signal->theData[1];  /* BLOCK REFERENCE OF LQH          */  tresult = 0;  if (cfreeopRec == RNIL) {    jam();    refaccConnectLab(signal);    return;  }//if  seizeOpRec(signal);  ptrGuard(operationRecPtr);  operationRecPtr.p->userptr = tuserptr;  operationRecPtr.p->userblockref = tuserblockref;  operationRecPtr.p->operation = ZUNDEFINED_OP;  operationRecPtr.p->transactionstate = IDLE;  /* ******************************< */  /* ACCSEIZECONF                    */  /* ******************************< */  signal->theData[0] = tuserptr;  signal->theData[1] = operationRecPtr.i;  sendSignal(tuserblockref, GSN_ACCSEIZECONF, signal, 2, JBB);  return;}//Dbacc::execACCSEIZEREQ()void Dbacc::refaccConnectLab(Signal* signal) {  tresult = ZCONNECT_SIZE_ERROR;  /* ******************************< */  /* ACCSEIZEREF                     */  /* ******************************< */  signal->theData[0] = tuserptr;  signal->theData[1] = tresult;  sendSignal(tuserblockref, GSN_ACCSEIZEREF, signal, 2, JBB);  return;}//Dbacc::refaccConnectLab()/* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//*                                                                                   *//*       END OF CONNECTION MODULE                                                    *//*                                                                                   *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//*                                                                                   *//*       EXECUTE OPERATION MODULE                                                    *//*                                                                                   *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* --------------------------------------------------------------------------------- *//* INIT_OP_REC                                                                       *//*           INFORMATION WHICH IS RECIEVED BY ACCKEYREQ WILL BE SAVED                *//*           IN THE OPERATION RECORD.                                                *//* --------------------------------------------------------------------------------- */void Dbacc::initOpRec(Signal* signal) {  register Uint32 Treqinfo;  Treqinfo = signal->theData[2];  operationRecPtr.p->hashValue = signal->theData[3];  operationRecPtr.p->tupkeylen = signal->theData[4];  operationRecPtr.p->xfrmtupkeylen = signal->theData[4];  operationRecPtr.p->transId1 = signal->theData[5];  operationRecPtr.p->transId2 = signal->theData[6];  operationRecPtr.p->transactionstate = ACTIVE;  operationRecPtr.p->commitDeleteCheckFlag = ZFALSE;  operationRecPtr.p->operation = Treqinfo & 0x7;  /* --------------------------------------------------------------------------------- */  // opSimple is not used in this version. Is needed for deadlock handling later on.  /* --------------------------------------------------------------------------------- */  //  operationRecPtr.p->opSimple = (Treqinfo >> 3) & 0x1;   operationRecPtr.p->lockMode = (Treqinfo >> 4) & 0x3;  Uint32 readFlag = (((Treqinfo >> 4) & 0x3) == 0);      // Only 1 if Read  Uint32 dirtyFlag = (((Treqinfo >> 6) & 0x1) == 1);     // Only 1 if Dirty  Uint32 dirtyReadFlag = readFlag & dirtyFlag;  operationRecPtr.p->dirtyRead = dirtyReadFlag;  operationRecPtr.p->nodeType = (Treqinfo >> 7) & 0x3;  operationRecPtr.p->fid = fragrecptr.p->myfid;  operationRecPtr.p->fragptr = fragrecptr.i;  operationRecPtr.p->nextParallelQue = RNIL;  operationRecPtr.p->prevParallelQue = RNIL;  operationRecPtr.p->prevQueOp = RNIL;  operationRecPtr.p->nextQueOp = RNIL;  operationRecPtr.p->nextSerialQue = RNIL;  operationRecPtr.p->prevSerialQue = RNIL;  operationRecPtr.p->elementPage = RNIL;  operationRecPtr.p->keyinfoPage = RNIL;  operationRecPtr.p->lockOwner = ZFALSE;  operationRecPtr.p->insertIsDone = ZFALSE;  operationRecPtr.p->elementIsDisappeared = ZFALSE;  operationRecPtr.p->insertDeleteLen = fragrecptr.p->elementLength;  operationRecPtr.p->longPagePtr = RNIL;  operationRecPtr.p->longKeyPageIndex = RNIL;  operationRecPtr.p->scanRecPtr = RNIL;  // bit to mark lock operation  operationRecPtr.p->isAccLockReq = (Treqinfo >> 31) & 0x1;  // undo log is not run via ACCKEYREQ  operationRecPtr.p->isUndoLogReq = 0;}//Dbacc::initOpRec()/* --------------------------------------------------------------------------------- *//* SEND_ACCKEYCONF                                                                   *//* --------------------------------------------------------------------------------- */void Dbacc::sendAcckeyconf(Signal* signal) {  signal->theData[0] = operationRecPtr.p->userptr;  signal->theData[1] = operationRecPtr.p->operation;  signal->theData[2] = operationRecPtr.p->fid;  signal->theData[3] = operationRecPtr.p->localdata[0];  signal->theData[4] = operationRecPtr.p->localdata[1];  signal->theData[5] = fragrecptr.p->localkeylen;}//Dbacc::sendAcckeyconf()void Dbacc::ACCKEY_error(Uint32 fromWhere){  switch(fromWhere) {  case 0:    ndbrequire(false);  case 1:    ndbrequire(false);  case 2:    ndbrequire(false);  case 3:    ndbrequire(false);  case 4:    ndbrequire(false);  case 5:    ndbrequire(false);  case 6:    ndbrequire(false);  case 7:    ndbrequire(false);  case 8:    ndbrequire(false);  case 9:    ndbrequire(false);  default:    ndbrequire(false);  }//switch}//Dbacc::ACCKEY_error()/* ******************--------------------------------------------------------------- *//* ACCKEYREQ                                         REQUEST FOR INSERT, DELETE,     *//*                                                   RERAD AND UPDATE, A TUPLE.      *//*                                                   SENDER: LQH,    LEVEL B         *//*  SIGNAL DATA:      OPERATION_REC_PTR,             CONNECTION PTR                  *//*                    TABPTR,                        TABLE ID = TABLE RECORD POINTER *//*                    TREQINFO,                                                      *//*                    THASHVALUE,                    HASH VALUE OF THE TUP           *//*                    TKEYLEN,                       LENGTH OF THE PRIMARY KEYS      *//*                    TKEY1,                         PRIMARY KEY 1                   *//*                    TKEY2,                         PRIMARY KEY 2                   *//*                    TKEY3,                         PRIMARY KEY 3                   *//*                    TKEY4,                         PRIMARY KEY 4                   *//* ******************--------------------------------------------------------------- */void Dbacc::execACCKEYREQ(Signal* signal) {  jamEntry();  operationRecPtr.i = signal->theData[0];   /* CONNECTION PTR */  fragrecptr.i = signal->theData[1];        /* FRAGMENT RECORD POINTER         */  if (!((operationRecPtr.i < coprecsize) ||	(fragrecptr.i < cfragmentsize))) {    ACCKEY_error(0);    return;  }//if  ptrAss(operationRecPtr, operationrec);  ptrAss(fragrecptr, fragmentrec);    ndbrequire(operationRecPtr.p->transactionstate == IDLE);  initOpRec(signal);  // normalize key if any char attr  if (! operationRecPtr.p->isAccLockReq && fragrecptr.p->hasCharAttr)    xfrmKeyData(signal);  /*---------------------------------------------------------------*/  /*                                                               */  /*       WE WILL USE THE HASH VALUE TO LOOK UP THE PROPER MEMORY */  /*       PAGE AND MEMORY PAGE INDEX TO START THE SEARCH WITHIN.  */  /*       WE REMEMBER THESE ADDRESS IF WE LATER NEED TO INSERT    */  /*       THE ITEM AFTER NOT FINDING THE ITEM.                    */  /*---------------------------------------------------------------*/  getElement(signal);    if (tgeResult == ZTRUE) {    switch (operationRecPtr.p->operation) {    case ZREAD:    case ZUPDATE:    case ZDELETE:    case ZWRITE:    case ZSCAN_OP:      if (!tgeLocked){	if(operationRecPtr.p->operation == ZWRITE)	{	  jam();	  operationRecPtr.p->operation = ZUPDATE;	}        sendAcckeyconf(signal);        if (operationRecPtr.p->dirtyRead == ZFALSE) {	  /*---------------------------------------------------------------*/	  // It is not a dirty read. We proceed by locking and continue with	  // the operation.	  /*---------------------------------------------------------------*/          Uint32 eh = gePageptr.p->word32[tgeElementptr];          operationRecPtr.p->scanBits = ElementHeader::getScanBits(eh);          operationRecPtr.p->hashvaluePart = ElementHeader::getHashValuePart(eh);          operationRecPtr.p->elementPage = gePageptr.i;          operationRecPtr.p->elementContainer = tgeContainerptr;          operationRecPtr.p->elementPointer = tgeElementptr;          operationRecPtr.p->elementIsforward = tgeForward;	  eh = ElementHeader::setLocked(operationRecPtr.i);          dbgWord32(gePageptr, tgeElementptr, eh);          gePageptr.p->word32[tgeElementptr] = eh;	  	  insertLockOwnersList(signal , operationRecPtr);          return;        } else {          jam();	  /*---------------------------------------------------------------*/	  // It is a dirty read. We do not lock anything. Set state to	  // IDLE since no COMMIT call will come.	  /*---------------------------------------------------------------*/          operationRecPtr.p->transactionstate = IDLE;          operationRecPtr.p->operation = ZUNDEFINED_OP;          return;        }//if      } else {        jam();        accIsLockedLab(signal);        return;      }//if      break;    case ZINSERT:      jam();      insertExistElemLab(signal);      return;      break;    default:      ndbrequire(false);      break;    }//switch  } else if (tgeResult == ZFALSE) {    switch (operationRecPtr.p->operation) {    case ZINSERT:    case ZWRITE:      jam();      // If a write operation makes an insert we switch operation to ZINSERT so      // that the commit-method knows an insert has been made and updates noOfElements.      operationRecPtr.p->operation = ZINSERT;      operationRecPtr.p->insertIsDone = ZTRUE;      insertelementLab(signal);      return;      break;    case ZREAD:    case ZUPDATE:    case ZDELETE:    case ZSCAN_OP:      jam();      acckeyref1Lab(signal, ZREAD_ERROR);      return;      break;    default:      ndbrequire(false);      break;    }//switch  } else {    jam();    acckeyref1Lab(signal, tgeResult);    return;  }//if  return;}//Dbacc::execACCKEYREQ()voidDbacc::xfrmKeyData(Signal* signal){  Uint32 table = fragrecptr.p->myTableId;  Uint32 dst[MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY];  Uint32 keyPartLen[MAX_ATTRIBUTES_IN_INDEX];  Uint32* src = &signal->theData[7];  Uint32 len = xfrm_key(table, src, dst, sizeof(dst) >> 2, keyPartLen);  ndbrequire(len); // 0 means error  memcpy(src, dst, len << 2);  operationRecPtr.p->xfrmtupkeylen = len;}void Dbacc::accIsLockedLab(Signal* signal) {  ndbrequire(csystemRestart == ZFALSE);  queOperPtr.i = ElementHeader::getOpPtrI(gePageptr.p->word32[tgeElementptr]);  ptrCheckGuard(queOperPtr, coprecsize, operationrec);  if (operationRecPtr.p->dirtyRead == ZFALSE) {    Uint32 return_result;    if (operationRecPtr.p->lockMode == ZREADLOCK) {      jam();      priPageptr = gePageptr;      tpriElementptr = tgeElementptr;      return_result = placeReadInLockQueue(signal);    } else {      jam();      pwiPageptr = gePageptr;      tpwiElementptr = tgeElementptr;      return_result = placeWriteInLockQueue(signal);    }//if    if (return_result == ZPARALLEL_QUEUE) {      jam();      sendAcckeyconf(signal);      return;    } else if (return_result == ZSERIAL_QUEUE) {      jam();      signal->theData[0] = RNIL;      return;    } else if (return_result == ZWRITE_ERROR) {      jam();      acckeyref1Lab(signal, return_result);      return;    }//if    ndbrequire(false);  } else {    if (queOperPtr.p->elementIsDisappeared == ZFALSE) {      jam();      /*---------------------------------------------------------------*/      // It is a dirty read. We do not lock anything. Set state to      // IDLE since no COMMIT call will arrive.      /*---------------------------------------------------------------*/      sendAcckeyconf(signal);      operationRecPtr.p->transactionstate = IDLE;      operationRecPtr.p->operation = ZUNDEFINED_OP;      return;    } else {      jam();      /*---------------------------------------------------------------*/      // The tuple does not exist in the committed world currently.      // Report read error.      /*---------------------------------------------------------------*/      acckeyref1Lab(signal, ZREAD_ERR

⌨️ 快捷键说明

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