List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:March 31 2011 12:31pm
Subject:bzr commit into mysql-5.1-telco-6.3 branch (jonas:3407) Bug#12312393
View as plain text  
#At file:///home/jonas/src/telco-6.3/ based on revid:jonas@stripped

 3407 Jonas Oreland	2011-03-31
      ndb - bug#12312393 - clean interpreted bit when sending lookup on index table

    modified:
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/test/include/HugoCalculator.hpp
      storage/ndb/test/ndbapi/testInterpreter.cpp
      storage/ndb/test/src/HugoCalculator.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2011-01-30 20:42:21 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2011-03-31 12:31:43 +0000
@@ -13234,6 +13234,7 @@ void Dbtc::readIndexTable(Signal* signal
 			     opType == ZREAD ? ZREAD : ZREAD_EX);
   TcKeyReq::setAIInTcKeyReq(tcKeyRequestInfo, 1); // Allways send one AttrInfo
   TcKeyReq::setExecutingTrigger(tcKeyRequestInfo, 0);
+  TcKeyReq::setInterpretedFlag(tcKeyRequestInfo, 0);
   tcKeyReq->senderData = indexOp->indexOpId;
   indexOp->indexOpState = IOS_INDEX_ACCESS;
   regApiPtr->executingIndexOp = regApiPtr->accumulatingIndexOp;

=== modified file 'storage/ndb/test/include/HugoCalculator.hpp'
--- a/storage/ndb/test/include/HugoCalculator.hpp	2009-10-06 10:39:02 +0000
+++ b/storage/ndb/test/include/HugoCalculator.hpp	2011-03-31 12:31:43 +0000
@@ -44,6 +44,8 @@ public:
   int getUpdatesValue(NDBT_ResultRow* const pRow) const;
   int isIdCol(int colId) { return m_idCol == colId; };
   int isUpdateCol(int colId){ return m_updatesCol == colId; };
+
+  int equalForRow(Uint8 *, const NdbRecord*, int rowid);
 private:
   const NdbDictionary::Table& m_tab;
   int m_idCol;

=== modified file 'storage/ndb/test/ndbapi/testInterpreter.cpp'
--- a/storage/ndb/test/ndbapi/testInterpreter.cpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/ndbapi/testInterpreter.cpp	2011-03-31 12:31:43 +0000
@@ -389,6 +389,148 @@ int runTestBug34107(NDBT_Context* ctx, N
   return NDBT_OK;
 }
 
