20 #define DBTUP_ROUTINES_CPP
22 #include <RefConvert.hpp>
23 #include <ndb_limits.h>
25 #include <AttributeDescriptor.hpp>
26 #include "AttributeOffset.hpp"
27 #include <AttributeHeader.hpp>
28 #include <dblqh/Dblqh.hpp>
31 Dbtup::setUpQueryRoutines(Tablerec *regTabPtr)
33 Uint32 startDescriptor= regTabPtr->tabDescriptor;
34 ndbrequire((startDescriptor + (regTabPtr->m_no_of_attributes << ZAD_LOG_SIZE))
36 for (Uint32
i= 0;
i < regTabPtr->m_no_of_attributes;
i++) {
37 Uint32 attrDescrStart= startDescriptor + (
i << ZAD_LOG_SIZE);
38 Uint32 attrDescr= tableDescriptor[attrDescrStart].tabDescr;
39 Uint32 attrOffset= tableDescriptor[attrDescrStart + 1].tabDescr;
42 Uint32 array = AttributeDescriptor::getArrayType(attrDescr);
43 Uint32 charset = AttributeOffset::getCharsetFlag(attrOffset);
44 Uint32
size = AttributeDescriptor::getSize(attrDescr);
45 Uint32 bytes = AttributeDescriptor::getSizeInBytes(attrDescr);
46 Uint32 words = AttributeDescriptor::getSizeInWords(attrDescr);
47 Uint32 nullable = AttributeDescriptor::getNullable(attrDescr);
48 Uint32 dynamic = AttributeDescriptor::getDynamic(attrDescr);
52 if (array == NDB_ARRAYTYPE_FIXED)
57 case DictTabInfo::aBit:
59 regTabPtr->readFunctionArray[
i] = &Dbtup::readBitsNotNULL;
60 regTabPtr->updateFunctionArray[
i] = &Dbtup::updateBitsNotNULL;
62 case DictTabInfo::an8Bit:
63 case DictTabInfo::a16Bit:
65 regTabPtr->readFunctionArray[
i]=
66 &Dbtup::readFixedSizeTHManyWordNotNULL;
67 regTabPtr->updateFunctionArray[
i]=
68 &Dbtup::updateFixedSizeTHManyWordNotNULL;
70 case DictTabInfo::a32Bit:
71 case DictTabInfo::a64Bit:
72 case DictTabInfo::a128Bit:
77 regTabPtr->readFunctionArray[
i] =
78 &Dbtup::readFixedSizeTHOneWordNotNULL;
79 regTabPtr->updateFunctionArray[
i] =
80 &Dbtup::updateFixedSizeTHOneWordNotNULL;
84 regTabPtr->readFunctionArray[
i] =
85 &Dbtup::readFixedSizeTHTwoWordNotNULL;
86 regTabPtr->updateFunctionArray[
i] =
87 &Dbtup::updateFixedSizeTHManyWordNotNULL;
91 regTabPtr->readFunctionArray[
i] =
92 &Dbtup::readFixedSizeTHManyWordNotNULL;
93 regTabPtr->updateFunctionArray[
i] =
94 &Dbtup::updateFixedSizeTHManyWordNotNULL;
101 regTabPtr->readFunctionArray[
i] =
102 &Dbtup::readFixedSizeTHManyWordNotNULL;
103 regTabPtr->updateFunctionArray[
i] =
104 &Dbtup::updateFixedSizeTHManyWordNotNULL;
110 case DictTabInfo::aBit:
112 regTabPtr->readFunctionArray[
i] = &Dbtup::readBitsNULLable;
113 regTabPtr->updateFunctionArray[
i] = &Dbtup::updateBitsNULLable;
115 case DictTabInfo::an8Bit:
116 case DictTabInfo::a16Bit:
118 regTabPtr->readFunctionArray[
i]=
119 &Dbtup::readFixedSizeTHManyWordNULLable;
120 regTabPtr->updateFunctionArray[
i]=
121 &Dbtup::updateFixedSizeTHManyWordNULLable;
123 case DictTabInfo::a32Bit:
124 case DictTabInfo::a64Bit:
125 case DictTabInfo::a128Bit:
130 regTabPtr->readFunctionArray[
i] =
131 &Dbtup::readFixedSizeTHOneWordNULLable;
132 regTabPtr->updateFunctionArray[
i] =
133 &Dbtup::updateFixedSizeTHManyWordNULLable;
137 regTabPtr->readFunctionArray[
i] =
138 &Dbtup::readFixedSizeTHTwoWordNULLable;
139 regTabPtr->updateFunctionArray[
i] =
140 &Dbtup::updateFixedSizeTHManyWordNULLable;
144 regTabPtr->readFunctionArray[
i] =
145 &Dbtup::readFixedSizeTHManyWordNULLable;
146 regTabPtr->updateFunctionArray[
i] =
147 &Dbtup::updateFixedSizeTHManyWordNULLable;
154 regTabPtr->readFunctionArray[
i] =
155 &Dbtup::readFixedSizeTHManyWordNULLable;
156 regTabPtr->updateFunctionArray[
i] =
157 &Dbtup::updateFixedSizeTHManyWordNULLable;
165 regTabPtr->readFunctionArray[
i]=
166 &Dbtup::readVarSizeNotNULL;
167 regTabPtr->updateFunctionArray[
i]=
168 &Dbtup::updateVarSizeNotNULL;
173 regTabPtr->readFunctionArray[
i]=
174 &Dbtup::readVarSizeNULLable;
175 regTabPtr->updateFunctionArray[
i]=
176 &Dbtup::updateVarSizeNULLable;
179 if(AttributeDescriptor::getDiskBased(attrDescr))
184 r[0] = &Dbtup::readDiskBitsNotNULL;
185 r[1] = &Dbtup::readDiskBitsNULLable;
186 r[2] = &Dbtup::readDiskFixedSizeNotNULL;
187 r[3] = &Dbtup::readDiskFixedSizeNULLable;
188 r[4] = &Dbtup::readDiskVarAsFixedSizeNotNULL;
189 r[5] = &Dbtup::readDiskVarAsFixedSizeNULLable;
197 u[0] = &Dbtup::updateDiskBitsNotNULL;
198 u[1] = &Dbtup::updateDiskBitsNULLable;
199 u[2] = &Dbtup::updateDiskFixedSizeNotNULL;
200 u[3] = &Dbtup::updateDiskFixedSizeNULLable;
201 u[4] = &Dbtup::updateDiskVarAsFixedSizeNotNULL;
202 u[5] = &Dbtup::updateDiskVarAsFixedSizeNULLable;
209 AttributeDescriptor::getArrayType(attrDescr) == NDB_ARRAYTYPE_FIXED
212 if(AttributeDescriptor::getSize(attrDescr) == 0)
216 AttributeDescriptor::getNullable(attrDescr)? 1 : 0;
217 regTabPtr->readFunctionArray[
i]= r[a+b];
218 regTabPtr->updateFunctionArray[
i]= u[a+b];
225 if (array == NDB_ARRAYTYPE_FIXED)
230 regTabPtr->readFunctionArray[
i]= &Dbtup::readDynBitsNULLable;
231 regTabPtr->updateFunctionArray[
i]= &Dbtup::updateDynBitsNULLable;
233 else if (words > InternalMaxDynFix)
236 regTabPtr->readFunctionArray[
i]=
237 &Dbtup::readDynBigFixedSizeNULLable;
238 regTabPtr->updateFunctionArray[
i]=
239 &Dbtup::updateDynBigFixedSizeNULLable;
244 regTabPtr->readFunctionArray[
i]=
245 &Dbtup::readDynFixedSizeNULLable;
246 regTabPtr->updateFunctionArray[
i]=
247 &Dbtup::updateDynFixedSizeNULLable;
252 regTabPtr->readFunctionArray[
i]= &Dbtup::readDynVarSizeNULLable;
253 regTabPtr->updateFunctionArray[
i]= &Dbtup::updateDynVarSizeNULLable;
258 if (array == NDB_ARRAYTYPE_FIXED)
263 regTabPtr->readFunctionArray[
i]= &Dbtup::readDynBitsNotNULL;
264 regTabPtr->updateFunctionArray[
i]= &Dbtup::updateDynBitsNotNULL;
266 else if (words > InternalMaxDynFix)
269 regTabPtr->readFunctionArray[
i]=
270 &Dbtup::readDynBigFixedSizeNotNULL;
271 regTabPtr->updateFunctionArray[
i]=
272 &Dbtup::updateDynBigFixedSizeNotNULL;
277 regTabPtr->readFunctionArray[
i]=
278 &Dbtup::readDynFixedSizeNotNULL;
279 regTabPtr->updateFunctionArray[
i]=
280 &Dbtup::updateDynFixedSizeNotNULL;
286 regTabPtr->readFunctionArray[
i]= &Dbtup::readDynVarSizeNotNULL;
287 regTabPtr->updateFunctionArray[
i]= &Dbtup::updateDynVarSizeNotNULL;
296 static void dump_buf_hex(
unsigned char *p, Uint32 bytes)
302 for(Uint32
i=0;
i<bytes;
i++)
304 if(
i==((
sizeof(buf)/3)-1))
309 sprintf(q+3*
i,
" %02X", p[
i]);
311 ndbout_c(
"%8p: %s", p, buf);
318 pad32(Uint32 bytepos, Uint32 bitsused)
322 assert((bytepos & 3) == 0);
324 Uint32
ret = 4 * ((bitsused + 31) >> 5) +
325 ((bytepos + 3) & ~(Uint32)3);
353 int Dbtup::readAttributes(KeyReqStruct *req_struct,
354 const Uint32* inBuffer,
360 Uint32 attributeId, descr_index, tmpAttrBufIndex, tmpAttrBufBits, inBufIndex;
361 Uint32 attributeOffset;
362 TableDescriptor* attr_descr;
365 Tablerec*
const regTabPtr = req_struct->tablePtrP;
366 Uint32 numAttributes= regTabPtr->m_no_of_attributes;
369 req_struct->out_buf_index= 0;
370 req_struct->out_buf_bits = 0;
371 req_struct->max_read= 4*maxRead;
372 req_struct->xfrm_flag= xfrm_flag;
373 Uint8*outBuffer = (Uint8*)outBuf;
374 while (inBufIndex < inBufLen) {
375 tmpAttrBufIndex= req_struct->out_buf_index;
376 tmpAttrBufBits = req_struct->out_buf_bits;
379 attributeId= ahIn.getAttributeId();
380 descr_index= attributeId << ZAD_LOG_SIZE;
381 thrjam(req_struct->jamBuffer);
383 tmpAttrBufIndex = pad32(tmpAttrBufIndex, tmpAttrBufBits);
387 req_struct->out_buf_index= tmpAttrBufIndex + 4;
388 req_struct->out_buf_bits = 0;
389 attr_descr= req_struct->attr_descr;
390 if (attributeId < numAttributes) {
391 attributeOffset= attr_descr[descr_index + 1].tabDescr;
392 ReadFunction f= regTabPtr->readFunctionArray[attributeId];
393 req_struct->attr_descriptor= attr_descr[descr_index].tabDescr;
394 if ((this->*f)(outBuffer,
400 return -(int)req_struct->errorCode;
403 else if(attributeId & AttributeHeader::PSEUDO)
405 int sz = read_pseudo(inBuffer, inBufIndex,
410 inBufIndex += Uint32(sz);
419 return -ZATTRIBUTE_ID_ERROR;
422 return pad32(req_struct->out_buf_index, req_struct->out_buf_bits) >> 2;
426 Dbtup::readFixedSizeTHOneWordNotNULL(Uint8* outBuffer,
427 KeyReqStruct *req_struct,
431 ndbassert((req_struct->out_buf_index & 3) == 0);
432 ndbassert(req_struct->out_buf_bits == 0);
434 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
435 Uint32 indexBuf= req_struct->out_buf_index;
436 Uint32 readOffset= AttributeOffset::getOffset(attrDes2);
437 Uint32
const wordRead= tuple_header[readOffset];
439 Uint32 newIndexBuf = indexBuf + 4;
440 Uint32* dst = (Uint32*)(outBuffer + indexBuf);
441 Uint32 maxRead= req_struct->max_read;
443 ndbrequire(readOffset < req_struct->check_offset[MM]);
444 if (newIndexBuf <= maxRead) {
445 thrjam(req_struct->jamBuffer);
447 ahOut->setDataSize(1);
448 req_struct->out_buf_index= newIndexBuf;
451 thrjam(req_struct->jamBuffer);
452 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
458 Dbtup::readFixedSizeTHTwoWordNotNULL(Uint8* outBuffer,
459 KeyReqStruct *req_struct,
463 ndbassert((req_struct->out_buf_index & 3) == 0);
464 ndbassert(req_struct->out_buf_bits == 0);
466 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
467 Uint32 indexBuf= req_struct->out_buf_index;
468 Uint32 readOffset= AttributeOffset::getOffset(attrDes2);
469 Uint32
const wordReadFirst= tuple_header[readOffset];
470 Uint32
const wordReadSecond= tuple_header[readOffset + 1];
471 Uint32 maxRead= req_struct->max_read;
473 Uint32 newIndexBuf = indexBuf + 8;
474 Uint32* dst = (Uint32*)(outBuffer + indexBuf);
476 ndbrequire(readOffset + 1 < req_struct->check_offset[MM]);
477 if (newIndexBuf <= maxRead) {
478 thrjam(req_struct->jamBuffer);
479 ahOut->setDataSize(2);
480 dst[0] = wordReadFirst;
481 dst[1] = wordReadSecond;
482 req_struct->out_buf_index= newIndexBuf;
485 thrjam(req_struct->jamBuffer);
486 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
494 zero32(Uint8* dstPtr,
const Uint32 len)
496 Uint32 odd = len & 3;
499 Uint32 aligned = len & ~3;
500 Uint8* dst = dstPtr+aligned;
513 Dbtup::readFixedSizeTHManyWordNotNULL(Uint8* outBuffer,
514 KeyReqStruct *req_struct,
518 ndbassert(req_struct->out_buf_bits == 0);
520 Uint32 attrDescriptor= req_struct->attr_descriptor;
521 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
522 Uint32 indexBuf= req_struct->out_buf_index;
523 Uint32 readOffset= AttributeOffset::getOffset(attrDes2);
524 Uint32 srcBytes = AttributeDescriptor::getSizeInBytes(attrDescriptor);
525 Uint32 attrNoOfWords= (srcBytes + 3) >> 2;
526 Uint32 maxRead= req_struct->max_read;
527 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
529 Uint32 newIndexBuf = indexBuf + srcBytes;
530 Uint8* dst = (outBuffer + indexBuf);
531 const Uint8* src = (Uint8*)(tuple_header + readOffset);
533 ndbrequire((readOffset + attrNoOfWords - 1) < req_struct->check_offset[MM]);
534 if (! charsetFlag || ! req_struct->xfrm_flag) {
535 if (newIndexBuf <= maxRead) {
536 thrjam(req_struct->jamBuffer);
537 ahOut->setByteSize(srcBytes);
538 memcpy(dst, src, srcBytes);
539 zero32(dst, srcBytes);
540 req_struct->out_buf_index = newIndexBuf;
543 thrjam(req_struct->jamBuffer);
544 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
550 return xfrm_reader(dst, req_struct, ahOut, attrDes2, src, srcBytes);
555 Dbtup::readFixedSizeTHOneWordNULLable(Uint8* outBuffer,
556 KeyReqStruct *req_struct,
560 if (!nullFlagCheck(req_struct, attrDes2)) {
561 thrjam(req_struct->jamBuffer);
562 return readFixedSizeTHOneWordNotNULL(outBuffer,
567 thrjam(req_struct->jamBuffer);
574 Dbtup::readFixedSizeTHTwoWordNULLable(Uint8* outBuffer,
575 KeyReqStruct *req_struct,
579 if (!nullFlagCheck(req_struct, attrDes2)) {
580 thrjam(req_struct->jamBuffer);
581 return readFixedSizeTHTwoWordNotNULL(outBuffer,
586 thrjam(req_struct->jamBuffer);
593 Dbtup::readFixedSizeTHManyWordNULLable(Uint8* outBuffer,
594 KeyReqStruct *req_struct,
598 if (!nullFlagCheck(req_struct, attrDes2)) {
599 thrjam(req_struct->jamBuffer);
600 return readFixedSizeTHManyWordNotNULL(outBuffer,
605 thrjam(req_struct->jamBuffer);
612 Dbtup::readFixedSizeTHZeroWordNULLable(Uint8* outBuffer,
613 KeyReqStruct *req_struct,
617 thrjam(req_struct->jamBuffer);
618 if (nullFlagCheck(req_struct, attrDes2)) {
619 thrjam(req_struct->jamBuffer);
626 Dbtup::nullFlagCheck(KeyReqStruct *req_struct, Uint32 attrDes2)
629 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
630 Uint32(DD) : Uint32(MM);
631 Tablerec*
const regTabPtr = req_struct->tablePtrP;
632 Uint32 *bits= (ind) ? req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD) :
633 req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
634 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
640 Dbtup::disk_nullFlagCheck(KeyReqStruct *req_struct, Uint32 attrDes2)
642 Tablerec*
const regTabPtr = req_struct->tablePtrP;
643 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
644 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
651 Dbtup::varsize_reader(Uint8* outBuffer,
652 KeyReqStruct *req_struct,
658 ndbassert(req_struct->out_buf_bits == 0);
660 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attr_des2);
661 Uint32 attr_descriptor= req_struct->attr_descriptor;
662 Uint32 indexBuf= req_struct->out_buf_index;
663 Uint32 max_var_size= AttributeDescriptor::getSizeInBytes(attr_descriptor);
664 Uint32 max_read= req_struct->max_read;
666 Uint32 newIndexBuf = indexBuf + srcBytes;
667 Uint8* dst = (outBuffer + indexBuf);
669 ndbrequire(srcBytes <= max_var_size);
670 if (! charsetFlag || ! req_struct->xfrm_flag)
672 if (newIndexBuf <= max_read) {
673 thrjam(req_struct->jamBuffer);
674 ah_out->setByteSize(srcBytes);
675 memcpy(dst, srcPtr, srcBytes);
676 zero32(dst, srcBytes);
677 req_struct->out_buf_index= newIndexBuf;
683 return xfrm_reader(dst, req_struct, ah_out, attr_des2, srcPtr, srcBytes);
686 thrjam(req_struct->jamBuffer);
687 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
692 Dbtup::xfrm_reader(Uint8* dstPtr,
693 KeyReqStruct* req_struct,
696 const void* srcPtr, Uint32 srcBytes)
698 thrjam(req_struct->jamBuffer);
699 ndbassert(req_struct->out_buf_bits == 0);
701 Tablerec* regTabPtr = req_struct->tablePtrP;
702 Uint32 attrDes1 = req_struct->attr_descriptor;
703 Uint32 indexBuf= req_struct->out_buf_index;
704 Uint32 maxRead= req_struct->max_read;
705 Uint32
i = AttributeOffset::getCharsetPos(attrDes2);
707 Uint32 maxBytes = AttributeDescriptor::getSizeInBytes(attrDes1);
709 ndbrequire(i < regTabPtr->noOfCharsets);
714 Uint32 xmul = cs->strxfrm_multiply;
717 Uint32 dstLen = xmul * (maxBytes - lb);
718 Uint32 maxIndexBuf = indexBuf + (dstLen >> 2);
719 if (maxIndexBuf <= maxRead && ok)
721 thrjam(req_struct->jamBuffer);
723 (
const Uint8*)srcPtr + lb, len);
726 ahOut->setByteSize(n);
727 Uint32 newIndexBuf = indexBuf +
n;
728 ndbrequire(newIndexBuf <= maxRead);
729 req_struct->out_buf_index = newIndexBuf;
732 thrjam(req_struct->jamBuffer);
733 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
739 Dbtup::bits_reader(Uint8* outBuffer,
740 KeyReqStruct *req_struct,
742 const Uint32* bmptr, Uint32 bmlen,
743 Uint32 bitPos, Uint32 bitCount)
745 ndbassert((req_struct->out_buf_index & 3) == 0);
747 Uint32 indexBuf = req_struct->out_buf_index;
748 Uint32 indexBits = req_struct->out_buf_bits;
749 Uint32 maxRead = req_struct->max_read;
751 Uint32 sz32 = (bitCount + 31) >> 5;
752 Uint32 newIndexBuf = indexBuf + 4 * ((indexBits + bitCount) >> 5);
753 Uint32 newIndexBits = (indexBits + bitCount) & 31;
755 Uint32* dst = (Uint32*)(outBuffer + indexBuf);
756 if (newIndexBuf <= maxRead) {
758 ahOut->setDataSize(sz32);
759 req_struct->out_buf_index = newIndexBuf;
760 req_struct->out_buf_bits = newIndexBits;
764 * dst &= (1 << indexBits) - 1;
768 else if (indexBits == 0)
781 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
787 Dbtup::readVarSizeNotNULL(Uint8* out_buffer,
788 KeyReqStruct *req_struct,
792 Uint32 var_idx= AttributeOffset::getOffset(attr_des2);
793 Uint32 var_attr_pos= req_struct->m_var_data[MM].m_offset_array_ptr[var_idx];
794 Uint32 idx= req_struct->m_var_data[MM].m_var_len_offset;
796 req_struct->m_var_data[MM].m_offset_array_ptr[var_idx+idx] - var_attr_pos;
797 const char* src_ptr= req_struct->m_var_data[MM].m_data_ptr+var_attr_pos;
799 return varsize_reader(out_buffer, req_struct, ah_out, attr_des2,
804 Dbtup::readVarSizeNULLable(Uint8* outBuffer,
805 KeyReqStruct *req_struct,
809 if (!nullFlagCheck(req_struct, attrDes2)) {
810 thrjam(req_struct->jamBuffer);
811 return readVarSizeNotNULL(outBuffer,
816 thrjam(req_struct->jamBuffer);
823 Dbtup::readDynFixedSizeNotNULL(Uint8* outBuffer,
824 KeyReqStruct *req_struct,
828 thrjam(req_struct->jamBuffer);
829 if(req_struct->is_expanded)
830 return readDynFixedSizeExpandedNotNULL(outBuffer, req_struct,
833 return readDynFixedSizeShrunkenNotNULL(outBuffer, req_struct,
838 Dbtup::readDynFixedSizeNULLable(Uint8* outBuffer,
839 KeyReqStruct *req_struct,
843 thrjam(req_struct->jamBuffer);
844 if(req_struct->is_expanded)
845 return readDynFixedSizeExpandedNULLable(outBuffer, req_struct,
848 return readDynFixedSizeShrunkenNULLable(outBuffer, req_struct,
853 Dbtup::readDynFixedSizeExpandedNotNULL(Uint8* outBuffer,
854 KeyReqStruct *req_struct,
862 thrjam(req_struct->jamBuffer);
863 Uint32 attr_descriptor= req_struct->attr_descriptor;
865 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
866 Uint32(DD) : Uint32(MM);
868 char *src_ptr= req_struct->m_var_data[ind].m_dyn_data_ptr;
869 Uint32 var_index= AttributeOffset::getOffset(attrDes2);
870 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
871 Uint32 var_attr_pos= off_arr[var_index];
872 Uint32 vsize_in_bytes=
873 AttributeDescriptor::getSizeInBytes(attr_descriptor);
874 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
875 src_ptr + var_attr_pos, vsize_in_bytes);
879 Dbtup::readDynFixedSizeExpandedNULLable(Uint8* outBuffer,
880 KeyReqStruct *req_struct,
890 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
891 Uint32(DD) : Uint32(MM);
893 Uint32 *src_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
894 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
897 thrjam(req_struct->jamBuffer);
902 return readDynFixedSizeExpandedNotNULL(outBuffer, req_struct,
907 Dbtup::readDynFixedSizeShrunkenNotNULL(Uint8* outBuffer,
908 KeyReqStruct *req_struct,
912 Uint32 attr_descriptor= req_struct->attr_descriptor;
914 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
915 Uint32(DD) : Uint32(MM);
917 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
918 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
919 ndbrequire(dyn_len != 0);
920 Uint32 bm_len= (* bm_ptr) & DYN_BM_LEN_MASK;
921 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
936 thrjam(req_struct->jamBuffer);
937 Tablerec * regTabPtr = req_struct->tablePtrP;
938 Uint32 *bm_mask_ptr= regTabPtr->dynFixSizeMask[ind];
939 Uint32 bm_pos= AttributeOffset::getNullFlagOffset(attrDes2);
940 Uint32 prevMask= (1 << (pos & 31)) - 1;
941 Uint32 bit_count= BitmaskImpl::count_bits(prevMask & bm_mask_ptr[bm_pos] & bm_ptr[bm_pos]);
942 for(Uint32 i=0; i<bm_pos; i++)
943 bit_count+= BitmaskImpl::count_bits(bm_mask_ptr[i] & bm_ptr[i]);
946 Uint32 vsize_in_bytes= AttributeDescriptor::getSizeInBytes(attr_descriptor);
947 Uint32 vsize_in_words= (vsize_in_bytes+3)>>2;
948 Uint32 *data_ptr= bm_ptr + dyn_len - bit_count - vsize_in_words;
950 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
951 (Uint8 *)data_ptr, vsize_in_bytes);
957 dynCheckNull(Uint32 totlen, Uint32 bm_len,
const Uint32* bm_ptr, Uint32 pos)
959 return totlen == 0 || !(bm_len > (pos >> 5)) ||
964 Dbtup::readDynFixedSizeShrunkenNULLable(Uint8* outBuffer,
965 KeyReqStruct *req_struct,
970 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
971 Uint32(DD) : Uint32(MM);
973 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
974 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
975 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
977 if(dyn_len == 0 || dynCheckNull(dyn_len, (* bm_ptr) & DYN_BM_LEN_MASK,
980 thrjam(req_struct->jamBuffer);
985 return readDynFixedSizeShrunkenNotNULL(outBuffer, req_struct,
990 Dbtup::readDynBigFixedSizeNotNULL(Uint8* outBuffer,
991 KeyReqStruct *req_struct,
995 thrjam(req_struct->jamBuffer);
996 if(req_struct->is_expanded)
997 return readDynBigFixedSizeExpandedNotNULL(outBuffer, req_struct,
1000 return readDynBigFixedSizeShrunkenNotNULL(outBuffer, req_struct,
1005 Dbtup::readDynBigFixedSizeNULLable(Uint8* outBuffer,
1006 KeyReqStruct *req_struct,
1010 thrjam(req_struct->jamBuffer);
1011 if(req_struct->is_expanded)
1012 return readDynBigFixedSizeExpandedNULLable(outBuffer, req_struct,
1015 return readDynBigFixedSizeShrunkenNULLable(outBuffer, req_struct,
1020 Dbtup::readDynBigFixedSizeExpandedNotNULL(Uint8* outBuffer,
1021 KeyReqStruct *req_struct,
1029 thrjam(req_struct->jamBuffer);
1030 Uint32 attr_descriptor= req_struct->attr_descriptor;
1032 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1033 Uint32(DD) : Uint32(MM);
1035 char *src_ptr= req_struct->m_var_data[ind].m_dyn_data_ptr;
1036 Uint32 var_index= AttributeOffset::getOffset(attrDes2);
1037 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
1038 Uint32 var_attr_pos= off_arr[var_index];
1039 Uint32 vsize_in_bytes=
1040 AttributeDescriptor::getSizeInBytes(attr_descriptor);
1041 Uint32 idx= req_struct->m_var_data[ind].m_dyn_len_offset;
1042 ndbrequire(vsize_in_bytes <= off_arr[var_index+idx] - var_attr_pos);
1043 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
1044 src_ptr + var_attr_pos, vsize_in_bytes);
1048 Dbtup::readDynBigFixedSizeExpandedNULLable(Uint8* outBuffer,
1049 KeyReqStruct *req_struct,
1059 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1060 Uint32(DD) : Uint32(MM);
1062 Uint32 *src_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1063 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1066 thrjam(req_struct->jamBuffer);
1071 return readDynBigFixedSizeExpandedNotNULL(outBuffer, req_struct,
1076 Dbtup::readDynBigFixedSizeShrunkenNotNULL(Uint8* outBuffer,
1077 KeyReqStruct *req_struct,
1081 Uint32 attr_descriptor= req_struct->attr_descriptor;
1083 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1084 Uint32(DD) : Uint32(MM);
1086 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1087 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1088 ndbrequire(dyn_len!=0);
1089 Uint32 bm_len = (* bm_ptr) & DYN_BM_LEN_MASK;
1090 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1101 Tablerec * regTabPtr = req_struct->tablePtrP;
1102 Uint32 *bm_mask_ptr= regTabPtr->dynVarSizeMask[ind];
1103 Uint32 bm_pos= AttributeOffset::getNullFlagOffset(attrDes2);
1104 Uint32 prevMask= (1 << (pos & 31)) - 1;
1105 Uint32 bit_count= BitmaskImpl::count_bits(prevMask & bm_mask_ptr[bm_pos] & bm_ptr[bm_pos]);
1106 for(Uint32 i=0; i<bm_pos; i++)
1107 bit_count+= BitmaskImpl::count_bits(bm_mask_ptr[i] & bm_ptr[i]);
1110 Uint32 vsize_in_bytes= AttributeDescriptor::getSizeInBytes(attr_descriptor);
1112 Uint16* offset_array = (Uint16*)(bm_ptr + bm_len);
1113 Uint16 data_offset= offset_array[bit_count];
1114 ndbrequire(vsize_in_bytes <= Uint32(offset_array[bit_count+1]- data_offset));
1120 thrjam(req_struct->jamBuffer);
1121 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
1122 ((
char *)offset_array) + data_offset, vsize_in_bytes);
1126 Dbtup::readDynBigFixedSizeShrunkenNULLable(Uint8* outBuffer,
1127 KeyReqStruct *req_struct,
1132 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1133 Uint32(DD) : Uint32(MM);
1135 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1136 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1138 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1139 if(dyn_len == 0 || dynCheckNull(dyn_len, (* bm_ptr) & DYN_BM_LEN_MASK,
1142 thrjam(req_struct->jamBuffer);
1147 return readDynBigFixedSizeShrunkenNotNULL(outBuffer, req_struct,
1152 Dbtup::readDynBitsNotNULL(Uint8* outBuffer,
1153 KeyReqStruct *req_struct,
1157 thrjam(req_struct->jamBuffer);
1158 if(req_struct->is_expanded)
1159 return readDynBitsExpandedNotNULL(outBuffer, req_struct, ahOut, attrDes2);
1161 return readDynBitsShrunkenNotNULL(outBuffer, req_struct, ahOut, attrDes2);
1165 Dbtup::readDynBitsNULLable(Uint8* outBuffer,
1166 KeyReqStruct *req_struct,
1170 thrjam(req_struct->jamBuffer);
1171 if(req_struct->is_expanded)
1172 return readDynBitsExpandedNULLable(outBuffer, req_struct, ahOut, attrDes2);
1174 return readDynBitsShrunkenNULLable(outBuffer, req_struct, ahOut, attrDes2);
1178 Dbtup::readDynBitsShrunkenNotNULL(Uint8* outBuffer,
1179 KeyReqStruct* req_struct,
1183 Uint32 attr_descriptor= req_struct->attr_descriptor;
1185 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1186 Uint32(DD) : Uint32(MM);
1188 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1189 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1190 ndbrequire(dyn_len != 0);
1191 Uint32 bm_len = (* bm_ptr) & DYN_BM_LEN_MASK;
1193 AttributeDescriptor::getArraySize(attr_descriptor);
1194 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1196 ndbrequire((pos>>5)<bm_len);
1198 ndbassert(pos>bitCount);
1201 return bits_reader(outBuffer, req_struct, ahOut,
1207 Dbtup::readDynBitsShrunkenNULLable(Uint8* outBuffer,
1208 KeyReqStruct* req_struct,
1213 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1214 Uint32(DD) : Uint32(MM);
1216 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1217 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1219 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1220 if(dyn_len == 0 || dynCheckNull(dyn_len, (* bm_ptr) & DYN_BM_LEN_MASK,
1223 thrjam(req_struct->jamBuffer);
1228 return readDynBitsShrunkenNotNULL(outBuffer, req_struct, ahOut, attrDes2);
1232 Dbtup::readDynBitsExpandedNotNULL(Uint8* outBuffer,
1233 KeyReqStruct* req_struct,
1237 Uint32 attr_descriptor= req_struct->attr_descriptor;
1239 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1240 Uint32(DD) : Uint32(MM);
1242 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1243 Uint32 bm_len = (* bm_ptr) & DYN_BM_LEN_MASK;
1245 AttributeDescriptor::getArraySize(attr_descriptor);
1246 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1248 ndbassert(pos>bitCount);
1251 return bits_reader(outBuffer, req_struct, ahOut,
1257 Dbtup::readDynBitsExpandedNULLable(Uint8* outBuffer,
1258 KeyReqStruct* req_struct,
1264 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1265 Uint32(DD) : Uint32(MM);
1267 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1268 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1271 thrjam(req_struct->jamBuffer);
1276 return readDynBitsExpandedNotNULL(outBuffer, req_struct, ahOut, attrDes2);
1280 Dbtup::readDynVarSizeNotNULL(Uint8* outBuffer,
1281 KeyReqStruct *req_struct,
1285 thrjam(req_struct->jamBuffer);
1286 if(req_struct->is_expanded)
1287 return readDynVarSizeExpandedNotNULL(outBuffer, req_struct,
1290 return readDynVarSizeShrunkenNotNULL(outBuffer, req_struct,
1295 Dbtup::readDynVarSizeNULLable(Uint8* outBuffer,
1296 KeyReqStruct *req_struct,
1300 thrjam(req_struct->jamBuffer);
1301 if(req_struct->is_expanded)
1302 return readDynVarSizeExpandedNULLable(outBuffer, req_struct,
1305 return readDynVarSizeShrunkenNULLable(outBuffer, req_struct,
1310 Dbtup::readDynVarSizeExpandedNotNULL(Uint8* outBuffer,
1311 KeyReqStruct *req_struct,
1319 thrjam(req_struct->jamBuffer);
1321 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1322 Uint32(DD) : Uint32(MM);
1324 char *src_ptr= req_struct->m_var_data[ind].m_dyn_data_ptr;
1325 Uint32 var_index= AttributeOffset::getOffset(attrDes2);
1326 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
1327 Uint32 var_attr_pos= off_arr[var_index];
1328 Uint32 idx= req_struct->m_var_data[ind].m_dyn_len_offset;
1329 Uint32 vsize_in_bytes= off_arr[var_index+idx] - var_attr_pos;
1330 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
1331 src_ptr + var_attr_pos, vsize_in_bytes);
1335 Dbtup::readDynVarSizeExpandedNULLable(Uint8* outBuffer,
1336 KeyReqStruct *req_struct,
1346 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1347 Uint32(DD) : Uint32(MM);
1349 Uint32 *src_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1350 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1353 thrjam(req_struct->jamBuffer);
1358 return readDynVarSizeExpandedNotNULL(outBuffer, req_struct,
1363 Dbtup::readDynVarSizeShrunkenNotNULL(Uint8* outBuffer,
1364 KeyReqStruct *req_struct,
1369 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1370 Uint32(DD) : Uint32(MM);
1372 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1373 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1374 ndbrequire(dyn_len!=0);
1375 Uint32 bm_len = (* bm_ptr) & DYN_BM_LEN_MASK;
1376 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1387 Tablerec * regTabPtr = req_struct->tablePtrP;
1388 Uint32 *bm_mask_ptr= regTabPtr->dynVarSizeMask[ind];
1389 Uint32 bm_pos= AttributeOffset::getNullFlagOffset(attrDes2);
1390 Uint32 prevMask= (1 << (pos & 31)) - 1;
1391 Uint32 bit_count= BitmaskImpl::count_bits(prevMask & bm_mask_ptr[bm_pos] & bm_ptr[bm_pos]);
1392 for(Uint32 i=0; i<bm_pos; i++)
1393 bit_count+= BitmaskImpl::count_bits(bm_mask_ptr[i] & bm_ptr[i]);
1397 Uint16* offset_array = (Uint16*)(bm_ptr + bm_len);
1398 Uint16 data_offset= offset_array[bit_count];
1399 Uint32 vsize_in_bytes= offset_array[bit_count+1] - data_offset;
1405 thrjam(req_struct->jamBuffer);
1406 return varsize_reader(outBuffer, req_struct, ahOut, attrDes2,
1407 ((
char *)offset_array) + data_offset, vsize_in_bytes);
1411 Dbtup::readDynVarSizeShrunkenNULLable(Uint8* outBuffer,
1412 KeyReqStruct *req_struct,
1417 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
1418 Uint32(DD) : Uint32(MM);
1420 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
1421 Uint32 dyn_len= req_struct->m_var_data[ind].m_dyn_part_len;
1423 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1424 if(dyn_len == 0 || dynCheckNull(dyn_len, (* bm_ptr) & DYN_BM_LEN_MASK,
1427 thrjam(req_struct->jamBuffer);
1432 return readDynVarSizeShrunkenNotNULL(outBuffer, req_struct,
1437 Dbtup::readDiskFixedSizeNotNULL(Uint8* outBuffer,
1438 KeyReqStruct *req_struct,
1442 ndbassert(req_struct->out_buf_bits == 0);
1444 Uint32 attrDescriptor= req_struct->attr_descriptor;
1445 Uint32 *tuple_header= req_struct->m_disk_ptr->m_data;
1446 Uint32 indexBuf= req_struct->out_buf_index;
1447 Uint32 readOffset= AttributeOffset::getOffset(attrDes2);
1448 Uint32 srcBytes = AttributeDescriptor::getSizeInBytes(attrDescriptor);
1449 Uint32 attrNoOfWords= (srcBytes + 3) >> 2;
1450 Uint32 maxRead= req_struct->max_read;
1451 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
1452 Uint32 newIndexBuf = indexBuf + srcBytes;
1453 Uint8* dst = (outBuffer + indexBuf);
1454 const Uint8* src = (Uint8*)(tuple_header+readOffset);
1456 ndbrequire((readOffset + attrNoOfWords - 1) < req_struct->check_offset[DD]);
1457 if (! charsetFlag || ! req_struct->xfrm_flag)
1459 if (newIndexBuf <= maxRead)
1462 ahOut->setByteSize(srcBytes);
1463 memcpy(dst, src, srcBytes);
1464 zero32(dst, srcBytes);
1465 req_struct->out_buf_index = newIndexBuf;
1471 return xfrm_reader(dst, req_struct, ahOut, attrDes2, src, srcBytes);
1475 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
1480 Dbtup::readDiskFixedSizeNULLable(Uint8* outBuffer,
1481 KeyReqStruct *req_struct,
1485 if (!disk_nullFlagCheck(req_struct, attrDes2)) {
1487 return readDiskFixedSizeNotNULL(outBuffer,
1499 Dbtup::readDiskVarAsFixedSizeNotNULL(Uint8* outBuffer,
1500 KeyReqStruct *req_struct,
1504 ndbassert(req_struct->out_buf_bits == 0);
1506 Uint32 attrDescriptor= req_struct->attr_descriptor;
1507 Uint32 *tuple_header= req_struct->m_disk_ptr->m_data;
1508 Uint32 indexBuf= req_struct->out_buf_index;
1509 Uint32 readOffset= AttributeOffset::getOffset(attrDes2);
1511 Uint32 maxRead= req_struct->max_read;
1512 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
1513 Uint8* dst = (outBuffer + indexBuf);
1514 const Uint8* src = (Uint8*)(tuple_header+readOffset);
1516 Uint32 srcBytes = AttributeDescriptor::getSizeInBytes(attrDescriptor);
1517 Uint32 attrNoOfWords= (srcBytes + 3) >> 2;
1518 Uint32 newIndexBuf = indexBuf + srcBytes;
1522 if (typeId != NDB_ARRAYTYPE_FIXED &&
1524 srcBytes = len + lb;
1525 newIndexBuf = indexBuf + srcBytes;
1526 attrNoOfWords= (srcBytes + 3) >> 2;
1529 ndbrequire((readOffset + attrNoOfWords - 1) < req_struct->check_offset[DD]);
1530 if (! charsetFlag || ! req_struct->xfrm_flag)
1532 if (newIndexBuf <= maxRead)
1535 ahOut->setByteSize(srcBytes);
1536 memcpy(dst, src, srcBytes);
1537 zero32(dst, srcBytes);
1538 req_struct->out_buf_index = newIndexBuf;
1544 return xfrm_reader(dst, req_struct, ahOut, attrDes2, src, srcBytes);
1548 req_struct->errorCode = ZTRY_TO_READ_TOO_MUCH_ERROR;
1553 Dbtup::readDiskVarAsFixedSizeNULLable(Uint8* outBuffer,
1554 KeyReqStruct *req_struct,
1558 if (!disk_nullFlagCheck(req_struct, attrDes2)) {
1560 return readDiskVarAsFixedSizeNotNULL(outBuffer,
1572 Dbtup::readDiskVarSizeNotNULL(Uint8* out_buffer,
1573 KeyReqStruct *req_struct,
1582 Dbtup::readDiskVarSizeNULLable(Uint8* outBuffer,
1583 KeyReqStruct *req_struct,
1587 if (!disk_nullFlagCheck(req_struct, attrDes2)) {
1589 return readDiskVarSizeNotNULL(outBuffer,
1601 Dbtup::readDiskBitsNotNULL(Uint8* outBuffer,
1602 KeyReqStruct* req_struct,
1606 Tablerec *
const regTabPtr = req_struct->tablePtrP;
1607 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1609 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
1610 Uint32 bm_len = regTabPtr->m_offsets[DD].m_null_words;
1611 Uint32* bm_ptr = req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
1613 return bits_reader(outBuffer, req_struct, ahOut,
1620 Dbtup::readDiskBitsNULLable(Uint8* outBuffer,
1621 KeyReqStruct* req_struct,
1625 Tablerec *
const regTabPtr = req_struct->tablePtrP;
1626 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
1628 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
1630 Uint32 bm_len = regTabPtr->m_offsets[DD].m_null_words;
1631 Uint32 *bm_ptr= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
1640 return bits_reader(outBuffer, req_struct, ahOut,
1657 int Dbtup::updateAttributes(KeyReqStruct *req_struct,
1661 Tablerec *
const regTabPtr = req_struct->tablePtrP;
1662 Operationrec*
const regOperPtr = req_struct->operPtrP;
1663 Uint32 numAttributes= regTabPtr->m_no_of_attributes;
1664 TableDescriptor *attr_descr= req_struct->attr_descr;
1666 Uint32 inBufIndex= 0;
1667 req_struct->in_buf_index= 0;
1668 req_struct->in_buf_len= inBufLen;
1670 while (inBufIndex < inBufLen) {
1672 Uint32 attributeId= ahIn.getAttributeId();
1673 Uint32 attrDescriptorIndex= attributeId << ZAD_LOG_SIZE;
1674 if (likely(attributeId < numAttributes)) {
1675 Uint32 attrDescriptor= attr_descr[attrDescriptorIndex].tabDescr;
1676 Uint32 attributeOffset= attr_descr[attrDescriptorIndex + 1].tabDescr;
1677 if ((AttributeDescriptor::getPrimaryKey(attrDescriptor)) &&
1678 (regOperPtr->op_struct.op_type != ZINSERT)) {
1679 if (checkUpdateOfPrimaryKey(req_struct,
1680 &inBuffer[inBufIndex],
1683 return -ZTRY_UPDATE_PRIMARY_KEY;
1686 UpdateFunction f= regTabPtr->updateFunctionArray[attributeId];
1688 req_struct->attr_descriptor= attrDescriptor;
1689 req_struct->changeMask.set(attributeId);
1690 if ((this->*f)(inBuffer,
1693 inBufIndex= req_struct->in_buf_index;
1697 return -(int)req_struct->errorCode;
1700 else if(attributeId == AttributeHeader::READ_LCP)
1702 Uint32 sz= ahIn.getDataSize();
1703 update_lcp(req_struct, inBuffer+inBufIndex+1, sz);
1704 inBufIndex += 1 + sz;
1705 req_struct->in_buf_index = inBufIndex;
1707 else if (attributeId == AttributeHeader::READ_PACKED)
1709 Uint32 sz = update_packed(req_struct, inBuffer+inBufIndex);
1710 inBufIndex += 1 + sz;
1711 req_struct->in_buf_index = inBufIndex;
1713 else if(attributeId == AttributeHeader::DISK_REF)
1716 Uint32 sz= ahIn.getDataSize();
1717 ndbrequire(sz == 2);
1718 req_struct->m_tuple_ptr->m_header_bits |= Tuple_header::DISK_PART;
1719 memcpy(req_struct->m_tuple_ptr->get_disk_ref_ptr(regTabPtr),
1720 inBuffer+inBufIndex+1, sz << 2);
1721 inBufIndex += 1 + sz;
1722 req_struct->in_buf_index = inBufIndex;
1724 else if(attributeId == AttributeHeader::ANY_VALUE)
1727 Uint32 sz= ahIn.getDataSize();
1728 ndbrequire(sz == 1);
1729 regOperPtr->m_any_value = * (inBuffer + inBufIndex + 1);
1730 inBufIndex += 1 + sz;
1731 req_struct->in_buf_index = inBufIndex;
1733 else if(attributeId == AttributeHeader::OPTIMIZE)
1736 Uint32 sz= ahIn.getDataSize();
1737 ndbrequire(sz == 1);
1741 req_struct->optimize_options = * (inBuffer + inBufIndex + 1);
1742 req_struct->optimize_options &=
1743 AttributeHeader::OPTIMIZE_OPTIONS_MASK;
1744 inBufIndex += 1 + sz;
1745 req_struct->in_buf_index = inBufIndex;
1747 else if (attributeId == AttributeHeader::ROW_AUTHOR)
1750 Uint32 sz= ahIn.getDataSize();
1751 ndbrequire(sz == 1);
1753 Uint32 value = * (inBuffer + inBufIndex + 1);
1755 regTabPtr->getExtraAttrId<Tablerec::TR_ExtraRowAuthorBits>();
1757 if (unlikely(!(regTabPtr->m_bits & Tablerec::TR_ExtraRowAuthorBits)))
1759 return -ZATTRIBUTE_ID_ERROR;
1762 if (unlikely(store_extra_row_bits(attrId, regTabPtr,
1763 req_struct->m_tuple_ptr,
1764 value,
false) ==
false))
1766 return -ZAI_INCONSISTENCY_ERROR;
1768 inBufIndex += 1 + sz;
1769 req_struct->in_buf_index = inBufIndex;
1771 else if (attributeId == AttributeHeader::ROW_GCI64)
1774 Uint32 sz= ahIn.getDataSize();
1775 ndbrequire(sz == 2);
1777 regTabPtr->getExtraAttrId<Tablerec::TR_ExtraRowGCIBits>();
1778 Uint32 gciLo = * (inBuffer + inBufIndex + 1);
1779 Uint32 gciHi = * (inBuffer + inBufIndex + 2);
1781 if (unlikely(!(regTabPtr->m_bits & Tablerec::TR_RowGCI)))
1783 return -ZATTRIBUTE_ID_ERROR;
1787 regOperPtr->op_struct.m_gci_written = 1;
1789 *req_struct->m_tuple_ptr->get_mm_gci(regTabPtr) = gciHi;
1791 if (regTabPtr->m_bits & Tablerec::TR_ExtraRowGCIBits)
1793 if (unlikely(store_extra_row_bits(attrId, regTabPtr,
1794 req_struct->m_tuple_ptr,
1795 gciLo,
true) ==
false))
1797 return -ZAI_INCONSISTENCY_ERROR;
1801 inBufIndex+= 1 + sz;
1802 req_struct->in_buf_index = inBufIndex;
1807 return -(int)req_struct->errorCode;
1814 Dbtup::checkUpdateOfPrimaryKey(KeyReqStruct* req_struct,
1815 Uint32* updateBuffer,
1816 Tablerec*
const regTabPtr)
1818 Uint32 keyReadBuffer[MAX_KEY_SIZE_IN_WORDS];
1819 TableDescriptor* attr_descr = req_struct->attr_descr;
1821 Uint32 attributeId = ahIn.getAttributeId();
1822 Uint32 attrDescriptorIndex = attributeId << ZAD_LOG_SIZE;
1823 Uint32 attrDescriptor = attr_descr[attrDescriptorIndex].tabDescr;
1824 Uint32 attributeOffset = attr_descr[attrDescriptorIndex + 1].tabDescr;
1826 Uint32 xfrmBuffer[1 + MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY];
1827 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attributeOffset);
1829 Uint32 csIndex = AttributeOffset::getCharsetPos(attributeOffset);
1833 xfrm_attr(attrDescriptor, cs, &updateBuffer[1], srcPos,
1834 &xfrmBuffer[1], dstPos, MAX_KEY_SIZE_IN_WORDS * MAX_XFRM_MULTIPLY);
1835 ahIn.setDataSize(dstPos);
1836 xfrmBuffer[0] = ahIn.m_value;
1837 updateBuffer = xfrmBuffer;
1840 ReadFunction f = regTabPtr->readFunctionArray[attributeId];
1843 req_struct->out_buf_index = 0;
1844 req_struct->out_buf_bits = 0;
1845 req_struct->max_read =
sizeof(keyReadBuffer);
1846 req_struct->attr_descriptor = attrDescriptor;
1848 bool tmp = req_struct->xfrm_flag;
1849 req_struct->xfrm_flag =
true;
1850 ndbrequire((this->*f)((Uint8*)keyReadBuffer,
1854 req_struct->xfrm_flag = tmp;
1856 ndbrequire(req_struct->out_buf_index == attributeHeader.getByteSize());
1857 if (ahIn.getDataSize() != attributeHeader.getDataSize()) {
1861 if (memcmp(&keyReadBuffer[0],
1863 req_struct->out_buf_index) != 0) {
1871 Dbtup::updateFixedSizeTHOneWordNotNULL(Uint32* inBuffer,
1872 KeyReqStruct *req_struct,
1875 Uint32 indexBuf= req_struct->in_buf_index;
1876 Uint32 inBufLen= req_struct->in_buf_len;
1877 Uint32 updateOffset= AttributeOffset::getOffset(attrDes2);
1879 Uint32 nullIndicator= ahIn.isNULL();
1880 Uint32 newIndex= indexBuf + 2;
1881 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
1882 ndbrequire(updateOffset < req_struct->check_offset[MM]);
1884 if (newIndex <= inBufLen) {
1885 Uint32 updateWord= inBuffer[indexBuf + 1];
1886 if (!nullIndicator) {
1888 req_struct->in_buf_index= newIndex;
1889 tuple_header[updateOffset]= updateWord;
1893 req_struct->errorCode = ZNOT_NULL_ATTR;
1898 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
1905 Dbtup::updateFixedSizeTHTwoWordNotNULL(Uint32* inBuffer,
1906 KeyReqStruct *req_struct,
1909 Uint32 indexBuf= req_struct->in_buf_index;
1910 Uint32 inBufLen= req_struct->in_buf_len;
1911 Uint32 updateOffset= AttributeOffset::getOffset(attrDes2);
1913 Uint32 nullIndicator= ahIn.isNULL();
1914 Uint32 newIndex= indexBuf + 3;
1915 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
1916 ndbrequire((updateOffset + 1) < req_struct->check_offset[MM]);
1918 if (newIndex <= inBufLen) {
1919 Uint32 updateWord1= inBuffer[indexBuf + 1];
1920 Uint32 updateWord2= inBuffer[indexBuf + 2];
1921 if (!nullIndicator) {
1923 req_struct->in_buf_index= newIndex;
1924 tuple_header[updateOffset]= updateWord1;
1925 tuple_header[updateOffset + 1]= updateWord2;
1929 req_struct->errorCode = ZNOT_NULL_ATTR;
1934 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
1940 Dbtup::fixsize_updater(Uint32* inBuffer,
1941 KeyReqStruct *req_struct,
1944 Uint32 updateOffset,
1947 Uint32 attrDescriptor= req_struct->attr_descriptor;
1948 Uint32 indexBuf= req_struct->in_buf_index;
1949 Uint32 inBufLen= req_struct->in_buf_len;
1950 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
1953 Uint32 noOfWords= AttributeDescriptor::getSizeInWords(attrDescriptor);
1954 Uint32 nullIndicator= ahIn.isNULL();
1955 Uint32 newIndex= indexBuf + noOfWords + 1;
1956 ndbrequire((updateOffset + noOfWords - 1) < checkOffset);
1958 if (newIndex <= inBufLen) {
1959 if (!nullIndicator) {
1963 Tablerec * regTabPtr = req_struct->tablePtrP;
1965 Uint32 bytes = AttributeDescriptor::getSizeInBytes(attrDescriptor);
1966 Uint32 i = AttributeOffset::getCharsetPos(attrDes2);
1967 ndbrequire(i < regTabPtr->noOfCharsets);
1971 const char* ssrc = (
const char*)&inBuffer[indexBuf + 1];
1975 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
1979 if (typeId != NDB_TYPE_TEXT &&
1980 (*cs->cset->well_formed_len)(cs, ssrc + lb, ssrc + lb + len, ZNIL, ¬_used) != len) {
1982 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
1986 req_struct->in_buf_index= newIndex;
1987 MEMCOPY_NO_WORDS(&(dst_ptr[updateOffset]),
1988 &inBuffer[indexBuf + 1],
1994 req_struct->errorCode = ZNOT_NULL_ATTR;
1999 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2005 Dbtup::updateFixedSizeTHManyWordNotNULL(Uint32* inBuffer,
2006 KeyReqStruct *req_struct,
2009 Uint32 *tuple_header= req_struct->m_tuple_ptr->m_data;
2010 Uint32 updateOffset= AttributeOffset::getOffset(attrDes2);
2011 Uint32 checkOffset= req_struct->check_offset[MM];
2012 return fixsize_updater(inBuffer, req_struct, attrDes2, tuple_header,
2013 updateOffset, checkOffset);
2017 Dbtup::updateFixedSizeTHManyWordNULLable(Uint32* inBuffer,
2018 KeyReqStruct *req_struct,
2021 Tablerec *
const regTabPtr = req_struct->tablePtrP;
2023 Uint32 nullIndicator= ahIn.isNULL();
2024 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2025 Uint32 *bits= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
2027 if (!nullIndicator) {
2030 return updateFixedSizeTHManyWordNotNULL(inBuffer,
2034 Uint32 newIndex= req_struct->in_buf_index + 1;
2035 if (newIndex <= req_struct->in_buf_len) {
2038 req_struct->in_buf_index= newIndex;
2042 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2049 Dbtup::updateVarSizeNotNULL(Uint32* in_buffer,
2050 KeyReqStruct *req_struct,
2054 char *var_data_start= req_struct->m_var_data[MM].m_data_ptr;
2055 var_index= AttributeOffset::getOffset(attr_des2);
2056 Uint32 idx= req_struct->m_var_data[MM].m_var_len_offset;
2057 Uint16 *vpos_array= req_struct->m_var_data[MM].m_offset_array_ptr;
2058 Uint16
offset= vpos_array[var_index];
2059 Uint16 *len_offset_ptr= &(vpos_array[var_index+idx]);
2060 return varsize_updater(in_buffer, req_struct, var_data_start,
2061 offset, len_offset_ptr,
2062 req_struct->m_var_data[MM].m_max_var_offset);
2065 Dbtup::varsize_updater(Uint32* in_buffer,
2066 KeyReqStruct *req_struct,
2067 char *var_data_start,
2068 Uint32 var_attr_pos,
2069 Uint16 *len_offset_ptr,
2070 Uint32 check_offset)
2072 Uint32 attr_descriptor, index_buf, in_buf_len, null_ind;
2073 Uint32 vsize_in_words, new_index, max_var_size;
2075 attr_descriptor= req_struct->attr_descriptor;
2076 index_buf= req_struct->in_buf_index;
2077 in_buf_len= req_struct->in_buf_len;
2079 null_ind= ahIn.isNULL();
2080 Uint32 size_in_bytes = ahIn.getByteSize();
2081 vsize_in_words= (size_in_bytes + 3) >> 2;
2082 max_var_size= AttributeDescriptor::getSizeInBytes(attr_descriptor);
2083 Uint32 arrayType = AttributeDescriptor::getArrayType(attr_descriptor);
2084 new_index= index_buf + vsize_in_words + 1;
2086 Uint32 dataLen = size_in_bytes;
2087 const Uint8 * src = (
const Uint8*)&in_buffer[index_buf + 1];
2089 if (new_index <= in_buf_len && size_in_bytes <= max_var_size)
2094 if (arrayType == NDB_ARRAYTYPE_SHORT_VAR)
2096 dataLen = 1 + src[0];
2098 else if (arrayType == NDB_ARRAYTYPE_MEDIUM_VAR)
2100 dataLen = 2 + src[0] + 256 * Uint32(src[1]);
2103 if (dataLen == size_in_bytes)
2105 *len_offset_ptr= var_attr_pos+size_in_bytes;
2106 req_struct->in_buf_index= new_index;
2108 ndbrequire(var_attr_pos+size_in_bytes <= check_offset);
2109 memcpy(var_data_start+var_attr_pos, src, size_in_bytes);
2113 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2118 req_struct->errorCode = ZNOT_NULL_ATTR;
2123 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2128 Dbtup::updateVarSizeNULLable(Uint32* inBuffer,
2129 KeyReqStruct *req_struct,
2132 Tablerec *
const regTabPtr = req_struct->tablePtrP;
2134 Uint32 nullIndicator= ahIn.isNULL();
2135 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2136 Uint32 *bits= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
2137 Uint32 idx= req_struct->m_var_data[MM].m_var_len_offset;
2139 if (!nullIndicator) {
2142 return updateVarSizeNotNULL(inBuffer,
2146 Uint32 newIndex= req_struct->in_buf_index + 1;
2147 Uint32 var_index= AttributeOffset::getOffset(attrDes2);
2148 Uint32 var_pos= req_struct->var_pos_array[var_index];
2149 if (newIndex <= req_struct->in_buf_len) {
2152 req_struct->var_pos_array[var_index+idx]= var_pos;
2153 req_struct->in_buf_index= newIndex;
2157 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2164 Dbtup::updateDynFixedSizeNotNULL(Uint32* inBuffer,
2165 KeyReqStruct *req_struct,
2168 Uint32 attrDescriptor= req_struct->attr_descriptor;
2170 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2171 Uint32(DD) : Uint32(MM);
2173 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2174 Uint32 nullbits= AttributeDescriptor::getSizeInWords(attrDescriptor);
2176 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
2177 ndbassert(nullbits && nullbits <= 16);
2186 Uint32 bm_idx= (pos >> 5);
2188 Uint64 bm_mask = ((Uint64(1) << nullbits) - 1) << (pos & 31);
2189 Uint32 bm_mask1 = (Uint32)(bm_mask & 0xFFFFFFFF);
2190 Uint32 bm_mask2 = (Uint32)(bm_mask >> 32);
2194 bm_ptr[bm_idx]|= bm_mask1;
2200 bm_ptr[bm_idx+1]|= bm_mask2;
2203 Uint32 off_index= AttributeOffset::getOffset(attrDes2);
2204 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
2205 Uint32
offset= off_arr[off_index];
2206 Uint32 *dst_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
2207 Uint32 check_offset= req_struct->m_var_data[ind].m_max_dyn_offset;
2209 ndbassert((offset&3)==0);
2210 ndbassert((check_offset&3)==0);
2211 bool result= fixsize_updater(inBuffer, req_struct, attrDes2, dst_ptr,
2212 (offset>>2), (check_offset>>2));
2217 Dbtup::updateDynFixedSizeNULLable(Uint32* inBuffer,
2218 KeyReqStruct *req_struct,
2222 Uint32 nullIndicator= ahIn.isNULL();
2225 return updateDynFixedSizeNotNULL(inBuffer, req_struct, attrDes2);
2227 Uint32 attrDescriptor= req_struct->attr_descriptor;
2229 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2230 Uint32(DD) : Uint32(MM);
2232 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2233 Uint32 nullbits= AttributeDescriptor::getSizeInWords(attrDescriptor);
2234 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
2236 ndbassert(nullbits && nullbits <= 16);
2245 Uint32 bm_idx= (pos >> 5);
2247 Uint64 bm_mask = ~(((Uint64(1) << nullbits) - 1) << (pos & 31));
2248 Uint32 bm_mask1 = (Uint32)(bm_mask & 0xFFFFFFFF);
2249 Uint32 bm_mask2 = (Uint32)(bm_mask >> 32);
2251 Uint32 newIndex= req_struct->in_buf_index + 1;
2252 if (newIndex <= req_struct->in_buf_len) {
2255 bm_ptr[bm_idx] &= bm_mask1;
2256 bm_ptr[bm_idx+1] &= bm_mask2;
2257 req_struct->in_buf_index= newIndex;
2261 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2268 Dbtup::updateDynBigFixedSizeNotNULL(Uint32* inBuffer,
2269 KeyReqStruct *req_struct,
2272 Uint32 attrDescriptor= req_struct->attr_descriptor;
2274 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2275 Uint32(DD) : Uint32(MM);
2277 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2278 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
2283 Uint32 off_index= AttributeOffset::getOffset(attrDes2);
2284 Uint32 noOfWords= AttributeDescriptor::getSizeInWords(attrDescriptor);
2285 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
2286 Uint32 offset= off_arr[off_index];
2287 Uint32 idx= req_struct->m_var_data[ind].m_dyn_len_offset;
2289 ndbassert((offset&3)==0);
2290 bool res= fixsize_updater(inBuffer,
2295 req_struct->m_var_data[ind].m_max_dyn_offset);
2297 off_arr[off_index+idx]= offset+(noOfWords<<2);
2302 Dbtup::updateDynBigFixedSizeNULLable(Uint32* inBuffer,
2303 KeyReqStruct *req_struct,
2307 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2308 Uint32(DD) : Uint32(MM);
2311 Uint32 nullIndicator= ahIn.isNULL();
2312 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2313 Uint32 *bm_ptr= (Uint32*)req_struct->m_var_data[ind].m_dyn_data_ptr;
2316 return updateDynBigFixedSizeNotNULL(inBuffer, req_struct, attrDes2);
2318 Uint32 newIndex= req_struct->in_buf_index + 1;
2319 if (newIndex <= req_struct->in_buf_len) {
2322 req_struct->in_buf_index= newIndex;
2326 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2332 Dbtup::updateDynBitsNotNULL(Uint32* inBuffer,
2333 KeyReqStruct *req_struct,
2336 Uint32 attrDescriptor= req_struct->attr_descriptor;
2338 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2339 Uint32(DD) : Uint32(MM);
2341 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2342 Uint32 bitCount = AttributeDescriptor::getArraySize(attrDescriptor);
2343 Uint32 *bm_ptr= (Uint32 *)(req_struct->m_var_data[ind].m_dyn_data_ptr);
2344 Uint32 bm_len = (* bm_ptr) & DYN_BM_LEN_MASK;
2348 Uint32 indexBuf= req_struct->in_buf_index;
2349 Uint32 inBufLen= req_struct->in_buf_len;
2351 Uint32 nullIndicator = ahIn.isNULL();
2352 Uint32 newIndex = indexBuf + 1 + ((bitCount + 31) >> 5);
2354 if (newIndex <= inBufLen) {
2355 if (!nullIndicator) {
2356 ndbassert(pos>=bitCount);
2358 inBuffer+indexBuf+1);
2359 req_struct->in_buf_index= newIndex;
2363 req_struct->errorCode = ZNOT_NULL_ATTR;
2368 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2375 Dbtup::updateDynBitsNULLable(Uint32* inBuffer,
2376 KeyReqStruct *req_struct,
2380 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2381 Uint32(DD) : Uint32(MM);
2384 Uint32 nullIndicator= ahIn.isNULL();
2387 return updateDynBitsNotNULL(inBuffer, req_struct, attrDes2);
2389 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2390 Uint32 *bm_ptr= (Uint32*)req_struct->m_var_data[ind].m_dyn_data_ptr;
2392 Uint32 newIndex= req_struct->in_buf_index + 1;
2393 if (newIndex <= req_struct->in_buf_len) {
2396 req_struct->in_buf_index= newIndex;
2400 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2406 Dbtup::updateDynVarSizeNotNULL(Uint32* inBuffer,
2407 KeyReqStruct *req_struct,
2411 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2412 Uint32(DD) : Uint32(MM);
2414 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2415 Uint32 *bm_ptr= (Uint32*)req_struct->m_var_data[ind].m_dyn_data_ptr;
2420 Uint32 off_index= AttributeOffset::getOffset(attrDes2);
2421 Uint16* off_arr= req_struct->m_var_data[ind].m_dyn_offset_arr_ptr;
2422 Uint32 offset= off_arr[off_index];
2423 Uint32 idx= req_struct->m_var_data[ind].m_dyn_len_offset;
2425 bool res= varsize_updater(inBuffer,
2429 &(off_arr[off_index+idx]),
2430 req_struct->m_var_data[ind].m_max_dyn_offset);
2435 Dbtup::updateDynVarSizeNULLable(Uint32* inBuffer,
2436 KeyReqStruct *req_struct,
2440 (AttributeDescriptor::getDiskBased(req_struct->attr_descriptor)) ?
2441 Uint32(DD) : Uint32(MM);
2444 Uint32 nullIndicator= ahIn.isNULL();
2445 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
2446 Uint32 *bm_ptr= (Uint32*)req_struct->m_var_data[ind].m_dyn_data_ptr;
2449 return updateDynVarSizeNotNULL(inBuffer, req_struct, attrDes2);
2451 Uint32 newIndex= req_struct->in_buf_index + 1;
2452 if (newIndex <= req_struct->in_buf_len) {
2455 req_struct->in_buf_index= newIndex;
2459 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2465 Dbtup::read_pseudo(
const Uint32 * inBuffer, Uint32 inPos,
2466 KeyReqStruct *req_struct,
2470 ndbassert(req_struct->out_buf_index);
2471 ndbassert(req_struct->out_buf_bits == 0);
2472 ndbassert((req_struct->out_buf_index & 3) == 0);
2474 Uint32 attrId = (* (inBuffer + inPos - 1)) >> 16;
2475 Uint32 outPos = req_struct->out_buf_index;
2476 Uint32* outBuffer = outBuf + ((outPos - 1) >> 2);
2479 const Uint32 DataSz = MAX_INDEX_STAT_KEY_SIZE;
2482 bzero(signal,
sizeof(signalT));
2484 case AttributeHeader::READ_LCP:
2485 return read_lcp(inBuffer, inPos, req_struct, outBuf);
2486 case AttributeHeader::READ_PACKED:
2487 case AttributeHeader::READ_ALL:
2488 return (
int)read_packed(inBuffer, inPos, req_struct, outBuf);
2489 case AttributeHeader::FRAGMENT:
2490 outBuffer[1] = req_struct->fragPtrP->fragmentId;
2493 case AttributeHeader::FRAGMENT_FIXED_MEMORY:
2495 Uint64 tmp = req_struct->fragPtrP->noOfPages;
2497 memcpy(outBuffer + 1, &tmp, 8);
2501 case AttributeHeader::FRAGMENT_VARSIZED_MEMORY:
2503 Uint64 tmp= req_struct->fragPtrP->noOfVarPages;
2505 memcpy(outBuffer + 1, &tmp, 8);
2509 case AttributeHeader::ROW_SIZE:
2510 outBuffer[1] = req_struct->tablePtrP->m_offsets[MM].m_fix_header_size << 2;
2513 case AttributeHeader::ROW_COUNT:
2514 case AttributeHeader::COMMIT_COUNT:
2515 signal->theData[0] = req_struct->operPtrP->userpointer;
2516 signal->theData[1] = attrId;
2519 outBuffer[1] = signal->theData[0];
2520 outBuffer[2] = signal->theData[1];
2523 case AttributeHeader::RANGE_NO:
2524 signal->theData[0] = req_struct->operPtrP->userpointer;
2525 signal->theData[1] = attrId;
2528 outBuffer[1] = signal->theData[0];
2531 case AttributeHeader::DISK_REF:
2533 Uint32 *ref= req_struct->m_tuple_ptr->get_disk_ref_ptr(req_struct->tablePtrP);
2534 outBuffer[1] = ref[0];
2535 outBuffer[2] = ref[1];
2539 case AttributeHeader::RECORDS_IN_RANGE:
2540 signal->theData[0] = req_struct->operPtrP->userpointer;
2541 signal->theData[1] = attrId;
2544 outBuffer[1] = signal->theData[0];
2545 outBuffer[2] = signal->theData[1];
2546 outBuffer[3] = signal->theData[2];
2547 outBuffer[4] = signal->theData[3];
2550 case AttributeHeader::INDEX_STAT_KEY:
2551 case AttributeHeader::INDEX_STAT_VALUE:
2553 signal->theData[0] = req_struct->operPtrP->userpointer;
2554 signal->theData[1] = attrId;
2558 const Uint8* src = (Uint8*)&signal->theData[0];
2559 Uint32 byte_sz = 2 + src[0] + (src[1] << 8);
2560 Uint8* dst = (Uint8*)&outBuffer[1];
2561 memcpy(dst, src, byte_sz);
2562 while (byte_sz % 4 != 0)
2567 case AttributeHeader::ROWID:
2568 outBuffer[1] = req_struct->frag_page_id;
2569 outBuffer[2] = req_struct->operPtrP->m_tuple_location.m_page_idx;
2572 case AttributeHeader::ROW_GCI:
2574 if (req_struct->tablePtrP->m_bits & Tablerec::TR_RowGCI)
2576 Uint64 tmp = * req_struct->m_tuple_ptr->get_mm_gci(req_struct->tablePtrP);
2577 memcpy(outBuffer + 1, &tmp,
sizeof(tmp));
2581 case AttributeHeader::ROW_GCI64:
2584 if (req_struct->tablePtrP->m_bits & Tablerec::TR_RowGCI)
2586 Uint32 tmp0 = *req_struct->m_tuple_ptr->get_mm_gci(req_struct->tablePtrP);
2587 Uint32 tmp1 = ~Uint32(0);
2588 if (req_struct->tablePtrP->m_bits & Tablerec::TR_ExtraRowGCIBits)
2591 req_struct->tablePtrP->getExtraAttrId<Tablerec::TR_ExtraRowGCIBits>();
2592 read_extra_row_bits(attrId,
2593 req_struct->tablePtrP,
2594 req_struct->m_tuple_ptr,
2598 Uint64 tmp = Uint64(tmp0) << 32 | tmp1;
2599 memcpy(outBuffer + 1, &tmp,
sizeof(tmp));
2604 case AttributeHeader::ROW_AUTHOR:
2607 if (req_struct->tablePtrP->m_bits & Tablerec::TR_ExtraRowAuthorBits)
2609 Uint32 attrId = req_struct->tablePtrP
2610 ->getExtraAttrId<Tablerec::TR_ExtraRowAuthorBits>();
2613 read_extra_row_bits(attrId,
2614 req_struct->tablePtrP,
2615 req_struct->m_tuple_ptr,
2623 case AttributeHeader::ANY_VALUE:
2634 Uint32 RlogSize = req_struct->log_size;
2635 req_struct->operPtrP->m_any_value = inBuffer[inPos];
2636 * (clogMemBuffer + RlogSize) = inBuffer[inPos - 1];
2637 * (clogMemBuffer + RlogSize + 1) = inBuffer[inPos];
2638 req_struct->out_buf_index = outPos - 4;
2639 req_struct->log_size = RlogSize + 2;
2642 case AttributeHeader::COPY_ROWID:
2644 outBuffer[1] = req_struct->operPtrP->m_copy_tuple_location.m_page_no;
2645 outBuffer[2] = req_struct->operPtrP->m_copy_tuple_location.m_page_idx;
2647 case AttributeHeader::FLUSH_AI:
2650 Uint32 resultRef = inBuffer[inPos];
2651 Uint32 resultData = inBuffer[inPos + 1];
2652 Uint32 routeRef = inBuffer[inPos + 2];
2653 flush_read_buffer(req_struct, outBuf, resultRef, resultData, routeRef);
2656 case AttributeHeader::CORR_FACTOR32:
2659 signal->theData[0] = req_struct->operPtrP->userpointer;
2660 signal->theData[1] = AttributeHeader::CORR_FACTOR64;
2663 outBuffer[1] = signal->theData[0];
2666 case AttributeHeader::CORR_FACTOR64:
2669 signal->theData[0] = req_struct->operPtrP->userpointer;
2670 signal->theData[1] = AttributeHeader::CORR_FACTOR64;
2673 outBuffer[1] = signal->theData[0];
2674 outBuffer[2] = signal->theData[1];
2677 case AttributeHeader::FRAGMENT_EXTENT_SPACE:
2680 disk_page_get_allocated(req_struct->tablePtrP, req_struct->fragPtrP, res);
2681 memcpy(outBuffer + 1, res + 0, 8);
2685 case AttributeHeader::FRAGMENT_FREE_EXTENT_SPACE:
2688 disk_page_get_allocated(req_struct->tablePtrP, req_struct->fragPtrP, res);
2689 memcpy(outBuffer + 1, res + 1, 8);
2693 case AttributeHeader::LOCK_REF:
2694 signal->theData[0] = req_struct->operPtrP->userpointer;
2695 signal->theData[1] = attrId;
2698 outBuffer[1] = signal->theData[0];
2699 outBuffer[2] = signal->theData[1];
2700 outBuffer[3] = signal->theData[2];
2703 case AttributeHeader::OP_ID:
2704 signal->theData[0] = req_struct->operPtrP->userpointer;
2705 signal->theData[1] = attrId;
2708 outBuffer[1] = signal->theData[0];
2709 outBuffer[2] = signal->theData[1];
2713 return -ZATTRIBUTE_ID_ERROR;
2717 req_struct->out_buf_index = outPos + 4*sz;
2722 Dbtup::read_packed(
const Uint32* inBuf, Uint32 inPos,
2723 KeyReqStruct *req_struct,
2726 ndbassert(req_struct->out_buf_index >= 4);
2727 ndbassert((req_struct->out_buf_index & 3) == 0);
2728 ndbassert(req_struct->out_buf_bits == 0);
2730 Tablerec *
const regTabPtr = req_struct->tablePtrP;
2731 Uint32 outPos = req_struct->out_buf_index;
2732 Uint32 outBits = req_struct->out_buf_bits;
2733 Uint32 maxRead = req_struct->max_read;
2736 Uint32 numAttributes = regTabPtr->m_no_of_attributes;
2737 Uint32 attrDescriptorStart = regTabPtr->tabDescriptor;
2738 Uint32 attrId = (* (inBuf + inPos - 1)) >> 16;
2739 Uint32 bmlen32 = ((* (inBuf + inPos - 1)) & 0xFFFF);
2742 if (attrId == AttributeHeader::READ_ALL)
2745 for (Uint32 i = 0; i<cnt; i++)
2752 cnt = 32*bmlen32 <= numAttributes ? 32*bmlen32 : numAttributes;
2753 mask.
assign(bmlen32, inBuf + inPos);
2758 nullable.
bitANDC(regTabPtr->notNullAttributeMask);
2759 Uint32 nullcnt = nullable.
count();
2760 Uint32 masksz = (cnt + nullcnt + 31) >> 5;
2762 Uint32* dst = (Uint32*)(outBuffer + ((outPos - 4) >> 2));
2763 Uint32* dstmask = dst + 1;
2765 bzero(dstmask, 4*masksz);
2768 Uint8* outBuf = (Uint8*)outBuffer;
2770 if (likely(outPos <= maxRead))
2773 for (Uint32 attrId = 0, maskpos = 0; attrId<cnt; attrId++, maskpos++)
2776 if (mask.
get(attrId))
2779 Uint32 attrDescrIdx = attrDescriptorStart + (attrId << ZAD_LOG_SIZE);
2780 Uint32 attrDesc1 = tableDescriptor[attrDescrIdx].tabDescr;
2781 Uint32 attrDesc2 = tableDescriptor[attrDescrIdx + 1].tabDescr;
2782 ReadFunction f = regTabPtr->readFunctionArray[attrId];
2786 ndbassert((outPos & 3) == 0);
2789 Uint32 save[2] = { outPos, outBits };
2790 switch(AttributeDescriptor::getSize(attrDesc1)){
2791 case DictTabInfo::aBit:
2792 outPos = (outPos + 3) & ~(Uint32)3;
2794 case DictTabInfo::an8Bit:
2795 case DictTabInfo::a16Bit:
2796 outPos = outPos + 4 * ((outBits + 31) >> 5);
2799 case DictTabInfo::a32Bit:
2800 case DictTabInfo::a64Bit:
2801 case DictTabInfo::a128Bit:
2802 outPos = ((outPos + 3) & ~(Uint32)3) + 4 * ((outBits + 31) >> 5);
2811 req_struct->out_buf_index = outPos;
2812 req_struct->out_buf_bits = outBits;
2813 req_struct->attr_descriptor = attrDesc1;
2814 if ((this->*f)(outBuf, req_struct, &ahOut, attrDesc2))
2819 outPos = req_struct->out_buf_index;
2820 outBits = req_struct->out_buf_bits;
2822 if (nullable.
get(attrId))
2841 req_struct->out_buf_index = pad32(outPos, outBits);
2842 req_struct->out_buf_bits = 0;
2851 #include <signaldata/TransIdAI.hpp>
2854 Dbtup::flush_read_buffer(KeyReqStruct *req_struct,
2855 const Uint32 * outBuf,
2860 Uint32 sig1= req_struct->trans_id1;
2861 Uint32 sig2= req_struct->trans_id2;
2862 Uint32 len = (req_struct->out_buf_index >> 2) - 1;
2863 Signal * signal = req_struct->signal;
2868 ptr[0].p= (Uint32*)outBuf;
2872 transIdAI->connectPtr= resultData;
2873 transIdAI->transId[0]= sig1;
2874 transIdAI->transId[1]= sig2;
2876 if (likely(connectedToNode))
2878 sendSignal(resultRef, GSN_TRANSID_AI, signal, 3, JBB, ptr, 1);
2883 if (outBuf == signal->theData + 3)
2890 memmove(signal->theData+25, signal->theData+3, 4*len);
2891 ptr[0].p = signal->theData+25;
2893 transIdAI->attrData[0] = resultRef;
2894 sendSignal(routeRef, GSN_TRANSID_AI_R, signal, 4, JBB, ptr, 1);
2897 req_struct->out_buf_index = 0;
2898 req_struct->out_buf_bits = 0;
2899 req_struct->read_length += len;
2903 Dbtup::update_packed(KeyReqStruct *req_struct,
const Uint32* inBuf)
2909 Dbtup::readBitsNotNULL(Uint8* outBuffer,
2910 KeyReqStruct* req_struct,
2914 Tablerec *
const regTabPtr = req_struct->tablePtrP;
2915 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
2917 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
2918 Uint32 *bmptr= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
2919 Uint32 bmlen = regTabPtr->m_offsets[MM].m_null_words;
2921 return bits_reader(outBuffer,
2929 Dbtup::readBitsNULLable(Uint8* outBuffer,
2930 KeyReqStruct* req_struct,
2934 Tablerec *
const regTabPtr = req_struct->tablePtrP;
2935 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
2937 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
2939 Uint32 *bm_ptr= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
2940 Uint32 bm_len = regTabPtr->m_offsets[MM].m_null_words;
2949 return bits_reader(outBuffer, req_struct, ahOut,
2955 Dbtup::updateBitsNotNULL(Uint32* inBuffer,
2956 KeyReqStruct* req_struct,
2959 Tablerec*
const regTabPtr = req_struct->tablePtrP;
2960 Uint32 indexBuf = req_struct->in_buf_index;
2961 Uint32 inBufLen = req_struct->in_buf_len;
2963 Uint32 nullIndicator = ahIn.isNULL();
2964 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
2966 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
2967 Uint32 newIndex = indexBuf + 1 + ((bitCount + 31) >> 5);
2968 Uint32 *bits= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
2970 if (newIndex <= inBufLen) {
2971 if (!nullIndicator) {
2973 bitCount, inBuffer+indexBuf+1);
2974 req_struct->in_buf_index = newIndex;
2978 req_struct->errorCode = ZNOT_NULL_ATTR;
2983 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
2990 Dbtup::updateBitsNULLable(Uint32* inBuffer,
2991 KeyReqStruct* req_struct,
2994 Tablerec*
const regTabPtr = req_struct->tablePtrP;
2995 Uint32 indexBuf = req_struct->in_buf_index;
2997 Uint32 nullIndicator = ahIn.isNULL();
2998 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
3000 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
3001 Uint32 *bits= req_struct->m_tuple_ptr->get_null_bits(regTabPtr);
3003 if (!nullIndicator) {
3006 bitCount, inBuffer+indexBuf+1);
3008 Uint32 newIndex = indexBuf + 1 + ((bitCount + 31) >> 5);
3009 req_struct->in_buf_index = newIndex;
3012 Uint32 newIndex = indexBuf + 1;
3013 if (newIndex <= req_struct->in_buf_len)
3018 req_struct->in_buf_index = newIndex;
3022 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3029 Dbtup::updateDiskFixedSizeNotNULL(Uint32* inBuffer,
3030 KeyReqStruct *req_struct,
3033 Uint32 attrDescriptor= req_struct->attr_descriptor;
3034 Uint32 indexBuf= req_struct->in_buf_index;
3035 Uint32 inBufLen= req_struct->in_buf_len;
3036 Uint32 updateOffset= AttributeOffset::getOffset(attrDes2);
3037 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
3040 Uint32 noOfWords= AttributeDescriptor::getSizeInWords(attrDescriptor);
3041 Uint32 nullIndicator= ahIn.isNULL();
3042 Uint32 newIndex= indexBuf + noOfWords + 1;
3043 Uint32 *tuple_header= req_struct->m_disk_ptr->m_data;
3044 ndbrequire((updateOffset + noOfWords - 1) < req_struct->check_offset[DD]);
3046 if (newIndex <= inBufLen) {
3047 if (!nullIndicator) {
3051 Tablerec * regTabPtr = req_struct->tablePtrP;
3053 Uint32 bytes = AttributeDescriptor::getSizeInBytes(attrDescriptor);
3054 Uint32 i = AttributeOffset::getCharsetPos(attrDes2);
3055 ndbrequire(i < regTabPtr->noOfCharsets);
3059 const char* ssrc = (
const char*)&inBuffer[indexBuf + 1];
3063 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
3067 if (typeId != NDB_TYPE_TEXT &&
3068 (*cs->cset->well_formed_len)(cs, ssrc + lb, ssrc + lb + len, ZNIL, ¬_used) != len) {
3070 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
3074 req_struct->in_buf_index= newIndex;
3075 MEMCOPY_NO_WORDS(&tuple_header[updateOffset],
3076 &inBuffer[indexBuf + 1],
3081 req_struct->errorCode = ZNOT_NULL_ATTR;
3086 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3092 Dbtup::updateDiskFixedSizeNULLable(Uint32* inBuffer,
3093 KeyReqStruct *req_struct,
3096 Tablerec *
const regTabPtr = req_struct->tablePtrP;
3098 Uint32 nullIndicator= ahIn.isNULL();
3099 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
3100 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
3102 if (!nullIndicator) {
3105 return updateDiskFixedSizeNotNULL(inBuffer,
3109 Uint32 newIndex= req_struct->in_buf_index + 1;
3110 if (newIndex <= req_struct->in_buf_len) {
3113 req_struct->in_buf_index= newIndex;
3117 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3124 Dbtup::updateDiskVarAsFixedSizeNotNULL(Uint32* inBuffer,
3125 KeyReqStruct* req_struct,
3128 Uint32 attrDescriptor= req_struct->attr_descriptor;
3129 Uint32 indexBuf= req_struct->in_buf_index;
3130 Uint32 inBufLen= req_struct->in_buf_len;
3131 Uint32 updateOffset= AttributeOffset::getOffset(attrDes2);
3132 Uint32 charsetFlag = AttributeOffset::getCharsetFlag(attrDes2);
3135 Uint32 noOfWords= AttributeDescriptor::getSizeInWords(attrDescriptor);
3136 Uint32 nullIndicator= ahIn.isNULL();
3137 Uint32 size_in_words= ahIn.getDataSize();
3139 Uint32 newIndex= indexBuf + size_in_words + 1;
3140 Uint32 *tuple_header= req_struct->m_disk_ptr->m_data;
3141 ndbrequire((updateOffset + noOfWords - 1) < req_struct->check_offset[DD]);
3143 if (size_in_words <= noOfWords) {
3144 if (!nullIndicator) {
3148 Tablerec* regTabPtr = req_struct->tablePtrP;
3150 Uint32 bytes= AttributeDescriptor::getSizeInBytes(attrDescriptor);
3151 Uint32 i = AttributeOffset::getCharsetPos(attrDes2);
3152 ndbrequire(i < regTabPtr->noOfCharsets);
3156 const char* ssrc = (
const char*)&inBuffer[indexBuf + 1];
3160 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
3164 if (typeId != NDB_TYPE_TEXT &&
3165 (*cs->cset->well_formed_len)(cs, ssrc + lb, ssrc + lb + len, ZNIL, ¬_used) != len) {
3167 req_struct->errorCode = ZINVALID_CHAR_FORMAT;
3172 req_struct->in_buf_index= newIndex;
3173 MEMCOPY_NO_WORDS(&tuple_header[updateOffset],
3174 &inBuffer[indexBuf + 1],
3179 req_struct->errorCode= ZNOT_NULL_ATTR;
3184 req_struct->errorCode= ZAI_INCONSISTENCY_ERROR;
3190 Dbtup::updateDiskVarAsFixedSizeNULLable(Uint32* inBuffer,
3191 KeyReqStruct *req_struct,
3194 Tablerec*
const regTabPtr = req_struct->tablePtrP;
3196 Uint32 nullIndicator= ahIn.isNULL();
3197 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
3198 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
3200 if (!nullIndicator) {
3203 return updateDiskVarAsFixedSizeNotNULL(inBuffer,
3207 Uint32 newIndex= req_struct->in_buf_index + 1;
3208 if (newIndex <= req_struct->in_buf_len) {
3211 req_struct->in_buf_index= newIndex;
3215 req_struct->errorCode= ZAI_INCONSISTENCY_ERROR;
3222 Dbtup::updateDiskVarSizeNotNULL(Uint32* in_buffer,
3223 KeyReqStruct *req_struct,
3226 Uint32 attr_descriptor, index_buf, in_buf_len, var_index, null_ind;
3227 Uint32 vsize_in_words, new_index, max_var_size;
3228 Uint32 var_attr_pos;
3229 char *var_data_start;
3232 attr_descriptor= req_struct->attr_descriptor;
3233 index_buf= req_struct->in_buf_index;
3234 in_buf_len= req_struct->in_buf_len;
3235 var_index= AttributeOffset::getOffset(attr_des2);
3237 null_ind= ahIn.isNULL();
3238 Uint32 size_in_bytes = ahIn.getByteSize();
3239 vsize_in_words= (size_in_bytes + 3) >> 2;
3240 max_var_size= AttributeDescriptor::getSizeInBytes(attr_descriptor);
3241 new_index= index_buf + vsize_in_words + 1;
3242 vpos_array= req_struct->m_var_data[DD].m_offset_array_ptr;
3243 Uint32 idx= req_struct->m_var_data[DD].m_var_len_offset;
3244 Uint32 check_offset= req_struct->m_var_data[DD].m_max_var_offset;
3246 if (new_index <= in_buf_len && vsize_in_words <= max_var_size) {
3249 var_attr_pos= vpos_array[var_index];
3250 var_data_start= req_struct->m_var_data[DD].m_data_ptr;
3251 vpos_array[var_index+idx]= var_attr_pos+size_in_bytes;
3252 req_struct->in_buf_index= new_index;
3254 ndbrequire(var_attr_pos+size_in_bytes <= check_offset);
3255 memcpy(var_data_start+var_attr_pos, &in_buffer[index_buf + 1],
3260 req_struct->errorCode = ZNOT_NULL_ATTR;
3265 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3272 Dbtup::updateDiskVarSizeNULLable(Uint32* inBuffer,
3273 KeyReqStruct *req_struct,
3276 Tablerec *
const regTabPtr = req_struct->tablePtrP;
3278 Uint32 nullIndicator= ahIn.isNULL();
3279 Uint32 pos= AttributeOffset::getNullFlagPos(attrDes2);
3280 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
3281 Uint32 idx= req_struct->m_var_data[DD].m_var_len_offset;
3283 if (!nullIndicator) {
3286 return updateDiskVarSizeNotNULL(inBuffer,
3290 Uint32 newIndex= req_struct->in_buf_index + 1;
3291 Uint32 var_index= AttributeOffset::getOffset(attrDes2);
3292 Uint32 var_pos= req_struct->var_pos_array[var_index];
3293 if (newIndex <= req_struct->in_buf_len) {
3296 req_struct->var_pos_array[var_index+idx]= var_pos;
3297 req_struct->in_buf_index= newIndex;
3301 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3308 Dbtup::updateDiskBitsNotNULL(Uint32* inBuffer,
3309 KeyReqStruct* req_struct,
3312 Tablerec*
const regTabPtr = req_struct->tablePtrP;
3313 Uint32 indexBuf = req_struct->in_buf_index;
3314 Uint32 inBufLen = req_struct->in_buf_len;
3316 Uint32 nullIndicator = ahIn.isNULL();
3317 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
3319 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
3320 Uint32 newIndex = indexBuf + 1 + ((bitCount + 31) >> 5);
3321 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
3323 if (newIndex <= inBufLen) {
3324 if (!nullIndicator) {
3326 bitCount, inBuffer+indexBuf+1);
3327 req_struct->in_buf_index = newIndex;
3331 req_struct->errorCode = ZNOT_NULL_ATTR;
3336 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3343 Dbtup::updateDiskBitsNULLable(Uint32* inBuffer,
3344 KeyReqStruct* req_struct,
3347 Tablerec*
const regTabPtr = req_struct->tablePtrP;
3348 Uint32 indexBuf = req_struct->in_buf_index;
3350 Uint32 nullIndicator = ahIn.isNULL();
3351 Uint32 pos = AttributeOffset::getNullFlagPos(attrDes2);
3353 AttributeDescriptor::getArraySize(req_struct->attr_descriptor);
3354 Uint32 *bits= req_struct->m_disk_ptr->get_null_bits(regTabPtr, DD);
3356 if (!nullIndicator) {
3359 bitCount, inBuffer+indexBuf+1);
3361 Uint32 newIndex = indexBuf + 1 + ((bitCount + 31) >> 5);
3362 req_struct->in_buf_index = newIndex;
3365 Uint32 newIndex = indexBuf + 1;
3366 if (newIndex <= req_struct->in_buf_len)
3371 req_struct->in_buf_index = newIndex;
3375 req_struct->errorCode = ZAI_INCONSISTENCY_ERROR;
3382 Dbtup::read_lcp(
const Uint32* inBuf, Uint32 inPos,
3383 KeyReqStruct *req_struct,
3386 ndbassert(req_struct->out_buf_index >= 4);
3387 ndbassert((req_struct->out_buf_index & 3) == 0);
3388 ndbassert(req_struct->out_buf_bits == 0);
3390 Tablerec*
const regTabPtr = req_struct->tablePtrP;
3391 Uint32 outPos = req_struct->out_buf_index;
3393 Uint32 fixsz = 4 * (regTabPtr->m_offsets[MM].m_fix_header_size - Tuple_header::HeaderSize);
3396 if (req_struct->m_tuple_ptr->m_header_bits & Tuple_header::VAR_PART)
3398 ndbassert(req_struct->is_expanded ==
false);
3399 varstart = (
char*)req_struct->m_var_data[MM].m_offset_array_ptr;
3400 char * end = req_struct->m_var_data->m_dyn_data_ptr +
3401 4*req_struct->m_var_data[MM].m_dyn_part_len;
3402 varlen = Uint32(end - varstart);
3403 varlen = (varlen + 3) & ~(Uint32)3;
3404 ndbassert(varlen < 32768);
3406 Uint32 totsz = fixsz + varlen;
3408 Uint32* dst = (Uint32*)(outBuffer + ((outPos - 4) >> 2));
3409 dst[0] = req_struct->frag_page_id;
3410 dst[1] = req_struct->operPtrP->m_tuple_location.m_page_idx;
3411 ndbassert(req_struct->m_tuple_ptr->m_data != 0);
3412 memcpy(dst+2, req_struct->m_tuple_ptr->m_data, fixsz);
3416 memcpy(dst + 2 + (fixsz >> 2), varstart, varlen);
3419 req_struct->out_buf_index = outPos + 8 + totsz - 4;
3425 Dbtup::update_lcp(KeyReqStruct* req_struct,
const Uint32 * src, Uint32 len)
3427 Tablerec*
const tabPtrP = req_struct->tablePtrP;
3429 req_struct->m_is_lcp =
true;
3430 Uint32 fixsz32 = (tabPtrP->m_offsets[MM].m_fix_header_size - Tuple_header::HeaderSize);
3431 Uint32 fixsz = 4 * fixsz32;
3432 Tuple_header* ptr = (Tuple_header*)req_struct->m_tuple_ptr;
3433 memcpy(ptr->m_data, src, fixsz);
3435 Uint16 mm_vars= tabPtrP->m_attributes[MM].m_no_of_varsize;
3436 Uint16 mm_dyns= tabPtrP->m_attributes[MM].m_no_of_dynamic;
3438 Uint32 varlen32 = 0;
3439 if (mm_vars || mm_dyns)
3441 varlen32 = len - fixsz32;
3444 ndbassert(len > fixsz32);
3446 Varpart_copy* vp = (Varpart_copy*)ptr->get_end_of_fix_part_ptr(tabPtrP);
3447 vp->m_len = varlen32;
3448 memcpy(vp->m_data, src + fixsz32, 4*varlen32);
3450 req_struct->m_lcp_varpart_len = varlen32;
3451 ptr->m_header_bits |= (tabPtrP->m_bits & Tablerec::TR_DiskPart) ?
3452 Tuple_header::DISK_PART : 0;
3453 ptr->m_header_bits |= (varlen32) ? Tuple_header::VAR_PART : 0;
3455 req_struct->changeMask.set();
3460 const Uint32 * src, Uint32 len, Uint32 *dst)
3464 ptrCheckGuard(tabPtr, cnoOfTablerec, tablerec);
3473 req_struct.m_tuple_ptr = ptr;
3474 req_struct.check_offset[MM]= len;
3475 req_struct.is_expanded =
false;
3481 Uint16 mm_vars = tabPtrP->m_attributes[MM].m_no_of_varsize;
3482 Uint16 mm_dyns = tabPtrP->m_attributes[MM].m_no_of_dynamic;
3483 Uint32 src_len = Tuple_header::HeaderSize + len - tabPtrP->m_offsets[MM].m_fix_header_size;
3485 const Uint32 *src_ptr= ptr->get_end_of_fix_part_ptr(tabPtrP);
3486 if(mm_vars || mm_dyns)
3488 const Uint32 *src_data= src_ptr;
3493 char* varstart = (
char*)(((Uint16*)src_data)+mm_vars+1);
3494 Uint32 varlen = ((Uint16*)src_data)[mm_vars];
3495 Uint32* dynstart = ALIGN_WORD(varstart + varlen);
3497 dst->m_data_ptr= varstart;
3498 dst->m_offset_array_ptr= (Uint16*)src_data;
3499 dst->m_var_len_offset= 1;
3500 dst->m_max_var_offset= varlen;
3502 Uint32 dynlen = Uint32(src_len - (dynstart - src_data));
3503 dst->m_dyn_data_ptr= (
char*)dynstart;
3504 dst->m_dyn_part_len= dynlen;
3508 dst->m_dyn_data_ptr= (
char*)src_data;
3509 dst->m_dyn_part_len= src_len;
3514 Uint32 descr_start= tabPtrP->tabDescriptor;
3516 req_struct.attr_descr= tab_descr;
3517 const Uint32* attrIds= &tableDescriptor[tabPtrP->readKeyArray].tabDescr;
3518 const Uint32 numAttrs= tabPtrP->noOfKeyAttr;
3523 int ret = readAttributes(&req_struct,
3533 for (Uint32 * end = src + ret; src < end;)
3536 memmove(tmp, src + 1, 4*ah.getDataSize());
3537 tmp += ah.getDataSize();
3538 src += 1 + ah.getDataSize();
3543 ndbrequire(ret > 0);
3549 Dbtup::store_extra_row_bits(Uint32 extra_no,
3550 const Tablerec* regTabPtr,
3556 if (unlikely(extra_no >= regTabPtr->m_no_of_extra_columns))
3561 Uint32 num_attr= regTabPtr->m_no_of_attributes;
3562 Uint32 attrId = num_attr + extra_no;
3563 Uint32 descr_start = regTabPtr->tabDescriptor;
3564 TableDescriptor *tab_descr = &tableDescriptor[descr_start];
3565 ndbrequire(descr_start + (attrId << ZAD_LOG_SIZE)<= cnoOfTabDescrRec);
3567 Uint32 attrDescriptorIndex = attrId << ZAD_LOG_SIZE;
3568 Uint32 attrDescriptor = tab_descr[attrDescriptorIndex].tabDescr;
3569 Uint32 attrOffset = tab_descr[attrDescriptorIndex + 1].tabDescr;
3571 Uint32 pos = AttributeOffset::getNullFlagPos(attrOffset);
3572 Uint32 bitCount = AttributeDescriptor::getArraySize(attrDescriptor);
3573 Uint32 maxVal = (1 << bitCount) - 1;
3574 Uint32 *bits= ptr->get_null_bits(regTabPtr);
3588 Uint32 check = regTabPtr->m_offsets[MM].m_null_words;
3594 Dbtup::read_extra_row_bits(Uint32 extra_no,
3595 const Tablerec* regTabPtr,
3603 ndbrequire(extra_no < regTabPtr->m_no_of_extra_columns);
3604 Uint32 num_attr= regTabPtr->m_no_of_attributes;
3605 Uint32 attrId = num_attr + extra_no;
3606 Uint32 descr_start = regTabPtr->tabDescriptor;
3607 TableDescriptor *tab_descr = &tableDescriptor[descr_start];
3608 ndbrequire(descr_start + (attrId << ZAD_LOG_SIZE)<= cnoOfTabDescrRec);
3610 Uint32 attrDescriptorIndex = attrId << ZAD_LOG_SIZE;
3611 Uint32 attrDescriptor = tab_descr[attrDescriptorIndex].tabDescr;
3612 Uint32 attrOffset = tab_descr[attrDescriptorIndex + 1].tabDescr;
3614 Uint32 pos = AttributeOffset::getNullFlagPos(attrOffset);
3615 Uint32 bitCount = AttributeDescriptor::getArraySize(attrDescriptor);
3616 Uint32 maxVal = (1 << bitCount) - 1;
3617 Uint32 *bits= ptr->get_null_bits(regTabPtr);
3620 Uint32 check = regTabPtr->m_offsets[MM].m_null_words;
3623 if (tmp == maxVal && extend)