List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:June 5 2009 10:39am
Subject:bzr commit into mysql-5.1-telco-7.1 branch (frazer:2899)
View as plain text  
#At file:///home/frazer/bzr/mysql-5.1-telco-7.1/

 2899 Frazer Clement	2009-06-05
      Enhance testDict -n FailAddFragment and fix exposed bugs
      modified:
        storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp
        storage/ndb/test/ndbapi/testDict.cpp

=== modified file 'storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp	2009-06-03 06:15:29 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp	2009-06-05 10:39:41 +0000
@@ -403,7 +403,9 @@ error:
   }
   //release SectionSegment used to store the default values for received attributes
   releaseSection(regTabPtr.p->m_createTable.defValSectionI);
+  regTabPtr.p->m_createTable.defValSectionI= RNIL;
   free_var_part(DefaultValuesFragment.p, regTabPtr.p, &regTabPtr.p->m_default_value_location);
+  regTabPtr.p->m_default_value_location.setNull();
 
   signal->theData[0]= fragOperPtr.p->lqhPtrFrag;
   signal->theData[1]= terrorCode;
@@ -687,7 +689,9 @@ void Dbtup::execTUPFRAGREQ(Signal* signa
 sendref:
   //release SectionSegment used to store the default values for received attributes
   releaseSection(regTabPtr.p->m_createTable.defValSectionI);
+  regTabPtr.p->m_createTable.defValSectionI= RNIL;
   free_var_part(DefaultValuesFragment.p, regTabPtr.p, &regTabPtr.p->m_default_value_location);
+  regTabPtr.p->m_default_value_location.setNull();
 
   signal->theData[0]= userptr;
   signal->theData[1]= terrorCode;
@@ -733,6 +737,7 @@ int Dbtup::store_default_record(const Ta
   
   copy(var_data_ptr, RdefValSectionI);
   releaseSection(RdefValSectionI);
+  regTabPtr.p->m_createTable.defValSectionI= RNIL;
   
   return 0;
 }
@@ -2056,6 +2061,7 @@ Dbtup::drop_table_logsync_callback(Signa
   
   releaseTabDescr(tabPtr.p);
   free_var_part(DefaultValuesFragment.p, tabPtr.p, &tabPtr.p->m_default_value_location);
+  tabPtr.p->m_default_value_location.setNull();
   initTab(tabPtr.p);
 }
 

=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp	2009-06-05 10:39:41 +0000
@@ -25,6 +25,7 @@
 #include <signaldata/DumpStateOrd.hpp>
 #include <../../include/kernel/ndb_limits.h>
 #include <../../include/kernel/trigger_definitions.h>
+#include <signaldata/DictTabInfo.hpp>
 #include <random.h>
 #include <NdbAutoPtr.hpp>
 #include <NdbMixRestarter.hpp>
@@ -1842,6 +1843,31 @@ runCreateDiskTable(NDBT_Context* ctx, ND
   return NDBT_OK;
 }
 
+int getColumnMaxLength(const NdbDictionary::Column* c)
+{
+  int length= c->getLength();
+  if (c->getArrayType() == NDB_ARRAYTYPE_FIXED)
+  {
+    /* Not yet set - need to calculate from type etc. */
+    DictTabInfo::Attribute attrDesc;
+
+    attrDesc.init();
+    attrDesc.AttributeExtType= c->getType();
+    attrDesc.AttributeExtLength= c->getLength();
+    attrDesc.AttributeExtPrecision= c->getPrecision();
+    attrDesc.AttributeExtScale= c->getScale();
+
+    if (!attrDesc.translateExtType())
+    {
+      return 0;
+    }
+
+    length= ((1 << attrDesc.AttributeSize) * c->getLength()) >> 3;
+  }
+
+  return length;
+}
+
 #include <NDBT_Tables.hpp>
 
 #define SAFTY 300
@@ -1869,7 +1895,34 @@ int runFailAddFragment(NDBT_Context* ctx
     errNo = atoi(buf);
     ndbout_c("Using errno: %u", errNo);
   }
-  
+
+  const NdbDictionary::Table* origTab= ctx->getTab();
+  HugoCalculator calc(*origTab);
+
+  // Add defaults to some columns
+  for (int colNum= 0; colNum < tab.getNoOfColumns(); colNum++)
+  {
+    const NdbDictionary::Column* origCol= origTab->getColumn(colNum);
+    NdbDictionary::Column* col= tab.getColumn(colNum);
+    if (!origCol->getPrimaryKey())
+    {
+      if (myRandom48(2) == 0)
+      {
+        char defaultBuf[ NDB_MAX_TUPLE_SIZE ];
+        Uint32 real_len;
+        const char* def= calc.calcValue(0, colNum, 0, 
+                                        defaultBuf,
+                                        getColumnMaxLength(origCol),
+                                        &real_len);
+        if (col->setDefaultValue(def, real_len) != 0)
+        {
+          ndbout_c("Error setting default value\n");
+          return NDBT_FAILED;
+        }
+      }
+    }
+  }
+
   // ordered index on first few columns
   NdbDictionary::Index idx("X");
   idx.setTable(tab.getName());

Thread
bzr commit into mysql-5.1-telco-7.1 branch (frazer:2899)Frazer Clement5 Jun