19 #include <ndb_global.h>
21 #include <NdbRecAttr.hpp>
22 #include <NdbBlob.hpp>
23 #include "NdbDictionaryImpl.hpp"
26 NdbRecAttr::NdbRecAttr(
Ndb*)
40 return setup(&(col->m_impl), aValue);
44 NdbRecAttr::setup(
const NdbColumnImpl* anAttrInfo,
char* aValue)
46 Uint32 tAttrSize = anAttrInfo->m_attrSize;
47 Uint32 tArraySize = anAttrInfo->m_arraySize;
48 Uint32 tAttrByteSize = tAttrSize * tArraySize;
50 m_column = anAttrInfo;
52 theAttrId = anAttrInfo->m_attrId;
53 m_size_in_bytes = tAttrByteSize;
55 return setup(tAttrByteSize, aValue);
59 NdbRecAttr::setup(Uint32 byteSize,
char* aValue)
71 if (aValue != NULL && (UintPtr(aValue)&3) == 0 && (byteSize&3) == 0) {
84 Uint32 tSize = (byteSize + 7) >> 3;
85 Uint64* tRef =
new Uint64[tSize];
87 for (Uint32
i = 0;
i < tSize;
i++) {
100 NdbRecAttr::copyout()
102 char* tRef = (
char*)theRef;
103 char* tValue = theValue;
104 if (tRef != tValue && tRef != NULL && tValue != NULL) {
105 Uint32
n = m_size_in_bytes;
120 ret->theAttrId = theAttrId;
121 ret->m_size_in_bytes = m_size_in_bytes;
122 ret->m_column = m_column;
124 Uint32
n = m_size_in_bytes;
126 ret->theRef = (
char*)&ret->theStorage[0];
127 ret->theStorageX = 0;
130 ret->theStorageX =
new Uint64[((n + 7) >> 3)];
131 if (ret->theStorageX == NULL)
137 ret->theRef = (
char*)ret->theStorageX;
140 memcpy(ret->theRef, theRef, n);
145 NdbRecAttr::receive_data(
const Uint32 * data32, Uint32 sz)
147 const unsigned char* data = (
const unsigned char*)data32;
150 if (unlikely(m_getVarValue != NULL)) {
155 Uint32 len = data[0] + (data[1] << 8);
156 assert(len == sz - 2);
157 assert(len < (1 << 16));
158 *m_getVarValue = len;
162 if(!copyoutRequired())
163 memcpy(theRef, data, sz);
165 memcpy(theValue, data, sz);
179 ndbrecattr_print_formatted(NdbOut& out,
const NdbRecAttr &r,
182 return NdbDictionary::printFormattedValue(out,
190 return ndbrecattr_print_formatted(out, r, default_print_format);
197 memcpy(&val,theRef,8);
205 memcpy(&val,theRef,8);
213 memcpy(&val,theRef,
sizeof(val));
221 memcpy(&val,theRef,
sizeof(val));
228 return sint3korr((
unsigned char *)theRef);
234 return uint3korr((
unsigned char*)theRef);