#At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-5.1-telco-7.0-spj-scan-scan/ based on revid:ole.john.aske@stripped
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
=== 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];
}
}
Attachment: [text/bzr-bundle] bzr/ole.john.aske@oracle.com-20110414092118-d3iymdyvsdwocpjv.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-7.0-spj-scan-vs-scan branch(ole.john.aske:3477) | Ole John Aske | 14 Apr |