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

📄 ndboperationdefine.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* Copyright (C) 2003 MySQL AB   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <ndb_global.h>#include <NdbOperation.hpp>#include "NdbApiSignal.hpp"#include <NdbTransaction.hpp>#include <Ndb.hpp>#include <NdbRecAttr.hpp>#include "NdbUtil.hpp"#include "NdbOut.hpp"#include "NdbImpl.hpp"#include <NdbIndexScanOperation.hpp>#include <NdbBlob.hpp>#include <Interpreter.hpp>#include <AttributeHeader.hpp>#include <signaldata/TcKeyReq.hpp>/***************************************************************************** * int insertTuple(); *****************************************************************************/intNdbOperation::insertTuple(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    theOperationType = InsertRequest;    tNdbCon->theSimpleState = 0;    theErrorLine = tErrorLine++;    theLockMode = LM_Exclusive;    return 0;   } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::insertTuple()/****************************************************************************** * int updateTuple(); *****************************************************************************/intNdbOperation::updateTuple(){    NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = UpdateRequest;      theErrorLine = tErrorLine++;    theLockMode = LM_Exclusive;    return 0;   } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::updateTuple()/***************************************************************************** * int writeTuple(); *****************************************************************************/intNdbOperation::writeTuple(){    NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = WriteRequest;      theErrorLine = tErrorLine++;    theLockMode = LM_Exclusive;    return 0;   } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::writeTuple()/****************************************************************************** * int readTuple(); *****************************************************************************/intNdbOperation::readTuple(NdbOperation::LockMode lm){   switch(lm) {  case LM_Read:    return readTuple();    break;  case LM_Exclusive:    return readTupleExclusive();    break;  case LM_CommittedRead:    return committedRead();    break;  default:    return -1;  };}/****************************************************************************** * int readTuple(); *****************************************************************************/intNdbOperation::readTuple(){   NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = ReadRequest;    theErrorLine = tErrorLine++;    theLockMode = LM_Read;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::readTuple()/***************************************************************************** * int deleteTuple(); *****************************************************************************/intNdbOperation::deleteTuple(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;      tNdbCon->theSimpleState = 0;    theOperationType = DeleteRequest;    theErrorLine = tErrorLine++;    theLockMode = LM_Exclusive;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::deleteTuple()/****************************************************************************** * int readTupleExclusive(); *****************************************************************************/intNdbOperation::readTupleExclusive(){   NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = ReadExclusive;    theErrorLine = tErrorLine++;    theLockMode = LM_Exclusive;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::readTupleExclusive()/***************************************************************************** * int simpleRead(); *****************************************************************************/intNdbOperation::simpleRead(){  /**   * Currently/still disabled   */  return readTuple();#if 0  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    theOperationType = ReadRequest;    theSimpleIndicator = 1;    theErrorLine = tErrorLine++;    theLockMode = LM_Read;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if#endif}//NdbOperation::simpleRead()/***************************************************************************** * int dirtyRead(); *****************************************************************************/intNdbOperation::dirtyRead(){  return committedRead();}//NdbOperation::dirtyRead()/***************************************************************************** * int committedRead(); *****************************************************************************/intNdbOperation::committedRead(){  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    theOperationType = ReadRequest;    theSimpleIndicator = 1;    theDirtyIndicator = 1;    theErrorLine = tErrorLine++;    theLockMode = LM_CommittedRead;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::committedRead()/***************************************************************************** * int dirtyUpdate(); ****************************************************************************/intNdbOperation::dirtyUpdate(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    theOperationType = UpdateRequest;    tNdbCon->theSimpleState = 0;    theSimpleIndicator = 1;    theDirtyIndicator = 1;    theErrorLine = tErrorLine++;    theLockMode = LM_CommittedRead;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::dirtyUpdate()/****************************************************************************** * int dirtyWrite(); *****************************************************************************/intNdbOperation::dirtyWrite(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    theOperationType = WriteRequest;    tNdbCon->theSimpleState = 0;    theSimpleIndicator = 1;    theDirtyIndicator = 1;    theErrorLine = tErrorLine++;    theLockMode = LM_CommittedRead;    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::dirtyWrite()/****************************************************************************** * int interpretedUpdateTuple(); ****************************************************************************/intNdbOperation::interpretedUpdateTuple(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = UpdateRequest;    theAI_LenInCurrAI = 25;    theLockMode = LM_Exclusive;    theErrorLine = tErrorLine++;    initInterpreter();    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::interpretedUpdateTuple()/***************************************************************************** * int interpretedDeleteTuple(); *****************************************************************************/intNdbOperation::interpretedDeleteTuple(){  NdbTransaction* tNdbCon = theNdbCon;  int tErrorLine = theErrorLine;  if (theStatus == Init) {    theStatus = OperationDefined;    tNdbCon->theSimpleState = 0;    theOperationType = DeleteRequest;    theErrorLine = tErrorLine++;    theAI_LenInCurrAI = 25;    theLockMode = LM_Exclusive;    initInterpreter();    return 0;  } else {    setErrorCode(4200);    return -1;  }//if}//NdbOperation::interpretedDeleteTuple()/****************************************************************************** * int getValue(AttrInfo* tAttrInfo, char* aRef ) * * Return Value   Return 0 : GetValue was successful. *                Return -1: In all other case.  * Parameters:    tAttrInfo : Attribute object of the retrieved attribute  *                            value. * Remark:        Define an attribute to retrieve in query. *****************************************************************************/NdbRecAttr*NdbOperation::getValue_impl(const NdbColumnImpl* tAttrInfo, char* aValue){  NdbRecAttr* tRecAttr;  if ((tAttrInfo != NULL) &&      (theStatus != Init)){    if (theStatus != GetValue) {      if (theInterpretIndicator == 1) {	if (theStatus == FinalGetValue) {	  ; // Simply continue with getValue	} else if (theStatus == ExecInterpretedValue) {	  if (insertATTRINFO(Interpreter::EXIT_OK) == -1)	    return NULL;	  theInterpretedSize = theTotalCurrAI_Len -	    (theInitialReadSize + 5);	} else if (theStatus == SetValueInterpreted) {	  theFinalUpdateSize = theTotalCurrAI_Len - 	    (theInitialReadSize + theInterpretedSize + 5);	} else {	  setErrorCodeAbort(4230);	  return NULL;	}//if	// MASV - How would execution come here?	theStatus = FinalGetValue;      } else {	setErrorCodeAbort(4230);

⌨️ 快捷键说明

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