diff --git a/storage/ndb/include/kernel/AttributeHeader.hpp b/storage/ndb/include/kernel/AttributeHeader.hpp index a8b811e4efa..092379d61de 100644 --- a/storage/ndb/include/kernel/AttributeHeader.hpp +++ b/storage/ndb/include/kernel/AttributeHeader.hpp @@ -51,8 +51,7 @@ public: // NOTE: in 5.1 ctors and init take size in bytes /** Initialize AttributeHeader at location aHeaderPtr */ - static AttributeHeader& init(void* aHeaderPtr, Uint32 anAttributeId, - Uint32 aByteSize); + static void init(Uint32* aHeaderPtr, Uint32 anAttributeId, Uint32 aByteSize); /** Returns size of AttributeHeader (usually one or two words) */ Uint32 getHeaderSize() const; // In 32-bit words @@ -112,10 +111,11 @@ public: */ inline -AttributeHeader& AttributeHeader::init(void* aHeaderPtr, Uint32 anAttributeId, - Uint32 aByteSize) +void AttributeHeader::init(Uint32* aHeaderPtr, Uint32 anAttributeId, + Uint32 aByteSize) { - return * new (aHeaderPtr) AttributeHeader(anAttributeId, aByteSize); + AttributeHeader ah(anAttributeId, aByteSize); + *aHeaderPtr = ah.m_value; } inline diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index bba894db7fd..3b81df159e4 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1940,9 +1940,8 @@ int Dbtup::interpreterNextLab(Signal* signal, Uint32 TdataForUpdate[3]; Uint32 Tlen; - AttributeHeader& ah= AttributeHeader::init(&TdataForUpdate[0], - TattrId, - TattrNoOfWords << 2); + AttributeHeader ah(TattrId, TattrNoOfWords << 2); + TdataForUpdate[0]= ah.m_value; TdataForUpdate[1]= TregMemBuffer[theRegister + 2]; TdataForUpdate[2]= TregMemBuffer[theRegister + 3]; Tlen= TattrNoOfWords + 1; @@ -1958,6 +1957,7 @@ int Dbtup::interpreterNextLab(Signal* signal, // Write a NULL value into the attribute /* --------------------------------------------------------- */ ah.setNULL(); + TdataForUpdate[0]= ah.m_value; Tlen= 1; } int TnoDataRW= updateAttributes(req_struct, diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp index eb94e2c3473..54f51499d9d 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupRoutines.cpp @@ -802,9 +802,7 @@ Dbtup::checkUpdateOfPrimaryKey(KeyReqStruct* req_struct, Tablerec* const regTabPtr) { Uint32 keyReadBuffer[MAX_KEY_SIZE_IN_WORDS]; - Uint32 attributeHeader; TableDescriptor* attr_descr = req_struct->attr_descr; - AttributeHeader* ahOut = (AttributeHeader*)&attributeHeader; AttributeHeader ahIn(*updateBuffer); Uint32 attributeId = ahIn.getAttributeId(); Uint32 attrDescriptorIndex = attributeId << ZAD_LOG_SIZE; @@ -827,7 +825,7 @@ Dbtup::checkUpdateOfPrimaryKey(KeyReqStruct* req_struct, ReadFunction f = regTabPtr->readFunctionArray[attributeId]; - AttributeHeader::init(&attributeHeader, attributeId, 0); + AttributeHeader attributeHeader(attributeId, 0); req_struct->out_buf_index = 0; req_struct->max_read = MAX_KEY_SIZE_IN_WORDS; req_struct->attr_descriptor = attrDescriptor; @@ -836,12 +834,12 @@ Dbtup::checkUpdateOfPrimaryKey(KeyReqStruct* req_struct, req_struct->xfrm_flag = true; ndbrequire((this->*f)(&keyReadBuffer[0], req_struct, - ahOut, + &attributeHeader, attributeOffset)); req_struct->xfrm_flag = tmp; - ndbrequire(req_struct->out_buf_index == ahOut->getDataSize()); - if (ahIn.getDataSize() != ahOut->getDataSize()) { + ndbrequire(req_struct->out_buf_index == attributeHeader.getDataSize()); + if (ahIn.getDataSize() != attributeHeader.getDataSize()) { ljam(); return true; } diff --git a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp index 550e255061f..f34bc41af06 100644 --- a/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp +++ b/storage/ndb/src/kernel/blocks/dbutil/DbUtil.cpp @@ -1169,9 +1169,7 @@ DbUtil::prepareOperation(Signal* signal, PreparePtr prepPtr) /************************************************************** * Attribute found - store in mapping (AttributeId, Position) **************************************************************/ - AttributeHeader & attrMap = - AttributeHeader::init(attrMappingIt.data, - attrDesc.AttributeId, // 1. Store AttrId + AttributeHeader attrMap(attrDesc.AttributeId, // 1. Store AttrId 0); if (attrDesc.AttributeKeyFlag) { @@ -1200,6 +1198,7 @@ DbUtil::prepareOperation(Signal* signal, PreparePtr prepPtr) return; } } + *(attrMappingIt.data) = attrMap.m_value; #if 0 ndbout << "BEFORE: attrLength: " << attrLength << endl; #endif diff --git a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp index ba26831749d..62350fe2c06 100644 --- a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp @@ -363,9 +363,8 @@ NdbOperation::getValue_impl(const NdbColumnImpl* tAttrInfo, char* aValue) return NULL; }//if }//if - Uint32 ah; - AttributeHeader::init(&ah, tAttrInfo->m_attrId, 0); - if (insertATTRINFO(ah) != -1) { + AttributeHeader ah(tAttrInfo->m_attrId, 0); + if (insertATTRINFO(ah.m_value) != -1) { // Insert Attribute Id into ATTRINFO part. /************************************************************************ @@ -491,12 +490,11 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo, tAttrId = tAttrInfo->m_attrId; m_no_disk_flag &= (tAttrInfo->m_storageType == NDB_STORAGETYPE_DISK ? 0:1); const char *aValue = aValuePassed; - Uint32 ahValue; if (aValue == NULL) { if (tAttrInfo->m_nullable) { - AttributeHeader& ah = AttributeHeader::init(&ahValue, tAttrId, 0); + AttributeHeader ah(tAttrId, 0); ah.setNULL(); - insertATTRINFO(ahValue); + insertATTRINFO(ah.m_value); // Insert Attribute Id with the value // NULL into ATTRINFO part. DBUG_RETURN(0); @@ -534,8 +532,8 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo, const Uint32 totalSizeInWords = (sizeInBytes + 3)/4; // Excluding bits in last word const Uint32 sizeInWords = sizeInBytes / 4; - AttributeHeader& ah = AttributeHeader::init(&ahValue, tAttrId, sizeInBytes); - insertATTRINFO( ahValue ); + AttributeHeader ah(tAttrId, sizeInBytes); + insertATTRINFO( ah.m_value ); /*********************************************************************** * Check if the pointer of the value passed is aligned on a 4 byte boundary.