+static char pkIdxName[256];
+
+int
+createPkIndex(NDBT_Context* ctx, NDBT_Step* step){
+  const NdbDictionary::Table* pTab = ctx->getTab();
+  Ndb* pNdb = GETNDB(step);
+
+  bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
+  bool logged = ctx->getProperty("LoggedIndexes", (Uint32)0);
+  bool noddl= ctx->getProperty("NoDDL");
+
+  // Create index
+  BaseString::snprintf(pkIdxName, 255, "IDC_PK_%s", pTab->getName());
+  if (orderedIndex)
+    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "
+	   << pkIdxName << " (";
+  else
+    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "
+	   << pkIdxName << " (";
+
+  NdbDictionary::Index pIdx(pkIdxName);
+  pIdx.setTable(pTab->getName());
+  if (orderedIndex)
+    pIdx.setType(NdbDictionary::Index::OrderedIndex);
+  else
+    pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
+  for (int c = 0; c< pTab->getNoOfColumns(); c++){
+    const NdbDictionary::Column * col = pTab->getColumn(c);
+    if(col->getPrimaryKey()){
+      pIdx.addIndexColumn(col->getName());
+      ndbout << col->getName() <<" ";
+    }
+  }
+
+  pIdx.setStoredIndex(logged);
+  ndbout << ") ";
+  if (noddl)
+  {
+    const NdbDictionary::Index* idx= pNdb->
+      getDictionary()->getIndex(pkIdxName, pTab->getName());
+
+    if (!idx)
+    {
+      ndbout << "Failed - Index does not exist and DDL not allowed" << endl;
+      ERR(pNdb->getDictionary()->getNdbError());
+      return NDBT_FAILED;
+    }
+    else
+    {
+      // TODO : Check index definition is ok
+    }
+  }
+  else
+  {
+    if (pNdb->getDictionary()->createIndex(pIdx) != 0){
+      ndbout << "FAILED!" << endl;
+      const NdbError err = pNdb->getDictionary()->getNdbError();
+      ERR(err);
+      return NDBT_FAILED;
+    }
+  }
+
+  ndbout << "OK!" << endl;
+  return NDBT_OK;
+}
+
+int
+createPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step)
+{
+  const NdbDictionary::Table* pTab = ctx->getTab();
+  Ndb* pNdb = GETNDB(step);
+
+  bool noddl= ctx->getProperty("NoDDL");
+
+  // Drop index
+  if (!noddl)
+  {
+    ndbout << "Dropping index " << pkIdxName << " ";
+    if (pNdb->getDictionary()->dropIndex(pkIdxName,
+                                         pTab->getName()) != 0){
+      ndbout << "FAILED!" << endl;
+      ERR(pNdb->getDictionary()->getNdbError());
+      return NDBT_FAILED;
+    } else {
+      ndbout << "OK!" << endl;
+    }
+  }
+
+  return NDBT_OK;
+}
+
+#define CHK_RET_FAILED(x) if (!(x)) { ndbout_c("Failed on line: %u", __LINE__); return NDBT_FAILED; }
+
+int
+runInterpretedUKLookup(NDBT_Context* ctx, NDBT_Step* step)
+{
+  const NdbDictionary::Table * pTab = ctx->getTab();
+  Ndb* pNdb = GETNDB(step);
+  NdbDictionary::Dictionary * dict = pNdb->getDictionary();
+
+  const NdbDictionary::Index* pIdx= dict->getIndex(pkIdxName, pTab->getName());
+  CHK_RET_FAILED(pIdx != 0);
+
+  const NdbRecord * pRowRecord = pTab->getDefaultRecord();
+  CHK_RET_FAILED(pRowRecord != 0);
+  const NdbRecord * pIdxRecord = pIdx->getDefaultRecord();
+  CHK_RET_FAILED(pIdxRecord != 0);
+
+  const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
+  Uint8 * pRow = new Uint8[len];
+  bzero(pRow, len);
+
+  HugoCalculator calc(* pTab);
+  calc.equalForRow(pRow, pRowRecord, 0);
+
+  NdbTransaction* pTrans = pNdb->startTransaction();
+  CHK_RET_FAILED(pTrans != 0);
+
+  NdbInterpretedCode code;
+  code.interpret_exit_ok();
+  code.finalise();
+
+  NdbOperation::OperationOptions opts;
+  bzero(&opts, sizeof(opts));
+  opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
+  opts.interpretedCode = &code;
+
+  const NdbOperation * pOp = pTrans->readTuple(pIdxRecord, (char*)pRow,
+                                               pRowRecord, (char*)pRow,
+                                               NdbOperation::LM_Read,
+                                               0,
+                                               &opts,
+                                               sizeof(opts));
+  CHK_RET_FAILED(pOp);
+  int res = pTrans->execute(Commit, AbortOnError);
+
+  CHK_RET_FAILED(res == 0);
+
+  delete [] pRow;
+
+  return NDBT_OK;
+}
 
 NDBT_TESTSUITE(testInterpreter);
 TESTCASE("IncValue32", 
@@ -480,6 +622,13 @@ TESTCASE("NdbErrorOperation", 
   INITIALIZER(runCheckGetNdbErrorOperation);
 }
 #endif
+TESTCASE("InterpretedUKLookup", "")
+{
+  INITIALIZER(runLoadTable);
+  INITIALIZER(createPkIndex);
+  INITIALIZER(runInterpretedUKLookup);
+  INITIALIZER(createPkIndex_Drop);
+}
 NDBT_TESTSUITE_END(testInterpreter);
 
 int main(int argc, const char** argv){

=== modified file 'storage/ndb/test/src/HugoCalculator.cpp'
--- a/storage/ndb/test/src/HugoCalculator.cpp	2010-06-17 05:17:43 +0000
+++ b/storage/ndb/test/src/HugoCalculator.cpp	2011-03-31 12:31:43 +0000
@@ -442,3 +442,30 @@ HugoCalculator::getUpdatesValue(NDBT_Res
   return pRow->attributeStore(m_updatesCol)->u_32_value();
 }
 
+int
+HugoCalculator::equalForRow(Uint8 * pRow,
+                            const NdbRecord* pRecord,
+                            int rowId)
+{
+  for(int attrId = 0; attrId < m_tab.getNoOfColumns(); attrId++)
+  {
+    const NdbDictionary::Column* attr = m_tab.getColumn(attrId);
+
+    if (attr->getPrimaryKey() == true)
+    {
+      char buf[8000];
+      int len = attr->getSizeInBytes();
+      memset(buf, 0, sizeof(buf));
+      Uint32 real_len;
+      const char * value = calcValue(rowId, attrId, 0, buf,
+                                     len, &real_len);
+      assert(value != 0); // NULLable PK not supported...
+      Uint32 off = 0;
+      bool ret = NdbDictionary::getOffset(pRecord, attrId, off);
+      if (!ret)
+        abort();
+      memcpy(pRow + off, buf, real_len);
+    }
+  }
+  return NDBT_OK;
+}


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20110331123143-b62tlyek9qmhhked.bundle
Thread
bzr commit into mysql-5.1-telco-6.3 branch (jonas:3407) Bug#12312393Jonas Oreland31 Mar