summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpekka@mysql.com <>2004-06-14 15:21:00 +0200
committerpekka@mysql.com <>2004-06-14 15:21:00 +0200
commit0dea4c66448da0b5ef2d237ff3d9bfce9b27f638 (patch)
tree02d4fa78e7a6b90df24e11d604cb455dd92f61aa
parent9a8621830dc818bdb9ece9b55f9bba26172a4932 (diff)
downloadmariadb-git-0dea4c66448da0b5ef2d237ff3d9bfce9b27f638.tar.gz
testBlobs.cpp, NdbBlob.cpp:
small blob fix
-rw-r--r--ndb/src/ndbapi/NdbBlob.cpp27
-rw-r--r--ndb/test/ndbapi/testBlobs.cpp4
2 files changed, 24 insertions, 7 deletions
diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp
index 39d8c6a0e37..8e067f770e8 100644
--- a/ndb/src/ndbapi/NdbBlob.cpp
+++ b/ndb/src/ndbapi/NdbBlob.cpp
@@ -35,6 +35,17 @@
#define DBG(x)
#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
* bugs or limitations. Keep the code but make possible to choose.
@@ -296,7 +307,7 @@ NdbBlob::getTableKeyValue(NdbOperation* anOp)
}
// odd bytes receive no data and must be zeroed
while (len % 4 != 0) {
- char* p = (char*)data + len++;
+ char* p = (char*)&data[pos] + len++;
*p = 0;
}
pos += len / 4;
@@ -311,8 +322,9 @@ NdbBlob::setTableKeyValue(NdbOperation* anOp)
{
const Uint32* data = (const Uint32*)theKeyBuf.data;
unsigned pos = 0;
- DBG("setTableKeyValue key0=" << data[0]);
- for (unsigned i = 0; i < theTable->m_columns.size(); i++) {
+ const unsigned size = theTable->m_columns.size();
+ DBG("setTableKeyValue key=" << ndb_blob_debug(data, size));
+ for (unsigned i = 0; i < size; i++) {
NdbColumnImpl* c = theTable->m_columns[i];
assert(c != NULL);
if (c->m_pk) {
@@ -333,8 +345,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp)
{
const Uint32* data = (const Uint32*)theAccessKeyBuf.data;
unsigned pos = 0;
- DBG("setAccessKeyValue key0=" << data[0]);
- for (unsigned i = 0; i < theAccessTable->m_columns.size(); i++) {
+ const unsigned size = theAccessTable->m_columns.size();
+ DBG("setAccessKeyValue key=" << ndb_blob_debug(data, size));
+ for (unsigned i = 0; i < size; i++) {
NdbColumnImpl* c = theAccessTable->m_columns[i];
assert(c != NULL);
if (c->m_pk) {
@@ -353,7 +366,9 @@ NdbBlob::setAccessKeyValue(NdbOperation* anOp)
int
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 ||
anOp->equal((Uint32)1, part) == -1 ||
anOp->equal((Uint32)2, theKeyBuf.data) == -1) {
diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp
index 9d083d800f7..001ec83630a 100644
--- a/ndb/test/ndbapi/testBlobs.cpp
+++ b/ndb/test/ndbapi/testBlobs.cpp
@@ -72,7 +72,7 @@ struct Opt {
m_tname("TBLOB1"),
m_x1name("TBLOB1X1"),
m_x2name("TBLOB1X2"),
- m_pk1off(999000000),
+ m_pk1off(0x12340000),
m_pk2len(55),
m_oneblob(false),
m_blob1(false, 7, 1137, 10),
@@ -988,6 +988,8 @@ testmain()
bool ulim = skip('w') ? false : true;
// pk
for (int rw = llim; rw <= ulim; rw++) {
+ if (skip('k'))
+ continue;
DBG("--- pk ops " << (! rw ? "get/set" : "read/write") << " ---");
calcTups(false);
CHK(insertPk(rw) == 0);