mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
ndb - bug#31635 (5.0)
0 pad varsize keys in ndbapi mysql-test/r/ndb_basic.result: new testcase mysql-test/t/ndb_basic.test: new testcase ndb/src/ndbapi/NdbOperationDefine.cpp: pad varsize keys ndb/src/ndbapi/NdbOperationSearch.cpp: pad varsize keys
This commit is contained in:
parent
6e817c8d26
commit
81b5dbe25b
4 changed files with 92 additions and 17 deletions
|
@ -841,4 +841,28 @@ a b
|
||||||
3 30
|
3 30
|
||||||
4 1
|
4 1
|
||||||
drop table t1,t2;
|
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
|
End of 5.0 tests
|
||||||
|
|
|
@ -780,7 +780,25 @@ update ignore t1,t2 set a = 1, c = 1 where a = 3 and c = 3;
|
||||||
select * from t1 order by a;
|
select * from t1 order by a;
|
||||||
drop table t1,t2;
|
drop table t1,t2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
# End of 5.0 tests
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -572,15 +572,32 @@ NdbOperation::setValue( const NdbColumnImpl* tAttrInfo,
|
||||||
* If it is not aligned then we start by copying the value to tempData and
|
* If it is not aligned then we start by copying the value to tempData and
|
||||||
* use this as aValue instead.
|
* use this as aValue instead.
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
const int attributeSize = sizeInBytes;
|
int attributeSize = sizeInBytes;
|
||||||
const int slack = sizeInBytes & 3;
|
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)){
|
if (((UintPtr)aValue & 3) != 0 || (slack != 0))
|
||||||
memcpy(&tempData[0], aValue, attributeSize);
|
{
|
||||||
aValue = (char*)&tempData[0];
|
char * tmp = (char*)tempData;
|
||||||
if(slack != 0) {
|
memcpy(tmp, aValue, attributeSize);
|
||||||
char * tmp = (char*)&tempData[0];
|
aValue = tmp;
|
||||||
memset(&tmp[attributeSize], 0, (4 - slack));
|
if(slack != 0)
|
||||||
|
{
|
||||||
|
bzero(tmp + attributeSize, slack);
|
||||||
}//if
|
}//if
|
||||||
}//if
|
}//if
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,7 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
|
||||||
|
|
||||||
OperationType tOpType = theOperationType;
|
OperationType tOpType = theOperationType;
|
||||||
Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize;
|
Uint32 sizeInBytes = tAttrInfo->m_attrSize * tAttrInfo->m_arraySize;
|
||||||
|
const Uint32 totalSizeInWords = (sizeInBytes + 3) / 4;
|
||||||
|
|
||||||
Uint32 real_len;
|
Uint32 real_len;
|
||||||
if (! tAttrInfo->get_var_length(aValue, real_len)) {
|
if (! tAttrInfo->get_var_length(aValue, real_len)) {
|
||||||
|
@ -150,20 +151,35 @@ NdbOperation::equal_impl(const NdbColumnImpl* tAttrInfo,
|
||||||
* aValue. If it is not aligned then we start by copying the value to
|
* aValue. If it is not aligned then we start by copying the value to
|
||||||
* tempData and use this as aValue instead.
|
* tempData and use this as aValue instead.
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
const int attributeSize = sizeInBytes;
|
int attributeSize = sizeInBytes;
|
||||||
const int slack = sizeInBytes & 3;
|
int slack = (sizeInBytes & 3) ? 4 - (sizeInBytes & 3) : 0;
|
||||||
const int align = UintPtr(aValue) & 7;
|
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)))
|
if (((align & 3) != 0) || (slack != 0) || (tDistrKey && (align != 0)))
|
||||||
{
|
{
|
||||||
((Uint32*)tempData)[attributeSize >> 2] = 0;
|
char * tmp = (char*)tempData;
|
||||||
memcpy(&tempData[0], aValue, attributeSize);
|
memcpy(tmp, aValue, attributeSize);
|
||||||
aValue = (char*)&tempData[0];
|
aValue = tmp;
|
||||||
|
bzero(tmp + attributeSize, slack);
|
||||||
}//if
|
}//if
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 totalSizeInWords = (sizeInBytes + 3)/4; // Inc. bits in last word
|
|
||||||
|
|
||||||
if (true){ //tArraySize != 0) {
|
if (true){ //tArraySize != 0) {
|
||||||
Uint32 tTupKeyLen = theTupKeyLen;
|
Uint32 tTupKeyLen = theTupKeyLen;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue