Commit 0dea4c66 authored by pekka@mysql.com's avatar pekka@mysql.com

testBlobs.cpp, NdbBlob.cpp:

  small blob fix
parent 9a862183
...@@ -35,6 +35,17 @@ ...@@ -35,6 +35,17 @@
#define DBG(x) #define DBG(x)
#endif #endif
static char*
ndb_blob_debug(const Uint32* data, unsigned size)
{
static char buf[128 + 1]; // MT irrelevant
buf[0] = 0;
for (unsigned i = 0; i < size && i < 128 / 4; i++) {
sprintf(buf + strlen(buf), "%*s%08x", i != 0, "", data[i]);
}
return buf;
}
/* /*
* Reading index table directly (as a table) is faster but there are * Reading index table directly (as a table) is faster but there are
* bugs or limitations. Keep the code but make possible to choose. * bugs or limitations. Keep the code but make possible to choose.
...@@ -296,7 +307,7 @@ NdbBlob::getTableKeyValue(NdbOperation* anOp) ...@@ -296,7 +307,7 @@ NdbBlob::getTableKeyValue(NdbOperation* anOp)
} }
// odd bytes receive no data and must be zeroed // odd bytes receive no data and must be zeroed
while (len % 4 != 0) { while (len % 4 != 0) {
char* p = (char*)data + len++; char* p = (char*)&data[pos] + len++;
*p = 0; *p = 0;
} }
pos += len / 4; pos += len / 4;
...@@ -311,8 +322,9 @@ NdbBlob::setTableKeyValue(NdbOperation* anOp) ...@@ -311,8 +322,9 @@ NdbBlob::setTableKeyValue(NdbOperation* anOp)
{ {
const Uint32* data = (const Uint32*)theKeyBuf.data; const Uint32* data = (const Uint32*)theKeyBuf.data;
unsigned pos = 0; unsigned pos = 0;
DBG("setTableKeyValue key0=" << data[0]); const unsigned size = theTable->m_columns.size();
for (unsigned i = 0; i < theTable->m_columns.size(); i++) { DBG("setTableKeyValue key=" << ndb_blob_debug(data, size));
for (unsigned i = 0; i < size; i++) {
NdbColumnImpl* c = theTable->m_columns[i]; NdbColumnImpl* c = theTable->m_columns[i];
assert(c != NULL); assert(c != NULL);
if (c->m_pk) { if (c->m_pk) {
...@@ -333,8 +345,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp) ...@@ -333,8 +345,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp)
{ {
const Uint32* data = (const Uint32*)theAccessKeyBuf.data; const Uint32* data = (const Uint32*)theAccessKeyBuf.data;
unsigned pos = 0; unsigned pos = 0;
DBG("setAccessKeyValue key0=" << data[0]); const unsigned size = theAccessTable->m_columns.size();
for (unsigned i = 0; i < theAccessTable->m_columns.size(); i++) { DBG("setAccessKeyValue key=" << ndb_blob_debug(data, size));
for (unsigned i = 0; i < size; i++) {
NdbColumnImpl* c = theAccessTable->m_columns[i]; NdbColumnImpl* c = theAccessTable->m_columns[i];
assert(c != NULL); assert(c != NULL);
if (c->m_pk) { if (c->m_pk) {
...@@ -353,7 +366,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp) ...@@ -353,7 +366,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp)
int int
NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part)
{ {
DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key0=" << *(Uint32*)theKeyBuf.data); Uint32* data = (Uint32*)theKeyBuf.data;
unsigned size = theTable->m_sizeOfKeysInWords;
DBG("setPartKeyValue dist=" << getDistKey(part) << " part=" << part << " key=" << ndb_blob_debug(data, size));
if (anOp->equal((Uint32)0, getDistKey(part)) == -1 || if (anOp->equal((Uint32)0, getDistKey(part)) == -1 ||
anOp->equal((Uint32)1, part) == -1 || anOp->equal((Uint32)1, part) == -1 ||
anOp->equal((Uint32)2, theKeyBuf.data) == -1) { anOp->equal((Uint32)2, theKeyBuf.data) == -1) {
......
...@@ -72,7 +72,7 @@ struct Opt { ...@@ -72,7 +72,7 @@ struct Opt {
m_tname("TBLOB1"), m_tname("TBLOB1"),
m_x1name("TBLOB1X1"), m_x1name("TBLOB1X1"),
m_x2name("TBLOB1X2"), m_x2name("TBLOB1X2"),
m_pk1off(999000000), m_pk1off(0x12340000),
m_pk2len(55), m_pk2len(55),
m_oneblob(false), m_oneblob(false),
m_blob1(false, 7, 1137, 10), m_blob1(false, 7, 1137, 10),
...@@ -988,6 +988,8 @@ testmain() ...@@ -988,6 +988,8 @@ testmain()
bool ulim = skip('w') ? false : true; bool ulim = skip('w') ? false : true;
// pk // pk
for (int rw = llim; rw <= ulim; rw++) { for (int rw = llim; rw <= ulim; rw++) {
if (skip('k'))
continue;
DBG("--- pk ops " << (! rw ? "get/set" : "read/write") << " ---"); DBG("--- pk ops " << (! rw ? "get/set" : "read/write") << " ---");
calcTups(false); calcTups(false);
CHK(insertPk(rw) == 0); CHK(insertPk(rw) == 0);
......
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