From f6dff046e44afe5061972471abd7555856297a69 Mon Sep 17 00:00:00 2001 From: "pekka@mysql.com" <> Date: Tue, 8 Feb 2005 10:33:58 +0100 Subject: [PATCH] ndb - workaround to strnxfrm 5.0 problem --- ndb/src/common/util/NdbSqlUtil.cpp | 3 +++ ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp | 2 +- ndb/test/ndbapi/testOIBasic.cpp | 12 ++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index b691b4cb512..bff829cbaf8 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -15,6 +15,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include int NdbSqlUtil::char_compare(const char* s1, unsigned n1, @@ -858,6 +859,8 @@ NdbSqlUtil::strnxfrm_bug7284(CHARSET_INFO* cs, unsigned char* dst, unsigned dstL int n2 = (*cs->coll->strnxfrm)(cs, xsp, sizeof(xsp), nsp, n1); if (n2 <= 0) return -1; + // XXX bug workaround - strnxfrm may not write full string + memset(dst, 0x0, dstLen); // strxfrm argument string - returns no error indication int n3 = (*cs->coll->strnxfrm)(cs, dst, dstLen, src, srcLen); // pad with strxfrm-ed space chars diff --git a/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp b/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp index f50d3a49df6..5640fdf2899 100644 --- a/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp +++ b/ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp @@ -250,7 +250,7 @@ Dbtux::readKeyAttrs(const Frag& frag, TreeEnt ent, unsigned start, Data keyData) debugOut << "readKeyAttrs:" << endl; ConstData data = keyData; Uint32 totalSize = 0; - for (Uint32 i = start; i < numAttrs; i++) { + for (Uint32 i = start; i < frag.m_numAttrs; i++) { Uint32 attrId = data.ah().getAttributeId(); Uint32 dataSize = data.ah().getDataSize(); debugOut << i << " attrId=" << attrId << " size=" << dataSize; diff --git a/ndb/test/ndbapi/testOIBasic.cpp b/ndb/test/ndbapi/testOIBasic.cpp index 33482bd9b11..ce1851083b1 100644 --- a/ndb/test/ndbapi/testOIBasic.cpp +++ b/ndb/test/ndbapi/testOIBasic.cpp @@ -1812,14 +1812,16 @@ Val::calckeychars(Par par, unsigned i, unsigned& n, unsigned char* buf) const Chs* chs = col.m_chs; CHARSET_INFO* cs = chs->m_cs; n = 0; - // our random chars may not fill value exactly - while (n + cs->mbmaxlen <= col.m_bytelength) { + unsigned len = 0; + while (len < col.m_length) { if (i % (1 + n) == 0) { break; } const Chr& chr = chs->m_chr[i % maxcharcount]; + assert(n + chr.m_size <= col.m_bytelength); memcpy(buf + n, chr.m_bytes, chr.m_size); n += chr.m_size; + len++; } } @@ -1884,8 +1886,8 @@ Val::calcnokeychars(Par par, unsigned& n, unsigned char* buf) const Chs* chs = col.m_chs; CHARSET_INFO* cs = chs->m_cs; n = 0; - // our random chars may not fill value exactly - while (n + cs->mbmaxlen <= col.m_bytelength) { + unsigned len = 0; + while (len < col.m_length) { if (urandom(1 + col.m_bytelength) == 0) { break; } @@ -1898,8 +1900,10 @@ Val::calcnokeychars(Par par, unsigned& n, unsigned char* buf) unsigned i = half + r; assert(i < maxcharcount); const Chr& chr = chs->m_chr[i]; + assert(n + chr.m_size <= col.m_bytelength); memcpy(buf + n, chr.m_bytes, chr.m_size); n += chr.m_size; + len++; } }