ndb - rel5.1.16 NdbRecAttr print of blob length assumed uint64 aligned buffer

ndb - 5.1.16 uint64 align for ndb_restore
(backport)
parent 120eaec1
...@@ -346,27 +346,27 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) ...@@ -346,27 +346,27 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r)
} }
break; break;
case NdbDictionary::Column::Blob: case NdbDictionary::Column::Blob:
{
const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef();
out << h->length << ":";
const unsigned char* p = (const unsigned char*)(h + 1);
unsigned n = r.arraySize() - sizeof(*h);
for (unsigned k = 0; k < n && k < h->length; k++)
out.print("%02X", (int)p[k]);
j = length;
}
break;
case NdbDictionary::Column::Text: case NdbDictionary::Column::Text:
{ {
const NdbBlob::Head* h = (const NdbBlob::Head*)r.aRef(); // user defined aRef() may not be aligned to Uint64
out << h->length << ":"; NdbBlob::Head head;
const unsigned char* p = (const unsigned char*)(h + 1); memcpy(&head, r.aRef(), sizeof(head));
unsigned n = r.arraySize() - sizeof(*h); out << head.length << ":";
for (unsigned k = 0; k < n && k < h->length; k++) const unsigned char* p = (const unsigned char*)r.aRef() + sizeof(head);
out.print("%c", (int)p[k]); if (r.arraySize() < sizeof(head))
j = length; out << "***error***"; // really cannot happen
else {
unsigned n = r.arraySize() - sizeof(head);
for (unsigned k = 0; k < n && k < head.length; k++) {
if (r.getType() == NdbDictionary::Column::Blob)
out.print("%02X", (int)p[k]);
else
out.print("%c", (int)p[k]);
}
} }
break; j = length;
}
break;
case NdbDictionary::Column::Longvarchar: case NdbDictionary::Column::Longvarchar:
{ {
unsigned len = uint2korr(r.aRef()); unsigned len = uint2korr(r.aRef());
......
...@@ -54,7 +54,12 @@ BackupFile::Twiddle(const AttributeDesc* attr_desc, AttributeData* attr_data, Ui ...@@ -54,7 +54,12 @@ BackupFile::Twiddle(const AttributeDesc* attr_desc, AttributeData* attr_data, Ui
return true; return true;
case 64: case 64:
for(i = 0; i<arraySize; i++){ for(i = 0; i<arraySize; i++){
attr_data->u_int64_value[i] = Twiddle64(attr_data->u_int64_value[i]); // allow unaligned
char* p = (char*)&attr_data->u_int64_value[i];
Uint64 x;
memcpy(&x, p, sizeof(Uint64));
x = Twiddle64(x);
memcpy(p, &x, sizeof(Uint64));
} }
return true; return true;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment