From: Date: October 16 2007 4:25pm Subject: bk commit into 5.1 tree (jonas:1.2165) BUG#31635 List-Archive: http://lists.mysql.com/commits/35655 X-Bug: 31635 Message-Id: <20071016142634.7294D7CCF31@perch.ndb.mysql.com> Below is the list of changes that have just been committed into a local 5.1 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-16 16:25:15+02:00, jonas@stripped +6 -0 ndb - bug#31635 (drop6) 0 pad varsize primary key(s) as mysqld does not (5.0 only) mysql-test/r/ndb_basic.result@stripped, 2007-10-16 16:25:13+02:00, jonas@stripped +24 -0 testcase mysql-test/r/rpl_ndb_basic.result@stripped, 2007-10-16 16:25:13+02:00, jonas@stripped +34 -0 testcase mysql-test/t/ndb_basic.test@stripped, 2007-10-16 16:25:13+02:00, jonas@stripped +20 -0 testcase mysql-test/t/rpl_ndb_basic.test@stripped, 2007-10-16 16:25:13+02:00, jonas@stripped +28 -0 testcase storage/ndb/src/ndbapi/NdbOperationDefine.cpp@stripped, 2007-10-16 16:25:14+02:00, jonas@stripped +25 -8 0 pad all key(s) storage/ndb/src/ndbapi/NdbOperationSearch.cpp@stripped, 2007-10-16 16:25:14+02:00, jonas@stripped +23 -7 0 pad all key(s) # 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/drop6 --- 1.30/mysql-test/r/ndb_basic.result 2007-10-16 16:25:18 +02:00 +++ 1.31/mysql-test/r/ndb_basic.result 2007-10-16 16:25:18 +02:00 @@ -689,3 +689,27 @@ 111111 aaaaaa 1 222222 bbbbbb 2 drop table t1; +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; --- 1.31/mysql-test/t/ndb_basic.test 2007-10-16 16:25:18 +02:00 +++ 1.32/mysql-test/t/ndb_basic.test 2007-10-16 16:25:18 +02:00 @@ -626,3 +626,23 @@ select * from t1 order by f2; select * from t1 order by f3; drop table t1; + +# +# 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; --- 1.22/storage/ndb/src/ndbapi/NdbOperationDefine.cpp 2007-10-16 16:25:18 +02:00 +++ 1.23/storage/ndb/src/ndbapi/NdbOperationDefine.cpp 2007-10-16 16:25:18 +02:00 @@ -544,15 +544,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.27/storage/ndb/src/ndbapi/NdbOperationSearch.cpp 2007-10-16 16:25:18 +02:00 +++ 1.28/storage/ndb/src/ndbapi/NdbOperationSearch.cpp 2007-10-16 16:25:18 +02:00 @@ -130,6 +130,7 @@ OperationType tOpType = theOperationType; Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize; + const Uint32 totalSizeInWords = (sizeInBytes + 3) / 4; { /************************************************************************ @@ -138,20 +139,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; --- 1.3/mysql-test/r/rpl_ndb_basic.result 2007-10-16 16:25:18 +02:00 +++ 1.4/mysql-test/r/rpl_ndb_basic.result 2007-10-16 16:25:18 +02:00 @@ -72,3 +72,37 @@ nid nom prenom 1 DEAD ABC1 DROP TABLE t1; +create table t1 (a varbinary(32) primary key, b int) engine = ndb; +insert into t1 values ('a', 1); +insert into t1 values ('aa', 1); +insert into t1 values ('b', 1); +insert into t1 values ('bb', 1); +select * from t1 order by 1; +a b +a 1 +aa 1 +b 1 +bb 1 +select * from t1 order by 1; +a b +a 1 +aa 1 +b 1 +bb 1 +replace into t1 set a='a', b = 2; +replace into t1 set a='aa', b = 2; +replace into t1 set a='b', b = 2; +replace into t1 set a='bb', b = 2; +select * from t1 order by 1; +a b +a 2 +aa 2 +b 2 +bb 2 +select * from t1 order by 1; +a b +a 2 +aa 2 +b 2 +bb 2 +drop table t1; --- 1.3/mysql-test/t/rpl_ndb_basic.test 2007-10-16 16:25:18 +02:00 +++ 1.4/mysql-test/t/rpl_ndb_basic.test 2007-10-16 16:25:18 +02:00 @@ -127,4 +127,32 @@ # cleanup --connection master + DROP TABLE t1; + +# +# Bug#31635 +# +create table t1 (a varbinary(32) primary key, b int) engine = ndb; +insert into t1 values ('a', 1); +insert into t1 values ('aa', 1); +insert into t1 values ('b', 1); +insert into t1 values ('bb', 1); +select * from t1 order by 1; +--sync_slave_with_master +connection slave; +select * from t1 order by 1; +connection master; +replace into t1 set a='a', b = 2; +replace into t1 set a='aa', b = 2; +replace into t1 set a='b', b = 2; +replace into t1 set a='bb', b = 2; +select * from t1 order by 1; +--sync_slave_with_master +connection slave; +select * from t1 order by 1; +connection master; + +drop table t1; +--sync_slave_with_master +connection master;