mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
ndb - Fix hugoCalcValue for bits
ndb/test/include/HugoCalculator.hpp: Fix calcValue for bits ndb/test/src/HugoCalculator.cpp: Fix calcValue for bits ndb/test/src/HugoOperations.cpp: Fix calcValue for bits ndb/test/tools/Makefile.am: Fix calcValue for bits
This commit is contained in:
parent
4cf675a21d
commit
d9ab043e07
4 changed files with 26 additions and 23 deletions
|
@ -38,7 +38,7 @@ public:
|
|||
float calcValue(int record, int attrib, int updates) const;
|
||||
double calcValue(int record, int attrib, int updates) const;
|
||||
#endif
|
||||
const char* calcValue(int record, int attrib, int updates, char* buf) const;
|
||||
const char* calcValue(int record, int attrib, int updates, char* buf, int len) const;
|
||||
|
||||
int verifyRowValues(NDBT_ResultRow* const pRow) const;
|
||||
int getIdValue(NDBT_ResultRow* const pRow) const;
|
||||
|
|
|
@ -85,17 +85,16 @@ const char*
|
|||
HugoCalculator::calcValue(int record,
|
||||
int attrib,
|
||||
int updates,
|
||||
char* buf) const {
|
||||
char* buf,
|
||||
int len) const {
|
||||
const char a[26] = {"UAWBORCTDPEFQGNYHISJMKXLZ"};
|
||||
const NdbDictionary::Column* attr = m_tab.getColumn(attrib);
|
||||
int val = calcValue(record, attrib, updates);
|
||||
|
||||
int len;
|
||||
if (attr->getPrimaryKey()){
|
||||
// Create a string where val is printed as chars in the beginning
|
||||
// of the string, then fill with other chars
|
||||
// The string length is set to the same size as the attribute
|
||||
len = attr->getLength();
|
||||
BaseString::snprintf(buf, len, "%d", val);
|
||||
for(int i=strlen(buf); i < len; i++)
|
||||
buf[i] = a[((val^i)%25)];
|
||||
|
@ -104,13 +103,13 @@ HugoCalculator::calcValue(int record,
|
|||
// Fill buf with some pattern so that we can detect
|
||||
// anomalies in the area that we don't fill with chars
|
||||
int i;
|
||||
for (i = 0; i<attr->getLength(); i++)
|
||||
for (i = 0; i<len; i++)
|
||||
buf[i] = ((i+2) % 255);
|
||||
|
||||
// Calculate length of the string to create. We want the string
|
||||
// length to be varied between max and min of this attribute.
|
||||
|
||||
len = val % (attr->getLength() + 1);
|
||||
len = val % (len + 1);
|
||||
// If len == 0 return NULL if this is a nullable attribute
|
||||
if (len == 0){
|
||||
if(attr->getNullable() == true)
|
||||
|
@ -131,7 +130,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
|
||||
id = pRow->attributeStore(m_idCol)->u_32_value();
|
||||
updates = pRow->attributeStore(m_updatesCol)->u_32_value();
|
||||
|
||||
int result = 0;
|
||||
|
||||
// Check the values of each column
|
||||
for (int i = 0; i<m_tab.getNoOfColumns(); i++){
|
||||
if (i != m_updatesCol && id != m_idCol) {
|
||||
|
@ -145,9 +145,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
case NdbDictionary::Column::Varchar:
|
||||
case NdbDictionary::Column::Binary:
|
||||
case NdbDictionary::Column::Varbinary:{
|
||||
int result = 0;
|
||||
char* buf = new char[len+1];
|
||||
const char* res = calcValue(id, i, updates, buf);
|
||||
const char* res = calcValue(id, i, updates, buf, len);
|
||||
if (res == NULL){
|
||||
if (!pRow->attributeStore(i)->isNULL()){
|
||||
g_err << "|- NULL ERROR: expected a NULL but the column was not null" << endl;
|
||||
|
@ -183,7 +182,6 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
}
|
||||
}
|
||||
delete []buf;
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case NdbDictionary::Column::Int:
|
||||
|
@ -194,9 +192,9 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
g_err << "|- Invalid data found: \"" << val << "\" != \""
|
||||
<< cval << "\"" << endl;
|
||||
g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case NdbDictionary::Column::Bigint:
|
||||
case NdbDictionary::Column::Bigunsigned:{
|
||||
|
@ -207,9 +205,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
<< cval << "\""
|
||||
<< endl;
|
||||
g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case NdbDictionary::Column::Float:{
|
||||
|
@ -217,20 +214,21 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
|
|||
float val = pRow->attributeStore(i)->float_value();
|
||||
if (val != cval){
|
||||
g_err << "|- Invalid data found: \"" << val << "\" != \""
|
||||
<< cval << "\"" << endl;
|
||||
<< cval << "\"" << endl;
|
||||
g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
|
||||
return -1;
|
||||
result = -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case NdbDictionary::Column::Undefined:
|
||||
default:
|
||||
assert(0);
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(0);
|
||||
return -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -414,15 +414,18 @@ int HugoOperations::equalForAttr(NdbOperation* pOp,
|
|||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
int len = attr->getLength();
|
||||
switch (attr->getType()){
|
||||
case NdbDictionary::Column::Bit:
|
||||
len = 4 * ((len + 31) >> 5);
|
||||
case NdbDictionary::Column::Char:
|
||||
case NdbDictionary::Column::Varchar:
|
||||
case NdbDictionary::Column::Binary:
|
||||
case NdbDictionary::Column::Varbinary:{
|
||||
char buf[8000];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
check = pOp->equal( attr->getName(), calc.calcValue(rowId, attrId, 0, buf));
|
||||
check = pOp->equal( attr->getName(),
|
||||
calc.calcValue(rowId, attrId, 0, buf, len));
|
||||
break;
|
||||
}
|
||||
case NdbDictionary::Column::Int:
|
||||
|
@ -451,16 +454,18 @@ int HugoOperations::setValueForAttr(NdbOperation* pOp,
|
|||
int updateId){
|
||||
int check = -1;
|
||||
const NdbDictionary::Column* attr = tab.getColumn(attrId);
|
||||
|
||||
|
||||
int len = attr->getLength();
|
||||
switch (attr->getType()){
|
||||
case NdbDictionary::Column::Bit:
|
||||
len = 4 * ((len + 31) >> 5);
|
||||
case NdbDictionary::Column::Char:
|
||||
case NdbDictionary::Column::Varchar:
|
||||
case NdbDictionary::Column::Binary:
|
||||
case NdbDictionary::Column::Varbinary:{
|
||||
char buf[8000];
|
||||
check = pOp->setValue( attr->getName(),
|
||||
calc.calcValue(rowId, attrId, updateId, buf));
|
||||
calc.calcValue(rowId, attrId, updateId, buf, len));
|
||||
break;
|
||||
}
|
||||
case NdbDictionary::Column::Int:{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
ndbtest_PROGRAMS = hugoCalculator hugoLoad hugoFill hugoLockRecords hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate hugoScanRead hugoScanUpdate restart verify_index copy_tab create_index ndb_cpcc
|
||||
ndbtest_PROGRAMS = hugoLoad hugoFill hugoLockRecords hugoPkDelete hugoPkRead hugoPkReadRecord hugoPkUpdate hugoScanRead hugoScanUpdate restart verify_index copy_tab create_index ndb_cpcc
|
||||
|
||||
# transproxy
|
||||
|
||||
|
|
Loading…
Reference in a new issue