📄 ndboperationint.cpp
字号:
/* 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 "Interpreter.hpp"#include <NdbIndexScanOperation.hpp>#ifdef VM_TRACE#include <NdbEnv.h>#define INT_DEBUG(x) \ { const char* tmp = NdbEnv_GetEnv("INT_DEBUG", (char*)0, 0); \ if (tmp != 0 && strlen(tmp) != 0) { ndbout << "INT:"; ndbout_c x; } }#else#define INT_DEBUG(x)#endifvoidNdbOperation::initInterpreter(){ theFirstLabel = NULL; theLastLabel = NULL; theFirstBranch = NULL; theLastBranch = NULL; theFirstCall = NULL; theLastCall = NULL; theFirstSubroutine = NULL; theLastSubroutine = NULL; theNoOfLabels = 0; theNoOfSubroutines = 0; theSubroutineSize = 0; theInitialReadSize = 0; theInterpretedSize = 0; theFinalUpdateSize = 0; theFinalReadSize = 0; theInterpretIndicator = 1; theTotalCurrAI_Len = 5;}intNdbOperation::incCheck(const NdbColumnImpl* tNdbColumnImpl){ if ((theInterpretIndicator == 1)) { if ((tNdbColumnImpl == NULL) || (theOperationType == OpenScanRequest || theOperationType == OpenRangeScanRequest)) goto inc_check_error1; if ((tNdbColumnImpl->getInterpretableType() != true) || (tNdbColumnImpl->m_pk != false) || (tNdbColumnImpl->m_nullable)) goto inc_check_error2; if (theStatus == ExecInterpretedValue) { ; // Simply continue with interpretation } else if (theStatus == GetValue) { theInitialReadSize = theTotalCurrAI_Len - 5; theStatus = ExecInterpretedValue; } else if (theStatus == SubroutineExec) { ; // Simply continue with interpretation } else { setErrorCodeAbort(4231); return -1; } return tNdbColumnImpl->m_attrId; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1; inc_check_error1: if (theOperationType == OpenScanRequest || theOperationType == OpenRangeScanRequest) { setErrorCodeAbort(4228); return -1; } setErrorCodeAbort(4004); return -1; inc_check_error2: if (tNdbColumnImpl->m_pk){ setErrorCodeAbort(4202); return -1; }//if if (!tNdbColumnImpl->getInterpretableType()){ setErrorCodeAbort(4217); return -1; }//if if (tNdbColumnImpl->m_nullable){ setErrorCodeAbort(4218); return -1; }//if setErrorCodeAbort(4219); return -1;}intNdbOperation::write_attrCheck(const NdbColumnImpl* tNdbColumnImpl){ if ((theInterpretIndicator == 1)) { if ((tNdbColumnImpl == NULL) || (theOperationType == OpenScanRequest || theOperationType == OpenRangeScanRequest)) goto write_attr_check_error1; if ((tNdbColumnImpl->getInterpretableType() == false) || (tNdbColumnImpl->m_pk)) goto write_attr_check_error2; if (theStatus == ExecInterpretedValue) { ; // Simply continue with interpretation } else if (theStatus == SubroutineExec) { ; // Simply continue with interpretation } else { setErrorCodeAbort(4231); return -1; } return tNdbColumnImpl->m_attrId; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1;write_attr_check_error1: if (theOperationType == OpenScanRequest || theOperationType == OpenRangeScanRequest) { setErrorCodeAbort(4228); return -1; } setErrorCodeAbort(4004); return -1;write_attr_check_error2: if (tNdbColumnImpl->m_pk) { setErrorCodeAbort(4202); return -1; }//if if (tNdbColumnImpl->getInterpretableType() == false){ setErrorCodeAbort(4217); return -1; }//if setErrorCodeAbort(4219); return -1;}intNdbOperation::read_attrCheck(const NdbColumnImpl* tNdbColumnImpl){ if ((theInterpretIndicator == 1)) { if (tNdbColumnImpl == NULL) goto read_attr_check_error1; if (tNdbColumnImpl->getInterpretableType() == false) goto read_attr_check_error2; if (theStatus == ExecInterpretedValue) { ; // Simply continue with interpretation } else if (theStatus == GetValue) { theInitialReadSize = theTotalCurrAI_Len - 5; theStatus = ExecInterpretedValue; } else if (theStatus == SubroutineExec) { ; // Simply continue with interpretation } else { setErrorCodeAbort(4231); return -1; } return tNdbColumnImpl->m_attrId; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1; read_attr_check_error1: setErrorCodeAbort(4004); return -1; read_attr_check_error2: if (tNdbColumnImpl->getInterpretableType() == false) setErrorCodeAbort(4217); else setErrorCodeAbort(4219); return -1;}intNdbOperation::initial_interpreterCheck(){ if ((theInterpretIndicator == 1)) { if (theStatus == ExecInterpretedValue) { return 0; // Simply continue with interpretation } else if (theStatus == GetValue) { theInitialReadSize = theTotalCurrAI_Len - 5; theStatus = ExecInterpretedValue; return 0; } else if (theStatus == SubroutineExec) { return 0; // Simply continue with interpretation } else { setErrorCodeAbort(4231); return -1; } return 0; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1;}intNdbOperation::labelCheck(){ if ((theInterpretIndicator == 1)) { if (theStatus == ExecInterpretedValue) { return 0; // Simply continue with interpretation } else if (theStatus == GetValue) { theInitialReadSize = theTotalCurrAI_Len - 5; theStatus = ExecInterpretedValue; return 0; } else if (theStatus == SubroutineExec) { return 0; // Simply continue with interpretation } else if (theStatus == SubroutineEnd) { theStatus = SubroutineExec; } else { setErrorCodeAbort(4231); return -1; } return 0; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1;}intNdbOperation::intermediate_interpreterCheck(){ if ((theInterpretIndicator == 1)) { if (theStatus == ExecInterpretedValue) { return 0; // Simply continue with interpretation } else if (theStatus == SubroutineExec) { return 0; // Simply continue with interpretation } else { setErrorCodeAbort(4231); return -1; } return 0; } else { if (theNdbCon->theCommitStatus == NdbTransaction::Started) setErrorCodeAbort(4200); } return -1;}/***************************************************************************** * int incValue(const char* anAttrName, char* aValue, Uint32 aValue) * * Return Value: Return 0 : incValue was succesful. * Return -1: In all other case. * Parameters: anAttrName : Attribute name where the attribute value * will be save. * aValue : The constant to increment the attribute value with. *****************************************************************************/intNdbOperation::incValue(const NdbColumnImpl* tNdbColumnImpl, Uint32 aValue){ INT_DEBUG(("incValue32 %d %u", tNdbColumnImpl->m_attrId, aValue)); int tAttrId; tAttrId = incCheck(tNdbColumnImpl); if (tAttrId == -1) goto incValue_error1;// Load Attribute into register 6 if (insertATTRINFO( Interpreter::Read(tAttrId, 6)) == -1) goto incValue_error1;// Load aValue into register 7 if (aValue < 65536) { if (insertATTRINFO(Interpreter::LoadConst16(7, aValue)) == -1) goto incValue_error1; } else { if (insertATTRINFO(Interpreter::LoadConst32(7)) == -1) goto incValue_error1; if (insertATTRINFO(aValue) == -1) goto incValue_error1; } // Add register 6 and 7 and put result in register 7 if (insertATTRINFO( Interpreter::Add(7, 6, 7)) == -1) goto incValue_error1; if (insertATTRINFO( Interpreter::Write(tAttrId, 7)) == -1) goto incValue_error1; theErrorLine++; return 0;incValue_error1: return -1;}/***************************************************************************** * int subValue(const char* anAttrName, char* aValue, Uint32 aValue) * * Return Value: Return 0 : incValue was succesful. * Return -1: In all other case. * Parameters: anAttrName : Attribute name where the attribute value * will be save. * aValue : The constant to increment the attribute value with. ******************************************************************************/intNdbOperation::subValue(const NdbColumnImpl* tNdbColumnImpl, Uint32 aValue){ INT_DEBUG(("subValue32 %d %u", tNdbColumnImpl->m_attrId, aValue)); int tAttrId; tAttrId = incCheck(tNdbColumnImpl); if (tAttrId == -1) goto subValue_error1;// Load Attribute into register 6 if (insertATTRINFO( Interpreter::Read(tAttrId, 6)) == -1) goto subValue_error1;// Load aValue into register 7 if (aValue < 65536) { if (insertATTRINFO( Interpreter::LoadConst16(7, aValue)) == -1) goto subValue_error1; } else { if (insertATTRINFO( Interpreter::LoadConst32(7)) == -1) goto subValue_error1; if (insertATTRINFO(aValue) == -1) goto subValue_error1; } // Subtract register 6 and 7 and put result in register 7 if (insertATTRINFO( Interpreter::Sub(7, 6, 7)) == -1) goto subValue_error1; if (insertATTRINFO( Interpreter::Write(tAttrId, 7)) == -1) goto subValue_error1; theErrorLine++; return 0; subValue_error1: return -1;}/****************************************************************************** * int incValue(const char* anAttrName, char* aValue, Uint64 aValue) * * Return Value: Return 0 : incValue was succesful. * Return -1: In all other case. * Parameters: anAttrName : Attribute name where the attribute value will * be save. * aValue : The constant to increment the attribute value with. *****************************************************************************/intNdbOperation::incValue(const NdbColumnImpl* tNdbColumnImpl, Uint64 aValue){ INT_DEBUG(("incValue64 %d %llu", tNdbColumnImpl->m_attrId, aValue)); int tAttrId; tAttrId = incCheck(tNdbColumnImpl); if (tAttrId == -1) goto incValue_error1;// Load Attribute into register 6
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -