summaryrefslogtreecommitdiff
path: root/ndb/src/ndbapi/NdbOperationDefine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ndb/src/ndbapi/NdbOperationDefine.cpp')
-rw-r--r--ndb/src/ndbapi/NdbOperationDefine.cpp33
1 files changed, 25 insertions, 8 deletions
diff --git a/ndb/src/ndbapi/NdbOperationDefine.cpp b/ndb/src/ndbapi/NdbOperationDefine.cpp
index aaaf64b2986..bb56008cd87 100644
--- a/ndb/src/ndbapi/NdbOperationDefine.cpp
+++ b/ndb/src/ndbapi/NdbOperationDefine.cpp
@@ -570,15 +570,32 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo,
* If it is not aligned then we start by copying the value to tempData and
* use this as aValue instead.
*************************************************************************/
- const int attributeSize = sizeInBytes;
- const int slack = sizeInBytes & 3;
+ int attributeSize = sizeInBytes;
+ int slack = (sizeInBytes & 3) ? 4 - (sizeInBytes & 3) : 0;
+ switch(tAttrInfo->m_type){
+ case NdbDictionary::Column::Varchar:
+ case NdbDictionary::Column::Varbinary:
+ attributeSize = 1 + *(Uint8*)aValue;
+ slack = 4 * totalSizeInWords - attributeSize;
+ break;
+ case NdbDictionary::Column::Longvarchar:
+ case NdbDictionary::Column::Longvarbinary:
+ {
+ const Uint8* ptr = (const Uint8*)aValue;
+ attributeSize = 2 + ptr[0] + 256 * ptr[1];
+ slack = 4 * totalSizeInWords - attributeSize;
+ break;
+ }
+ }
- if (((UintPtr)aValue & 3) != 0 || (slack != 0)){
- memcpy(&tempData[0], aValue, attributeSize);
- aValue = (char*)&tempData[0];
- if(slack != 0) {
- char * tmp = (char*)&tempData[0];
- memset(&tmp[attributeSize], 0, (4 - slack));
+ if (((UintPtr)aValue & 3) != 0 || (slack != 0))
+ {
+ char * tmp = (char*)tempData;
+ memcpy(tmp, aValue, attributeSize);
+ aValue = tmp;
+ if(slack != 0)
+ {
+ bzero(tmp + attributeSize, slack);
}//if
}//if