From: Date: October 26 2007 8:42am Subject: bk commit into 5.0 tree (jonas:1.2475) BUG#31635 List-Archive: http://lists.mysql.com/commits/36402 X-Bug: 31635 Message-Id: <20071026064237.713F57CCF53@perch.ndb.mysql.com> Below is the list of changes that have just been committed into a local 5.0 repository of jonas. When jonas does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-10-26 08:42:33+02:00, jonas@stripped +4 -0 ndb - bug#31635 (5.0) 0 pad varsize keys in ndbapi mysql-test/r/ndb_basic.result@stripped, 2007-10-26 08:42:31+02:00, jonas@stripped +24 -0 new testcase mysql-test/t/ndb_basic.test@stripped, 2007-10-26 08:42:31+02:00, jonas@stripped +20 -2 new testcase ndb/src/ndbapi/NdbOperationDefine.cpp@stripped, 2007-10-26 08:42:31+02:00, jonas@stripped +25 -8 pad varsize keys ndb/src/ndbapi/NdbOperationSearch.cpp@stripped, 2007-10-26 08:42:31+02:00, jonas@stripped +23 -7 pad varsize keys # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: jonas # Host: perch.ndb.mysql.com # Root: /home/jonas/src/mysql-5.0-ndb --- 1.38/mysql-test/r/ndb_basic.result 2007-10-26 08:42:37 +02:00 +++ 1.39/mysql-test/r/ndb_basic.result 2007-10-26 08:42:37 +02:00 @@ -841,4 +841,28 @@ 3 30 4 1 drop table t1,t2; +create table t1 (a varchar(100) primary key, b varchar(100)) engine = NDB; +insert into t1 values +('a', 'a'),('b','b'),('c', 'c'),('aa', 'aa'),('bb', 'bb'),('cc', 'cc'); +replace into t1 values ('a', '-a'); +replace into t1 values ('b', '-b'); +replace into t1 values ('c', '-c'); +replace into t1 values ('aa', '-aa'); +replace into t1 values ('bb', '-bb'); +replace into t1 values ('cc', '-cc'); +replace into t1 values ('aaa', '-aaa'); +replace into t1 values ('bbb', '-bbb'); +replace into t1 values ('ccc', '-ccc'); +select * from t1 order by 1,2; +a b +a -a +aa -aa +aaa -aaa +b -b +bb -bb +bbb -bbb +c -c +cc -cc +ccc -ccc +drop table t1; End of 5.0 tests --- 1.40/mysql-test/t/ndb_basic.test 2007-10-26 08:42:37 +02:00 +++ 1.41/mysql-test/t/ndb_basic.test 2007-10-26 08:42:37 +02:00 @@ -780,7 +780,25 @@ select * from t1 order by a; drop table t1,t2; -# End of 5.0 tests ---echo End of 5.0 tests +# +# Bug#31635 +# +create table t1 (a varchar(100) primary key, b varchar(100)) engine = NDB; +insert into t1 values + ('a', 'a'),('b','b'),('c', 'c'),('aa', 'aa'),('bb', 'bb'),('cc', 'cc'); +replace into t1 values ('a', '-a'); +replace into t1 values ('b', '-b'); +replace into t1 values ('c', '-c'); + +replace into t1 values ('aa', '-aa'); +replace into t1 values ('bb', '-bb'); +replace into t1 values ('cc', '-cc'); +replace into t1 values ('aaa', '-aaa'); +replace into t1 values ('bbb', '-bbb'); +replace into t1 values ('ccc', '-ccc'); +select * from t1 order by 1,2; +drop table t1; +# End of 5.0 tests +--echo End of 5.0 tests --- 1.24/ndb/src/ndbapi/NdbOperationDefine.cpp 2007-10-26 08:42:37 +02:00 +++ 1.25/ndb/src/ndbapi/NdbOperationDefine.cpp 2007-10-26 08:42:37 +02:00 @@ -572,15 +572,32 @@ * If it is not aligned then we start by copying the value to tempData and * use this as aValue instead. *************************************************************************/ - const int attributeSize = sizeInBytes; - const int slack = sizeInBytes & 3; + int attributeSize = sizeInBytes; + int slack = (sizeInBytes & 3) ? 4 - (sizeInBytes & 3) : 0; + switch(tAttrInfo->m_type){ + case NdbDictionary::Column::Varchar: + case NdbDictionary::Column::Varbinary: + attributeSize = 1 + *(Uint8*)aValue; + slack = 4 * totalSizeInWords - attributeSize; + break; + case NdbDictionary::Column::Longvarchar: + case NdbDictionary::Column::Longvarbinary: + { + const Uint8* ptr = (const Uint8*)aValue; + attributeSize = 2 + ptr[0] + 256 * ptr[1]; + slack = 4 * totalSizeInWords - attributeSize; + break; + } + } - if (((UintPtr)aValue & 3) != 0 || (slack != 0)){ - memcpy(&tempData[0], aValue, attributeSize); - aValue = (char*)&tempData[0]; - if(slack != 0) { - char * tmp = (char*)&tempData[0]; - memset(&tmp[attributeSize], 0, (4 - slack)); + if (((UintPtr)aValue & 3) != 0 || (slack != 0)) + { + char * tmp = (char*)tempData; + memcpy(tmp, aValue, attributeSize); + aValue = tmp; + if(slack != 0) + { + bzero(tmp + attributeSize, slack); }//if }//if --- 1.29/ndb/src/ndbapi/NdbOperationSearch.cpp 2007-10-26 08:42:37 +02:00 +++ 1.30/ndb/src/ndbapi/NdbOperationSearch.cpp 2007-10-26 08:42:37 +02:00 @@ -129,6 +129,7 @@ OperationType tOpType = theOperationType; Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize; + const Uint32 totalSizeInWords = (sizeInBytes + 3) / 4; Uint32 real_len; if (! tAttrInfo->get_var_length(aValue, real_len)) { @@ -150,20 +151,35 @@ * aValue. If it is not aligned then we start by copying the value to * tempData and use this as aValue instead. ***********************************************************************/ - const int attributeSize = sizeInBytes; - const int slack = sizeInBytes & 3; + int attributeSize = sizeInBytes; + int slack = (sizeInBytes & 3) ? 4 - (sizeInBytes & 3) : 0; const int align = UintPtr(aValue) & 7; + switch(tAttrInfo->m_type){ + case NdbDictionary::Column::Varchar: + case NdbDictionary::Column::Varbinary: + attributeSize = 1 + *(Uint8*)aValue; + slack = 4 * totalSizeInWords - attributeSize; + break; + case NdbDictionary::Column::Longvarchar: + case NdbDictionary::Column::Longvarbinary: + { + const Uint8* ptr = (const Uint8*)aValue; + attributeSize = 2 + ptr[0] + 256 * ptr[1]; + slack = 4*totalSizeInWords - attributeSize; + break; + } + } + if (((align & 3) != 0) || (slack != 0) || (tDistrKey && (align != 0))) { - ((Uint32*)tempData)[attributeSize >> 2] = 0; - memcpy(&tempData[0], aValue, attributeSize); - aValue = (char*)&tempData[0]; + char * tmp = (char*)tempData; + memcpy(tmp, aValue, attributeSize); + aValue = tmp; + bzero(tmp + attributeSize, slack); }//if } - Uint32 totalSizeInWords = (sizeInBytes + 3)/4; // Inc. bits in last word - if (true){ //tArraySize != 0) { Uint32 tTupKeyLen = theTupKeyLen;