34 #include <AttributeHeader.hpp>
35 #include <signaldata/TcKeyReq.hpp>
36 #include <signaldata/KeyInfo.hpp>
50 const char* aValuePassed)
52 DBUG_ENTER(
"NdbOperation::equal_impl");
53 DBUG_PRINT(
"enter", (
"col: %s op: %d val: 0x%lx",
54 (tAttrInfo == NULL) ?
"NULL" :
55 tAttrInfo->m_name.
c_str(),
57 (long) aValuePassed));
59 const char* aValue = aValuePassed;
60 const Uint32 MaxKeyLenInLongWords= (NDB_MAX_KEY_SIZE + 7)/8;
61 Uint64 tempData[ MaxKeyLenInLongWords ];
63 if ((theStatus == OperationDefined) &&
65 (tAttrInfo != NULL )) {
88 Uint32 tAttrId = tAttrInfo->m_column_no;
90 if (tAttrInfo->m_pk) {
91 Uint32 tKeyDefined = theTupleKeyDefined[0][2];
92 Uint32 tKeyAttrId = theTupleKeyDefined[0][0];
94 if (tKeyDefined ==
false) {
97 if (tKeyAttrId != tAttrId) {
108 tKeyAttrId = theTupleKeyDefined[
i][0];
109 tKeyDefined = theTupleKeyDefined[
i][2];
115 }
while (i < NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY);
127 if (! tAttrInfo->get_var_length(aValue, sizeInBytes)) {
128 setErrorCodeAbort(4209);
132 Uint32 tKeyInfoPosition =
133 i == 0 ? 1 : theTupleKeyDefined[i-1][1] + theTupleKeyDefined[i-1][2];
134 theTupleKeyDefined[
i][0] = tAttrId;
135 theTupleKeyDefined[
i][1] = tKeyInfoPosition;
136 theTupleKeyDefined[
i][2] = (sizeInBytes + 3) / 4;
145 const bool tDistrKey = tAttrInfo->m_distributionKey;
146 const int attributeSize = sizeInBytes;
147 const int slack = sizeInBytes & 3;
148 const int align = Uint32(UintPtr(aValue)) & 7;
150 if (((align & 3) != 0) || (slack != 0) || (tDistrKey && (align != 0)))
152 ((Uint32*)tempData)[attributeSize >> 2] = 0;
153 memcpy(&tempData[0], aValue, attributeSize);
154 aValue = (
char*)&tempData[0];
158 Uint32 totalSizeInWords = (sizeInBytes + 3)/4;
159 theTupKeyLen += totalSizeInWords;
169 Uint32 tMaxVariableKeyLenInWord = (MAXTUPLEKEYLENOFATTERIBUTEINWORD -
171 tAttrSizeInBits = aVariableKeyLen << 3;
172 tAttrSizeInWords = tAttrSizeInBits >> 5;
173 tAttrBitsInLastWord = tAttrSizeInBits - (tAttrSizeInWords << 5);
174 tAttrLenInWords = ((tAttrSizeInBits + 31) >> 5);
175 if (tAttrLenInWords > tMaxVariableKeyLenInWord) {
176 setErrorCodeAbort(4207);
179 theTupKeyLen = theTupKeyLen + tAttrLenInWords;
193 if(m_accessTable == m_currentTable) {
196 assert(tOpType ==
WriteRequest && m_accessTable->m_index);
198 int column_no_current_table =
199 m_accessTable->m_index->m_columns[tAttrId]->m_keyInfoPos;
200 int attr_id_current_table =
201 m_currentTable->m_columns[column_no_current_table]->m_attrId;
205 insertATTRINFO( ahValue );
206 insertATTRINFOloop((Uint32*)aValue, totalSizeInWords);
212 if (insertKEYINFO(aValue, tKeyInfoPosition, totalSizeInWords) != -1) {
219 Uint32 tNoKeysDef = theNoOfTupKeyLeft - 1;
220 Uint32 tErrorLine = theErrorLine;
221 unsigned char tInterpretInd = theInterpretIndicator;
222 theNoOfTupKeyLeft = tNoKeysDef;
224 theErrorLine = tErrorLine;
226 if (tNoKeysDef == 0) {
230 for (Uint32 i = 0; i < m_accessTable->
m_noOfKeys; i++) {
231 Uint32 k = theTupleKeyDefined[
i][0];
232 if (m_accessTable->m_columns[k]->m_keyInfoPos != i) {
233 DBUG_PRINT(
"info", (
"key disorder at %d", i));
241 if (tInterpretInd == 1) {
242 theStatus = GetValue;
244 theStatus = SetValue;
249 theStatus = GetValue;
251 if (tOpType ==
DeleteRequest && m_currentTable->m_noOfBlobs != 0) {
252 for (
unsigned i = 0; i < m_currentTable->m_columns.size(); i++) {
255 if (c->getBlobType()) {
263 theStatus = SetValue;
266 setErrorCodeAbort(4005);
277 if (aValue == NULL) {
279 setErrorCodeAbort(4505);
283 if ( tAttrInfo == NULL ) {
285 setErrorCodeAbort(4004);
289 if (theStatus == GetValue || theStatus == SetValue){
291 setErrorCodeAbort(4225);
295 ndbout_c(
"theStatus: %d", theStatus);
299 setErrorCodeAbort(4200);
303 setErrorCodeAbort(4205);
307 setErrorCodeAbort(4206);
326 NdbOperation::insertKEYINFO(
const char* aValue,
327 register Uint32 aStartPosition,
328 register Uint32 anAttrSizeInWords)
333 register Uint32 tAttrPos;
337 Uint32 signalCounter;
345 tEndPos = aStartPosition + anAttrSizeInWords - 1;
348 register Uint32 tkeyData = *(Uint32*)aValue;
350 register Uint32* tDataPtr = (Uint32*)aValue;
352 register Uint32* tkeyDataPtr = theKEYINFOptr + aStartPosition - 1;
356 *tkeyDataPtr = tkeyData;
357 if (tAttrPos < anAttrSizeInWords) {
362 tkeyData = *tDataPtr;
375 while(tEndPos > theTotalNrOfKeyWordInSignal)
377 tSignal = theNdb->getSignal();
380 setErrorCodeAbort(4000);
383 if (tSignal->setSignal(m_keyInfoGSN, refToBlock(theNdbCon->m_tcRef)) == -1)
385 setErrorCodeAbort(4001);
388 tSignal->setLength(KeyInfo::MaxSignalLength);
389 if (theTCREQ->next() != NULL)
390 theLastKEYINFO->next(tSignal);
392 theTCREQ->next(tSignal);
394 theLastKEYINFO = tSignal;
395 theLastKEYINFO->next(NULL);
396 theTotalNrOfKeyWordInSignal += 20;
405 tPosition = aStartPosition;
406 tCurrentKEYINFO = theTCREQ->next();
412 while (tPosition < 9)
414 theKEYINFOptr[tPosition-1] = * (Uint32*)(aValue + (tAttrPos << 2));
416 if (anAttrSizeInWords == tAttrPos)
430 while ((tPosition - tPos) > 20)
432 tCurrentKEYINFO = tCurrentKEYINFO->next();
435 signalCounter = tPosition - tPos + 3;
444 if (signalCounter > 23)
446 tCurrentKEYINFO = tCurrentKEYINFO->next();
449 tCurrentKEYINFO->setData(*(Uint32*)(aValue + (tAttrPos << 2)),
452 if (anAttrSizeInWords == tAttrPos)
463 NdbOperation::reorderKEYINFO()
465 Uint32 data[ NDB_MAX_KEYSIZE_IN_WORDS ];
466 Uint32
size = NDB_MAX_KEYSIZE_IN_WORDS;
467 int rc = getKeyFromTCREQ(data, size);
471 for (k = 0; k < m_accessTable->
m_noOfKeys; k++) {
473 for (i = 0; i < m_accessTable->m_columns.size(); i++) {
475 if (col->m_pk && col->m_keyInfoPos == k) {
477 for (j = 0; j < m_accessTable->
m_noOfKeys; j++) {
478 if (theTupleKeyDefined[j][0] == i) {
479 Uint32 off = theTupleKeyDefined[j][1] - 1;
480 Uint32 len = theTupleKeyDefined[j][2];
481 assert(off < NDB_MAX_KEYSIZE_IN_WORDS &&
482 off + len <= NDB_MAX_KEYSIZE_IN_WORDS);
483 int ret = insertKEYINFO((
char*)&data[off], pos, len);
489 assert(j < m_accessTable->m_columns.size());
493 assert(i < m_accessTable->m_columns.size());
498 NdbOperation::getKeyFromTCREQ(Uint32* data, Uint32 & size)
501 if ((size < theTupKeyLen) || (theTupKeyLen == 0))
506 while (pos < 8 && pos < size) {
507 data[pos] = theKEYINFOptr[pos];
513 if (n == KeyInfo::DataLength) {
514 tSignal = tSignal->next();
518 tSignal->getDataPtrSend()[KeyInfo::HeaderLength + n++];
526 if (theStatus == UseNdbRecord)
530 setErrorCodeAbort(4515);
545 NdbDictionary::Object::UserDefined)) ||
549 theDistributionKey = value;
550 theDistrKeyIndicator_ = 1;
551 DBUG_PRINT(
"info", (
"NdbOperation::setPartitionId: %u",
552 theDistributionKey));
556 NdbOperation::getPartitionId()
const
558 DBUG_PRINT(
"info", (
"NdbOperation::getPartitionId: %u ind=%d",
559 theDistributionKey, theDistrKeyIndicator_));
560 return theDistributionKey;