18 #include <ndb_global.h>
21 #include "Interpreter.hpp"
22 #include <AttributeHeader.hpp>
23 #include <signaldata/TcKeyReq.hpp>
24 #include <signaldata/TcKeyRef.hpp>
25 #include <signaldata/KeyInfo.hpp>
26 #include <signaldata/AttrInfo.hpp>
27 #include <signaldata/ScanTab.hpp>
29 #include <ndb_version.h>
52 STATIC_CONST(KeyAndAttrInfoHeaderLength = 3);
54 const Uint32 firstSigDataLen;
62 void checkStaticAssertions()
64 STATIC_ASSERT(KeyInfo::HeaderLength == KeyAndAttrInfoHeaderLength);
65 STATIC_ASSERT(AttrInfo::HeaderLength == KeyAndAttrInfoHeaderLength);
73 firstSigDataLen(dataLen),
74 firstDataPtr(TCREQ->getDataPtrSend()+dataOffset),
75 secondSignal(nextSignal),
76 currentPos(firstDataPtr)
78 assert((dataOffset + dataLen) <= NdbApiSignal::MaxSignalWords);
86 currentPos= firstDataPtr;
89 const Uint32* getNextWords(Uint32& sz)
96 if (likely(currentPos != NULL))
98 if (currentPos == firstDataPtr)
100 currentPos= secondSignal;
108 assert(sig->getLength() >= KeyAndAttrInfoHeaderLength);
109 sz= sig->getLength() - KeyAndAttrInfoHeaderLength;
110 currentPos= sig->next();
111 return sig->getDataPtrSend() + KeyAndAttrInfoHeaderLength;
119 NdbOperation::setLastFlag(
NdbApiSignal* signal, Uint32 lastFlag)
122 TcKeyReq::setExecuteFlag(req->requestInfo, lastFlag);
126 NdbOperation::doSendKeyReq(
int aNodeId,
138 NdbImpl* impl = theNdb->theImpl;
139 Uint32 tcNodeVersion = impl->getNodeNdbVersion(aNodeId);
140 bool forceShort = impl->forceShortRequests;
141 bool sendLong = ( tcNodeVersion >= NDBD_LONG_TCKEYREQ ) &&
146 return impl->sendSignal(request, aNodeId, secs, numSecs);
154 Uint32 keyInfoLen = secs[0].sz;
155 Uint32 attrInfoLen = (numSecs == 2)?
159 Uint32 keyInfoInReq = MIN(keyInfoLen, TcKeyReq::MaxKeyInfo);
160 Uint32 attrInfoInReq = MIN(attrInfoLen, TcKeyReq::MaxAttrInfo);
162 Uint32 connectPtr = tcKeyReq->apiConnectPtr;
163 Uint32 transId1 = tcKeyReq->transId1;
164 Uint32 transId2 = tcKeyReq->transId2;
165 bool indexReq = (request->theVerId_signalNumber == GSN_TCINDXREQ);
167 Uint32 reqLen = request->theLength;
170 TcKeyReq::setKeyLength(tcKeyReq->requestInfo, keyInfoLen);
171 TcKeyReq::setAIInTcKeyReq(tcKeyReq->requestInfo , attrInfoInReq);
172 TcKeyReq::setAttrinfoLen(tcKeyReq->attrLen, attrInfoLen);
174 Uint32* writePtr = request->getDataPtrSend() + reqLen;
176 GSIReader keyInfoReader(secs[0].sectionIter);
177 GSIReader attrInfoReader(secs[1].sectionIter);
179 keyInfoReader.copyNWords(writePtr, keyInfoInReq);
180 writePtr += keyInfoInReq;
181 attrInfoReader.copyNWords(writePtr, attrInfoInReq);
183 reqLen += keyInfoInReq + attrInfoInReq;
184 assert( reqLen <= TcKeyReq::SignalLength );
186 request->setLength(reqLen);
188 if (impl->sendSignal(request, aNodeId) == -1)
191 keyInfoLen -= keyInfoInReq;
192 attrInfoLen -= attrInfoInReq;
196 request->theVerId_signalNumber = indexReq ?
197 GSN_INDXKEYINFO : GSN_KEYINFO;
199 keyInfo->connectPtr = connectPtr;
200 keyInfo->transId[0] = transId1;
201 keyInfo->transId[1] = transId2;
205 Uint32 dataWords = MIN(keyInfoLen, KeyInfo::DataLength);
207 keyInfoReader.copyNWords(&keyInfo->keyData[0], dataWords);
208 request->setLength(KeyInfo::HeaderLength + dataWords);
210 if (impl->sendSignal(request, aNodeId) == -1)
213 keyInfoLen-= dataWords;
220 request->theVerId_signalNumber = indexReq ?
221 GSN_INDXATTRINFO : GSN_ATTRINFO;
223 attrInfo->connectPtr = connectPtr;
224 attrInfo->transId[0] = transId1;
225 attrInfo->transId[1] = transId2;
229 Uint32 dataWords = MIN(attrInfoLen, AttrInfo::DataLength);
231 attrInfoReader.copyNWords(&attrInfo->attrData[0], dataWords);
232 request->setLength(AttrInfo::HeaderLength + dataWords);
234 if (impl->sendSignal(request, aNodeId) == -1)
237 attrInfoLen-= dataWords;
256 NdbOperation::doSend(
int aNodeId, Uint32 lastFlag)
258 assert(theTCREQ != NULL);
259 setLastFlag(theTCREQ, lastFlag);
263 if (m_attribute_record != NULL)
273 secs[0].sz= theTupKeyLen;
274 secs[0].sectionIter= &keyInfoIter;
277 if (theTotalCurrAI_Len != 0)
279 secs[1].sz= theTotalCurrAI_Len;
280 secs[1].sectionIter= &attrInfoIter;
284 if (doSendKeyReq(aNodeId, &secs[0], numSecs) == -1)
296 const Uint32 inlineKIOffset= Uint32(tcKeyReq->keyInfo - (Uint32*)tcKeyReq);
297 const Uint32 inlineKILength= MIN(TcKeyReq::MaxKeyInfo,
299 const Uint32 inlineAIOffset = Uint32(tcKeyReq->attrInfo -(Uint32*)tcKeyReq);
300 const Uint32 inlineAILength= MIN(TcKeyReq::MaxAttrInfo,
316 secs[0].sz= theTupKeyLen;
317 secs[0].sectionIter= &keyInfoIter;
320 if (theTotalCurrAI_Len != 0)
322 secs[1].sz= theTotalCurrAI_Len;
323 secs[1].sectionIter= &attrInfoIter;
327 if (doSendKeyReq(aNodeId, &secs[0], numSecs) == -1)
342 NdbOperation::prepareGetLockHandle()
345 assert(! theLockHandle->isLockRefValid() );
347 theLockHandle->m_table = m_currentTable;
351 (
char*) &theLockHandle->m_lockRef);
359 theLockHandle->m_state = NdbLockHandle::PREPARED;
364 NdbBlob* blobHandle = theBlobList;
366 while (blobHandle != NULL)
368 theLockHandle->m_openBlobCount ++;
369 blobHandle = blobHandle->theNext;
390 Uint32 tTransId1, tTransId2;
392 Uint8 tInterpretInd = theInterpretIndicator;
393 Uint8 tDirtyIndicator = theDirtyIndicator;
394 Uint32 tTotalCurrAI_Len = theTotalCurrAI_Len;
397 if (tInterpretInd != 1) {
399 OperationStatus tStatus = theStatus;
403 if (tStatus != SetValue) {
404 setErrorCodeAbort(4116);
409 if (tStatus != GetValue) {
410 setErrorCodeAbort(4116);
413 else if(unlikely(tDirtyIndicator && tTotalCurrAI_Len == 0))
415 getValue(NdbDictionary::Column::FRAGMENT);
416 tTotalCurrAI_Len = theTotalCurrAI_Len;
417 assert(theTotalCurrAI_Len);
425 if (prepareGetLockHandle() != 0)
428 tTotalCurrAI_Len = theTotalCurrAI_Len;
430 tTotalCurrAI_Len = repack_read(tTotalCurrAI_Len);
433 setErrorCodeAbort(4005);
437 if (prepareSendInterpreted() == -1) {
440 tTotalCurrAI_Len = theTotalCurrAI_Len;
449 Uint32 tTableId = m_accessTable->m_id;
450 Uint32 tSchemaVersion = m_accessTable->m_version;
452 tcKeyReq->apiConnectPtr = aTC_ConnectPtr;
453 tcKeyReq->apiOperationPtr = ptr2int();
455 if (tTotalCurrAI_Len > TcKeyReq::MaxTotalAttrInfo){
456 setErrorCodeAbort(4257);
460 tcKeyReq->setAttrinfoLen(TattrLen, 0);
461 tcKeyReq->setAPIVersion(TattrLen, NDB_VERSION);
462 tcKeyReq->attrLen = TattrLen;
464 tcKeyReq->tableId = tTableId;
465 tcKeyReq->tableSchemaVersion = tSchemaVersion;
466 tTransId1 = (Uint32) aTransId;
467 tTransId2 = (Uint32) (aTransId >> 32);
469 Uint8 tSimpleIndicator = theSimpleIndicator;
470 Uint8 tCommitIndicator = theCommitIndicator;
471 Uint8 tStartIndicator = theStartIndicator;
472 Uint8 tInterpretIndicator = theInterpretIndicator;
473 Uint8 tNoDisk = (m_flags & OF_NO_DISK) != 0;
474 Uint8 tQueable = (m_flags & OF_QUEUEABLE) != 0;
475 Uint8 tDeferred = (m_flags & OF_DEFERRED_CONSTRAINTS) != 0;
480 Uint8 tReadInd = (theOperationType ==
ReadRequest);
481 Uint8 tDirtyState = tReadInd & tDirtyIndicator;
483 tcKeyReq->transId1 = tTransId1;
484 tcKeyReq->transId2 = tTransId2;
487 tcKeyReq->setAIInTcKeyReq(tReqInfo, 0);
488 tcKeyReq->setSimpleFlag(tReqInfo, tSimpleIndicator);
489 tcKeyReq->setCommitFlag(tReqInfo, tCommitIndicator);
490 tcKeyReq->setStartFlag(tReqInfo, tStartIndicator);
491 tcKeyReq->setInterpretedFlag(tReqInfo, tInterpretIndicator);
492 tcKeyReq->setNoDiskFlag(tReqInfo, tNoDisk);
493 tcKeyReq->setQueueOnRedoProblemFlag(tReqInfo, tQueable);
494 tcKeyReq->setDeferredConstraints(tReqInfo, tDeferred);
499 tcKeyReq->setDirtyFlag(tReqInfo, tDirtyIndicator);
500 tcKeyReq->setOperationType(tReqInfo, tOperationType);
501 tcKeyReq->setKeyLength(tReqInfo, 0);
502 tcKeyReq->setViaSPJFlag(tReqInfo, 0);
505 abortOption = tDirtyState ? (Uint8)
AO_IgnoreError : (Uint8) abortOption;
506 tcKeyReq->setAbortOption(tReqInfo, abortOption);
507 m_abortOption = abortOption;
509 Uint8 tDistrKeyIndicator = theDistrKeyIndicator_;
510 Uint8 tScanIndicator = theScanInfo & 1;
512 tcKeyReq->setDistributionKeyFlag(tReqInfo, tDistrKeyIndicator);
513 tcKeyReq->setScanIndFlag(tReqInfo, tScanIndicator);
515 tcKeyReq->requestInfo = tReqInfo;
520 Uint32* tOptionalDataPtr = &tcKeyReq->scanInfo;
521 Uint32 tDistrGHIndex = tScanIndicator;
522 Uint32 tDistrKeyIndex = tDistrGHIndex;
524 Uint32 tScanInfo = theScanInfo;
525 Uint32 tDistrKey = theDistributionKey;
527 tOptionalDataPtr[0] = tScanInfo;
528 tOptionalDataPtr[tDistrKeyIndex] = tDistrKey;
530 theTCREQ->setLength(TcKeyReq::StaticLength +
532 theDistrKeyIndicator_);
537 if (theTupKeyLen > TcKeyReq::MaxKeyInfo) {
541 if (theLastKEYINFO == NULL)
542 theLastKEYINFO= theTCREQ->next();
544 assert(theLastKEYINFO != NULL);
546 Uint32 lastKeyInfoLen= ((theTupKeyLen - TcKeyReq::MaxKeyInfo)
547 % KeyInfo::DataLength);
549 theLastKEYINFO->setLength(lastKeyInfoLen ?
550 KeyInfo::HeaderLength + lastKeyInfoLen :
551 KeyInfo::MaxSignalLength);
555 if (tTotalCurrAI_Len > TcKeyReq::MaxAttrInfo) {
557 theCurrentATTRINFO->setLength(theAI_LenInCurrAI);
559 theTotalCurrAI_Len= tTotalCurrAI_Len;
561 theStatus = WaitResponse;
562 theReceiver.prepareSend();
567 NdbOperation::repack_read(Uint32 len)
570 Uint32 check = 0, prevId = 0;
575 Uint32 cols = m_currentTable->m_columns.size();
577 Uint32 *ptr = tcKeyReq->attrInfo;
578 for (i = 0; len && i < 5; i++, len--)
581 Uint32
id = tmp.getAttributeId();
584 (
id >= NDB_MAX_ATTRIBUTES_IN_TABLE))
599 ptr = tSignal->getDataPtrSend() + AttrInfo::HeaderLength;
600 for (i = 0; len && i<AttrInfo::DataLength; i++, len--)
603 Uint32
id = tmp.getAttributeId();
604 if ((
id <= prevId) ||
605 (
id >= NDB_MAX_ATTRIBUTES_IN_TABLE))
615 tSignal = tSignal->next();
617 const Uint32 newlen = 1 + (prevId >> 5);
618 const bool all = cols == save;
625 if (all ==
false && ((1 + newlen) > TcKeyReq::MaxAttrInfo))
630 theNdb->releaseSignals(cnt, theFirstATTRINFO, theCurrentATTRINFO);
631 theFirstATTRINFO = 0;
632 theCurrentATTRINFO = 0;
633 ptr = tcKeyReq->attrInfo;
642 memcpy(ptr + 1, &mask, 4*newlen);
659 NdbOperation::prepareSendInterpreted()
661 Uint32 tTotalCurrAI_Len = theTotalCurrAI_Len;
662 Uint32 tInitReadSize = theInitialReadSize;
663 assert (theStatus != UseNdbRecord);
664 if (theStatus == ExecInterpretedValue) {
665 if (insertATTRINFO(Interpreter::EXIT_OK) != -1) {
671 theInterpretedSize = (tTotalCurrAI_Len + 1) -
672 (tInitReadSize + AttrInfo::SectionSizeInfoLength);
677 }
else if (theStatus == FinalGetValue) {
679 theFinalReadSize = tTotalCurrAI_Len -
680 (tInitReadSize + theInterpretedSize + theFinalUpdateSize
681 + AttrInfo::SectionSizeInfoLength);
683 }
else if (theStatus == SetValueInterpreted) {
685 theFinalUpdateSize = tTotalCurrAI_Len -
686 (tInitReadSize + theInterpretedSize
687 + AttrInfo::SectionSizeInfoLength);
689 }
else if (theStatus == SubroutineEnd) {
691 theSubroutineSize = tTotalCurrAI_Len -
692 (tInitReadSize + theInterpretedSize +
693 theFinalUpdateSize + theFinalReadSize
694 + AttrInfo::SectionSizeInfoLength);
696 }
else if (theStatus == GetValue) {
697 theInitialReadSize = tTotalCurrAI_Len - AttrInfo::SectionSizeInfoLength;
699 setErrorCodeAbort(4116);
706 while (theFirstBranch != NULL) {
708 Uint32 tLabelAddress = 0;
711 Uint32 tBranchLabel = tNdbBranch->theBranchLabel;
712 NdbLabel* tNdbLabel = theFirstLabel;
713 if (tBranchLabel >= theNoOfLabels) {
714 setErrorCodeAbort(4221);
719 while (tNdbLabel != NULL) {
720 for(tLabelAddress = 0; tLabelAddress<16; tLabelAddress++){
721 const Uint32 labelNo = tNdbLabel->theLabelNo[tLabelAddress];
722 if(tBranchLabel == labelNo){
723 tAddress = tNdbLabel->theLabelAddress[tLabelAddress];
730 tNdbLabel = tNdbLabel->theNext;
732 if (tAddress == -1) {
737 setErrorCodeAbort(4222);
740 if (tNdbLabel->theSubroutine[tLabelAddress] != tNdbBranch->theSubroutine) {
741 setErrorCodeAbort(4224);
745 if (tAddress <
int(tNdbBranch->theBranchAddress)) {
746 tRelAddress = (tNdbBranch->theBranchAddress - tAddress) << 16;
749 tRelAddress = tRelAddress + (1 << 31);
751 }
else if (tAddress >
int(tNdbBranch->theBranchAddress)) {
752 tRelAddress = (tAddress - tNdbBranch->theBranchAddress) << 16;
754 setErrorCodeAbort(4223);
759 Uint32 tReadData = tSignal->readData(tNdbBranch->theSignalAddress);
760 tSignal->setData((tRelAddress + tReadData), tNdbBranch->theSignalAddress);
762 theFirstBranch = theFirstBranch->theNext;
763 theNdb->releaseNdbBranch(tNdbBranch);
766 while (theFirstCall != NULL) {
767 Uint32 tSubroutineCount = 0;
770 NdbCall* tNdbCall = theFirstCall;
771 if (tNdbCall->theSubroutine >= theNoOfSubroutines) {
772 setErrorCodeAbort(4221);
776 tNdbSubroutine = theFirstSubroutine;
777 while (tNdbSubroutine != NULL) {
778 tSubroutineCount += 16;
779 if (tNdbCall->theSubroutine < tSubroutineCount) {
781 Uint32 tSubroutineAddress = tNdbCall->theSubroutine - (tSubroutineCount - 16);
782 tAddress = tNdbSubroutine->theSubroutineAddress[tSubroutineAddress];
785 tNdbSubroutine = tNdbSubroutine->theNext;
787 if (tAddress == -1) {
788 setErrorCodeAbort(4222);
793 Uint32 tReadData = tSignal->readData(tNdbCall->theSignalAddress);
794 tSignal->setData(((tAddress << 16) + (tReadData & 0xffff)),
795 tNdbCall->theSignalAddress);
797 theFirstCall = theFirstCall->theNext;
798 theNdb->releaseNdbCall(tNdbCall);
801 Uint32 tInitialReadSize = theInitialReadSize;
802 Uint32 tInterpretedSize = theInterpretedSize;
803 Uint32 tFinalUpdateSize = theFinalUpdateSize;
804 Uint32 tFinalReadSize = theFinalReadSize;
805 Uint32 tSubroutineSize = theSubroutineSize;
810 tcKeyReq->attrInfo[0] = tInitialReadSize;
811 tcKeyReq->attrInfo[1] = tInterpretedSize;
812 tcKeyReq->attrInfo[2] = tFinalUpdateSize;
813 tcKeyReq->attrInfo[3] = tFinalReadSize;
814 tcKeyReq->attrInfo[4] = tSubroutineSize;
817 theFirstATTRINFO->setData(tInitialReadSize, 4);
818 theFirstATTRINFO->setData(tInterpretedSize, 5);
819 theFirstATTRINFO->setData(tFinalUpdateSize, 6);
820 theFirstATTRINFO->setData(tFinalReadSize, 7);
821 theFirstATTRINFO->setData(tSubroutineSize, 8);
823 theReceiver.prepareSend();
836 NdbOperation::buildSignalsNdbRecord(Uint32 aTC_ConnectPtr,
838 const Uint32 * m_read_mask)
840 char buf[NdbRecord::Attr::SHRINK_VARCHAR_BUFFSIZE];
843 Uint32 *attrinfo_section_sizes_ptr= NULL;
845 assert(theStatus==UseNdbRecord);
849 assert(!theInterpretIndicator);
852 const char *key_row= m_key_row;
853 const NdbRecord *attr_rec= m_attribute_record;
855 const bool isScanTakeover= (key_rec == NULL);
859 Uint32 hdrSize= fillTcKeyReqHdr(tcKeyReq, aTC_ConnectPtr, aTransId);
863 assert(theTCREQ->next() == NULL);
872 tcKeyReq->tableId= attr_rec->tableId;
873 tcKeyReq->tableSchemaVersion= attr_rec->tableVersion;
874 res= insertKEYINFO_NdbRecord(key_row, m_keyinfo_length*4);
881 tcKeyReq->tableId= key_rec->tableId;
882 tcKeyReq->tableSchemaVersion= key_rec->tableVersion;
883 theTotalNrOfKeyWordInSignal= 0;
884 for (Uint32 i= 0; i<key_rec->key_index_length; i++)
888 col= &key_rec->columns[key_rec->key_indexes[
i]];
894 if (col->is_null(key_row))
896 setErrorCodeAbort(4316);
904 if (col->flags & NdbRecord::IsMysqldShrinkVarchar)
907 len_ok= col->shrink_varchar(key_row, length, buf);
912 len_ok= col->get_var_length(key_row, length);
913 src= &key_row[col->offset];
919 setErrorCodeAbort(4209);
922 res= insertKEYINFO_NdbRecord(src, length);
930 assert(theLockHandle);
932 assert(theLockHandle->isLockRefValid());
934 tcKeyReq->tableId= attr_rec->tableId;
935 tcKeyReq->tableSchemaVersion= attr_rec->tableVersion;
938 Uint32 keyInfoWords = 0;
939 const Uint32* keyInfoSrc = theLockHandle->getKeyInfoWords(keyInfoWords);
940 assert( keyInfoWords );
942 res = insertKEYINFO_NdbRecord((
const char*)keyInfoSrc,
961 assert(theFirstATTRINFO == NULL);
963 theATTRINFOptr= NULL;
965 no_disk_flag = (m_flags & OF_NO_DISK) != 0;
974 if (code->m_flags & NdbInterpretedCode::UsesDisk)
978 Uint32 sizes[AttrInfo::SectionSizeInfoLength];
985 res = insertATTRINFOData_NdbRecord((
const char *)sizes,
991 attrinfo_section_sizes_ptr= (theATTRINFOptr -
992 AttrInfo::SectionSizeInfoLength);
1001 m_attribute_row != NULL))
1004 Uint32 requestedCols= 0;
1005 Uint32 maxAttrId= 0;
1006 for (Uint32 i= 0; i<attr_rec->noOfColumns; i++)
1010 col= &attr_rec->columns[
i];
1011 Uint32 attrId= col->attrId;
1014 assert(! (attrId & AttributeHeader::PSEUDO));
1017 m_read_mask, attrId))
1023 if (unlikely(col->flags & NdbRecord::IsBlob))
1026 if (col->flags & NdbRecord::IsDisk)
1029 if (attrId > maxAttrId)
1032 readMask.
set(attrId);
1037 if (requestedCols > 0)
1039 bool all= (requestedCols == m_currentTable->m_columns.size());
1043 res= insertATTRINFOHdr_NdbRecord(AttributeHeader::READ_ALL,
1051 Uint32 sigBitmaskWords= (maxAttrId>>5) + 1;
1053 res= insertATTRINFOHdr_NdbRecord(AttributeHeader::READ_PACKED,
1054 sigBitmaskWords << 2);
1058 res= insertATTRINFOData_NdbRecord((
const char*) &readMask.rep.data[0],
1059 sigBitmaskWords << 2);
1070 const NdbRecAttr *ra= theReceiver.theFirstRecAttr;
1073 res= insertATTRINFOHdr_NdbRecord(ra->attrId(), 0);
1080 if (((m_flags & OF_USE_ANY_VALUE) != 0) &&
1090 res= insertATTRINFOHdr_NdbRecord(AttributeHeader::ANY_VALUE, 4);
1093 res= insertATTRINFOData_NdbRecord((
const char *)(&m_any_value), 4);
1102 attrinfo_section_sizes_ptr[0]= theTotalCurrAI_Len -
1103 AttrInfo::SectionSizeInfoLength;
1105 Uint32 mainProgramWords= code->m_first_sub_instruction_pos ?
1106 code->m_first_sub_instruction_pos :
1107 code->m_instructions_length;
1109 res = insertATTRINFOData_NdbRecord((
const char *)code->m_buffer,
1110 mainProgramWords << 2);
1116 attrinfo_section_sizes_ptr[1]= mainProgramWords;
1124 (tOpType == RefreshRequest))
1126 updRow= m_attribute_row;
1127 NdbBlob *currentBlob= theBlobList;
1129 for (Uint32 i= 0; i<attr_rec->noOfColumns; i++)
1133 col= &attr_rec->columns[
i];
1134 Uint32 attrId= col->attrId;
1137 assert(! (attrId & AttributeHeader::PSEUDO));
1140 m_read_mask, attrId))
1143 if (col->flags & NdbRecord::IsDisk)
1149 if (likely(!(col->flags & (NdbRecord::IsBlob|NdbRecord::IsMysqldBitfield))))
1157 if (( isScanTakeover ) ||
1158 ( ( key_rec->m_attrId_indexes_length <= attrId) ||
1160 ( ! (idxCol= &key_rec->columns[idxColNum] )) ||
1161 ( ! (idxCol->flags & NdbRecord::IsKey)) ) )
1169 if (col->is_null(updRow))
1171 else if (!col->get_var_length(updRow, length))
1174 setErrorCodeAbort(4209);
1177 data= &updRow[col->offset];
1188 assert(key_rec != 0);
1189 assert(key_rec->m_attrId_indexes_length > attrId);
1191 assert(idxCol != NULL);
1193 assert(col->attrId == attrId);
1194 assert(col->flags & NdbRecord::IsKey);
1200 assert(!col->is_null(key_row));
1205 if (col->flags & NdbRecord::IsMysqldShrinkVarchar)
1210 len_ok= col->shrink_varchar(key_row, length, buf);
1215 len_ok= col->get_var_length(key_row, length);
1216 data= &key_row[col->offset];
1226 assert(! (col->flags & NdbRecord::IsKey));
1227 if (likely(col->flags & NdbRecord::IsMysqldBitfield))
1230 if (col->is_null(updRow))
1234 col->get_mysqld_bitfield(updRow, buf);
1236 length= col->maxSize;
1242 currentBlob= currentBlob->theNext;
1267 bh->getNullOrEmptyBlobHeadDataPtr(data, length);
1271 res= insertATTRINFOHdr_NdbRecord(attrId, length);
1276 res= insertATTRINFOData_NdbRecord(data, length);
1283 if (m_extraSetValues != NULL)
1285 for (Uint32 i=0; i<m_numExtraSetValues; i++)
1288 const void * pvalue=m_extraSetValues[
i].value;
1290 if (extraCol->getStorageType( )== NDB_STORAGETYPE_DISK)
1299 length=extraCol->getSizeInBytes();
1300 if (extraCol->getArrayType() != NdbDictionary::Column::ArrayTypeFixed)
1302 Uint32 lengthInfoBytes;
1310 setErrorCodeAbort(4209);
1317 res= insertATTRINFOHdr_NdbRecord(extraCol->getAttrId(), length);
1323 res=insertATTRINFOData_NdbRecord((
char*)pvalue, length);
1331 m_extraSetValues = NULL;
1332 m_numExtraSetValues = 0;
1338 (tOpType == RefreshRequest))
1341 if ((m_flags & OF_USE_ANY_VALUE) != 0)
1343 res= insertATTRINFOHdr_NdbRecord(AttributeHeader::ANY_VALUE, 4);
1346 res= insertATTRINFOData_NdbRecord((
const char *)(&m_any_value), 4);
1361 Uint32 updateWords= theTotalCurrAI_Len - (AttrInfo::SectionSizeInfoLength +
1362 attrinfo_section_sizes_ptr[0] +
1363 attrinfo_section_sizes_ptr[1]);
1364 attrinfo_section_sizes_ptr[2]= updateWords;
1367 if (code->m_number_of_subs > 0)
1369 assert(code->m_first_sub_instruction_pos);
1371 Uint32 *subroutineStart=
1372 &code->m_buffer[ code->m_first_sub_instruction_pos ];
1373 Uint32 subroutineWords=
1374 code->m_instructions_length -
1375 code->m_first_sub_instruction_pos;
1377 assert(subroutineWords > 0);
1379 res = insertATTRINFOData_NdbRecord((
const char *)subroutineStart,
1380 subroutineWords << 2);
1386 attrinfo_section_sizes_ptr[4]= subroutineWords;
1391 if (theTotalCurrAI_Len > TcKeyReq::MaxTotalAttrInfo){
1392 setErrorCodeAbort(4257);
1400 theTCREQ->setLength(hdrSize);
1401 TcKeyReq::setNoDiskFlag(tcKeyReq->requestInfo, no_disk_flag);
1410 NdbOperation::prepareSendNdbRecord(AbortOption ao)
1418 (Uint8) m_abortOption : (Uint8) ao;
1420 m_abortOption= theSimpleIndicator && theOperationType==
ReadRequest ?
1423 Uint8 tQueable = (m_flags & OF_QUEUEABLE) != 0;
1424 Uint8 tDeferred = (m_flags & OF_DEFERRED_CONSTRAINTS) != 0;
1426 TcKeyReq::setAbortOption(tcKeyReq->requestInfo, m_abortOption);
1427 TcKeyReq::setCommitFlag(tcKeyReq->requestInfo, theCommitIndicator);
1428 TcKeyReq::setStartFlag(tcKeyReq->requestInfo, theStartIndicator);
1429 TcKeyReq::setSimpleFlag(tcKeyReq->requestInfo, theSimpleIndicator);
1430 TcKeyReq::setDirtyFlag(tcKeyReq->requestInfo, theDirtyIndicator);
1432 TcKeyReq::setQueueOnRedoProblemFlag(tcKeyReq->requestInfo, tQueable);
1433 TcKeyReq::setDeferredConstraints(tcKeyReq->requestInfo, tDeferred);
1435 theStatus= WaitResponse;
1455 tcKeyReq->apiConnectPtr= connectPtr;
1456 tcKeyReq->apiOperationPtr= ptr2int();
1461 UintR attrLenAPIVer= 0;
1462 TcKeyReq::setAPIVersion(attrLenAPIVer, NDB_VERSION);
1463 tcKeyReq->attrLen= attrLenAPIVer;
1469 TcKeyReq::setInterpretedFlag(reqInfo, (m_interpreted_code != NULL));
1471 TcKeyReq::setOperationType(reqInfo, theOperationType);
1473 TcKeyReq::setDistributionKeyFlag(reqInfo, theDistrKeyIndicator_);
1474 TcKeyReq::setScanIndFlag(reqInfo, theScanInfo & 1);
1475 tcKeyReq->requestInfo= reqInfo;
1477 tcKeyReq->transId1= (Uint32)transId;
1478 tcKeyReq->transId2= (Uint32)(transId>>32);
1485 hdrPtr= &(tcKeyReq->scanInfo);
1486 if (theScanInfo & 1)
1488 *hdrPtr++= theScanInfo;
1491 if (theDistrKeyIndicator_)
1493 *hdrPtr++= theDistributionKey;
1507 NdbOperation::allocKeyInfo()
1511 tSignal= theNdb->getSignal();
1512 if (tSignal == NULL)
1514 setErrorCodeAbort(4000);
1517 tSignal->next(NULL);
1518 if (theRequest->next() != NULL)
1520 theLastKEYINFO->setLength(NdbApiSignal::MaxSignalWords);
1521 theLastKEYINFO->next(tSignal);
1525 theRequest->next(tSignal);
1527 theLastKEYINFO= tSignal;
1528 keyInfoRemain= NdbApiSignal::MaxSignalWords;
1529 theKEYINFOptr= tSignal->getDataPtrSend();
1541 NdbOperation::allocAttrInfo()
1545 tSignal= theNdb->getSignal();
1546 if (tSignal == NULL)
1548 setErrorCodeAbort(4000);
1551 tSignal->next(NULL);
1552 if (theFirstATTRINFO != NULL)
1554 theCurrentATTRINFO->setLength(NdbApiSignal::MaxSignalWords);
1555 theCurrentATTRINFO->next(tSignal);
1559 theFirstATTRINFO= tSignal;
1561 theCurrentATTRINFO= tSignal;
1562 attrInfoRemain= NdbApiSignal::MaxSignalWords;
1563 theATTRINFOptr= tSignal->getDataPtrSend();
1569 NdbOperation::insertKEYINFO_NdbRecord(
const char *value,
1578 theTupKeyLen+= (byteSize+3)/4;
1580 while (byteSize > keyInfoRemain*4)
1586 assert(theKEYINFOptr != NULL);
1587 memcpy(theKEYINFOptr, value, keyInfoRemain*4);
1588 value+= keyInfoRemain*4;
1589 byteSize-= keyInfoRemain*4;
1593 int res= allocKeyInfo();
1598 assert(theRequest->next() != NULL);
1599 assert(theLastKEYINFO != NULL);
1602 assert(theKEYINFOptr != NULL);
1603 memcpy(theKEYINFOptr, value, byteSize);
1604 if((byteSize%4) != 0)
1605 memset(((
char *)theKEYINFOptr)+byteSize, 0, 4-(byteSize%4));
1606 Uint32 sizeInWords= (byteSize+3)/4;
1607 theKEYINFOptr+= sizeInWords;
1608 keyInfoRemain-= sizeInWords;
1610 theLastKEYINFO->setLength(NdbApiSignal::MaxSignalWords
1617 NdbOperation::insertATTRINFOHdr_NdbRecord(Uint32 attrId,
1627 theTotalCurrAI_Len++;
1629 if (! attrInfoRemain)
1634 int res= allocAttrInfo();
1642 assert(theFirstATTRINFO != NULL);
1643 assert(theCurrentATTRINFO != NULL);
1644 assert(theATTRINFOptr != NULL);
1646 *(theATTRINFOptr++)= ah;
1649 theCurrentATTRINFO->setLength(NdbApiSignal::MaxSignalWords
1656 NdbOperation::insertATTRINFOData_NdbRecord(
const char *value,
1665 theTotalCurrAI_Len+= (byteSize+3)/4;
1667 while (byteSize > attrInfoRemain*4)
1673 memcpy(theATTRINFOptr, value, attrInfoRemain*4);
1674 value+= attrInfoRemain*4;
1675 byteSize-= attrInfoRemain*4;
1678 int res= allocAttrInfo();
1684 assert(theFirstATTRINFO != NULL);
1685 assert(theCurrentATTRINFO != NULL);
1686 assert(theATTRINFOptr != NULL);
1688 memcpy(theATTRINFOptr, value, byteSize);
1689 if((byteSize%4) != 0)
1690 memset(((
char *)theATTRINFOptr)+byteSize, 0, 4-(byteSize%4));
1691 Uint32 sizeInWords= (byteSize+3)/4;
1692 theATTRINFOptr+= sizeInWords;
1693 attrInfoRemain-= sizeInWords;
1695 theCurrentATTRINFO->setLength(NdbApiSignal::MaxSignalWords
1702 NdbOperation::checkState_TransId(
const NdbApiSignal* aSignal)
1704 Uint64 tRecTransId, tCurrTransId;
1705 Uint32 tTmp1, tTmp2;
1707 if (theStatus != WaitResponse) {
1708 #ifdef NDB_NO_DROPPED_SIGNAL
1714 tTmp1 = aSignal->readData(2);
1715 tTmp2 = aSignal->readData(3);
1717 tRecTransId = (Uint64)tTmp1 + ((Uint64)tTmp2 << 32);
1719 if (tCurrTransId != tRecTransId) {
1720 #ifdef NDB_NO_DROPPED_SIGNAL
1739 if (checkState_TransId(aSignal) == -1) {
1743 setErrorCode(aSignal->readData(4));
1744 if (aSignal->getLength() == TcKeyRef::SignalLength)
1747 theError.
details = (
char *) aSignal->readData(5);
1750 theStatus = Finished;
1751 theReceiver.m_received_result_length = ~0;
1754 if(! (theOperationType ==
ReadRequest && theDirtyIndicator))
1756 theNdbCon->OpCompleteFailure();
1764 if(theReceiver.m_expected_result_length)
1766 return theNdbCon->OpCompleteFailure();