Commit d9ab043e authored by unknown's avatar unknown

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
parent 4cf675a2
...@@ -38,7 +38,7 @@ public: ...@@ -38,7 +38,7 @@ public:
float calcValue(int record, int attrib, int updates) const; float calcValue(int record, int attrib, int updates) const;
double calcValue(int record, int attrib, int updates) const; double calcValue(int record, int attrib, int updates) const;
#endif #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 verifyRowValues(NDBT_ResultRow* const pRow) const;
int getIdValue(NDBT_ResultRow* const pRow) const; int getIdValue(NDBT_ResultRow* const pRow) const;
......
...@@ -85,17 +85,16 @@ const char* ...@@ -85,17 +85,16 @@ const char*
HugoCalculator::calcValue(int record, HugoCalculator::calcValue(int record,
int attrib, int attrib,
int updates, int updates,
char* buf) const { char* buf,
int len) const {
const char a[26] = {"UAWBORCTDPEFQGNYHISJMKXLZ"}; const char a[26] = {"UAWBORCTDPEFQGNYHISJMKXLZ"};
const NdbDictionary::Column* attr = m_tab.getColumn(attrib); const NdbDictionary::Column* attr = m_tab.getColumn(attrib);
int val = calcValue(record, attrib, updates); int val = calcValue(record, attrib, updates);
int len;
if (attr->getPrimaryKey()){ if (attr->getPrimaryKey()){
// Create a string where val is printed as chars in the beginning // Create a string where val is printed as chars in the beginning
// of the string, then fill with other chars // of the string, then fill with other chars
// The string length is set to the same size as the attribute // The string length is set to the same size as the attribute
len = attr->getLength();
BaseString::snprintf(buf, len, "%d", val); BaseString::snprintf(buf, len, "%d", val);
for(int i=strlen(buf); i < len; i++) for(int i=strlen(buf); i < len; i++)
buf[i] = a[((val^i)%25)]; buf[i] = a[((val^i)%25)];
...@@ -104,13 +103,13 @@ HugoCalculator::calcValue(int record, ...@@ -104,13 +103,13 @@ HugoCalculator::calcValue(int record,
// Fill buf with some pattern so that we can detect // Fill buf with some pattern so that we can detect
// anomalies in the area that we don't fill with chars // anomalies in the area that we don't fill with chars
int i; int i;
for (i = 0; i<attr->getLength(); i++) for (i = 0; i<len; i++)
buf[i] = ((i+2) % 255); buf[i] = ((i+2) % 255);
// Calculate length of the string to create. We want the string // Calculate length of the string to create. We want the string
// length to be varied between max and min of this attribute. // 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 return NULL if this is a nullable attribute
if (len == 0){ if (len == 0){
if(attr->getNullable() == true) if(attr->getNullable() == true)
...@@ -131,6 +130,7 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ ...@@ -131,6 +130,7 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
id = pRow->attributeStore(m_idCol)->u_32_value(); id = pRow->attributeStore(m_idCol)->u_32_value();
updates = pRow->attributeStore(m_updatesCol)->u_32_value(); updates = pRow->attributeStore(m_updatesCol)->u_32_value();
int result = 0;
// Check the values of each column // Check the values of each column
for (int i = 0; i<m_tab.getNoOfColumns(); i++){ for (int i = 0; i<m_tab.getNoOfColumns(); i++){
...@@ -145,9 +145,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ ...@@ -145,9 +145,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
case NdbDictionary::Column::Varchar: case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Binary: case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:{ case NdbDictionary::Column::Varbinary:{
int result = 0;
char* buf = new char[len+1]; 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 (res == NULL){
if (!pRow->attributeStore(i)->isNULL()){ if (!pRow->attributeStore(i)->isNULL()){
g_err << "|- NULL ERROR: expected a NULL but the column was not null" << endl; 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{ ...@@ -183,7 +182,6 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
} }
} }
delete []buf; delete []buf;
return result;
} }
break; break;
case NdbDictionary::Column::Int: case NdbDictionary::Column::Int:
...@@ -194,9 +192,9 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ ...@@ -194,9 +192,9 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
g_err << "|- Invalid data found: \"" << val << "\" != \"" g_err << "|- Invalid data found: \"" << val << "\" != \""
<< cval << "\"" << endl; << cval << "\"" << endl;
g_err << "|- The row: \"" << (* pRow) << "\"" << endl; g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
return -1; result = -1;
} }
return 0; break;
} }
case NdbDictionary::Column::Bigint: case NdbDictionary::Column::Bigint:
case NdbDictionary::Column::Bigunsigned:{ case NdbDictionary::Column::Bigunsigned:{
...@@ -207,9 +205,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ ...@@ -207,9 +205,8 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
<< cval << "\"" << cval << "\""
<< endl; << endl;
g_err << "|- The row: \"" << (* pRow) << "\"" << endl; g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
return -1; result = -1;
} }
return 0;
} }
break; break;
case NdbDictionary::Column::Float:{ case NdbDictionary::Column::Float:{
...@@ -219,18 +216,19 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{ ...@@ -219,18 +216,19 @@ HugoCalculator::verifyRowValues(NDBT_ResultRow* const pRow) const{
g_err << "|- Invalid data found: \"" << val << "\" != \"" g_err << "|- Invalid data found: \"" << val << "\" != \""
<< cval << "\"" << endl; << cval << "\"" << endl;
g_err << "|- The row: \"" << (* pRow) << "\"" << endl; g_err << "|- The row: \"" << (* pRow) << "\"" << endl;
return -1; result = -1;
} }
return 0;
} }
break; break;
case NdbDictionary::Column::Undefined: case NdbDictionary::Column::Undefined:
default:
assert(0);
result = -1;
break; break;
} }
} }
} }
assert(0); return result;
return -1;
} }
int int
......
...@@ -414,15 +414,18 @@ int HugoOperations::equalForAttr(NdbOperation* pOp, ...@@ -414,15 +414,18 @@ int HugoOperations::equalForAttr(NdbOperation* pOp,
return NDBT_FAILED; return NDBT_FAILED;
} }
int len = attr->getLength();
switch (attr->getType()){ switch (attr->getType()){
case NdbDictionary::Column::Bit: case NdbDictionary::Column::Bit:
len = 4 * ((len + 31) >> 5);
case NdbDictionary::Column::Char: case NdbDictionary::Column::Char:
case NdbDictionary::Column::Varchar: case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Binary: case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:{ case NdbDictionary::Column::Varbinary:{
char buf[8000]; char buf[8000];
memset(buf, 0, sizeof(buf)); 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; break;
} }
case NdbDictionary::Column::Int: case NdbDictionary::Column::Int:
...@@ -452,15 +455,17 @@ int HugoOperations::setValueForAttr(NdbOperation* pOp, ...@@ -452,15 +455,17 @@ int HugoOperations::setValueForAttr(NdbOperation* pOp,
int check = -1; int check = -1;
const NdbDictionary::Column* attr = tab.getColumn(attrId); const NdbDictionary::Column* attr = tab.getColumn(attrId);
int len = attr->getLength();
switch (attr->getType()){ switch (attr->getType()){
case NdbDictionary::Column::Bit: case NdbDictionary::Column::Bit:
len = 4 * ((len + 31) >> 5);
case NdbDictionary::Column::Char: case NdbDictionary::Column::Char:
case NdbDictionary::Column::Varchar: case NdbDictionary::Column::Varchar:
case NdbDictionary::Column::Binary: case NdbDictionary::Column::Binary:
case NdbDictionary::Column::Varbinary:{ case NdbDictionary::Column::Varbinary:{
char buf[8000]; char buf[8000];
check = pOp->setValue( attr->getName(), check = pOp->setValue( attr->getName(),
calc.calcValue(rowId, attrId, updateId, buf)); calc.calcValue(rowId, attrId, updateId, buf, len));
break; break;
} }
case NdbDictionary::Column::Int:{ case NdbDictionary::Column::Int:{
......
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 # transproxy
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment