List:Commits« Previous MessageNext Message »
From:Ole John Aske Date:April 14 2011 9:21am
Subject:bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch
(ole.john.aske:3476 to 3477)
View as plain text  
 3477 Ole John Aske	2011-04-14
      SPJ: Refactoring of how NdbQueryOperationDef objects was released:
      
      Previously NdbQueryOperationDef's was released by either 
      ::~NdbQueryBuilderImpl() or ::~NdbQueryDefImpl() doing
      a 'delete' on the NdbQueryOperationDef being the root of the
      query tree and each NdbQueryOperationDef recursively deleting
      its children. This had the implicit assumption that the
      query tree was in a consistent state - Which it might not be 
      in the case where a NdbQueryBuilder factory method failed 
      before a query tree had been completed.
      
      It simplify the logic to remove the recursive deletion of children,
      and instead iterate the m_operations[] vector to find the 
      NdbQueryOperationDef to delete.

    modified:
      storage/ndb/src/ndbapi/NdbQueryBuilder.cpp
 3476 Ole John Aske	2011-04-14
      SPJ: Minor refactoring: Remove unused 'Ndb' argument to ::NdbQueryBuilderImpl() and NdbQueryBuilder::create()
      
      Also fixed incorrect Copyright headers in HugoQueryBuilder.cpp and HugoQueryBuilder.hpp

    modified:
      sql/ha_ndbcluster.cc
      storage/ndb/src/ndbapi/NdbQueryBuilder.cpp
      storage/ndb/src/ndbapi/NdbQueryBuilder.hpp
      storage/ndb/src/ndbapi/NdbQueryBuilderImpl.hpp
      storage/ndb/test/include/HugoQueryBuilder.hpp
      storage/ndb/test/src/HugoQueryBuilder.cpp
      storage/ndb/test/tools/spj_performance_test.cpp
      storage/ndb/test/tools/spj_sanity_test.cpp
=== modified file 'storage/ndb/src/ndbapi/NdbQueryBuilder.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-04-14 08:59:45 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryBuilder.cpp	2011-04-14 09:21:18 +0000
@@ -574,16 +574,15 @@ NdbQueryIndexScanOperationDef::~NdbQuery
 
 NdbQueryOperationDefImpl::~NdbQueryOperationDefImpl()
 {
+  // Unlink any parent and child refering this object
   if (m_parent != NULL)
   {
     m_parent->removeChild(this);
   }
-  // Delete children recursively also.
   for (Uint32 i = 0; i<m_children.size(); i++)
   {
     assert(m_children[i]->m_parent == this);
     m_children[i]->m_parent = NULL;
-    delete m_children[i];
   }
 }
 
@@ -1145,12 +1144,13 @@ NdbQueryBuilderImpl::NdbQueryBuilderImpl
 NdbQueryBuilderImpl::~NdbQueryBuilderImpl()
 {
   // Delete all operand and operator in Vector's
-  if (m_operations.size() > 0)
+  for (Uint32 i=0; i<m_operations.size(); ++i)
   {
-    delete m_operations[0];
+    delete m_operations[i];
   }
   for (Uint32 i=0; i<m_operands.size(); ++i)
-  { delete m_operands[i];
+  {
+    delete m_operands[i];
   }
 }
 
@@ -1297,12 +1297,13 @@ NdbQueryDefImpl(const Vector<NdbQueryOpe
 NdbQueryDefImpl::~NdbQueryDefImpl()
 {
   // Release all NdbQueryOperations
-  if (m_operations.size() > 0)
+  for (Uint32 i=0; i<m_operations.size(); ++i)
   {
-    delete m_operations[0];
+    delete m_operations[i];
   }
   for (Uint32 i=0; i<m_operands.size(); ++i)
-  { delete m_operands[i];
+  {
+    delete m_operands[i];
   }
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3476 to 3477) Ole John Aske14 Apr