diff --git a/arangod/Aql/ExecutionBlock.h b/arangod/Aql/ExecutionBlock.h index 0c4ed97548..0f6b5c54a2 100644 --- a/arangod/Aql/ExecutionBlock.h +++ b/arangod/Aql/ExecutionBlock.h @@ -49,7 +49,7 @@ namespace triagens { class ExecutionBlock { public: ExecutionBlock (ExecutionNode const* ep) - : _exePlan(ep), _done(false), _depth(0) { } + : _exePlan(ep), _done(false), _depth(0), _varOverview(nullptr) { } virtual ~ExecutionBlock (); @@ -163,19 +163,22 @@ namespace triagens { unsigned int totalNrVars; // This is used to tell all Blocks and share a pointer to ourselves - shared_ptr me; + shared_ptr* me; VarOverview () - : depth(0), totalNrVars(0) { + : depth(0), totalNrVars(0), me(nullptr) { nrVarsHere.push_back(0); nrVars.push_back(0); - me.reset(this); }; + void setSharedPtr (shared_ptr* shared) { + me = shared; + } + // Copy constructor used for a subquery: VarOverview (VarOverview const& v) : varInfo(v.varInfo), nrVarsHere(v.nrVars), nrVars(v.nrVars), - depth(v.depth+1), totalNrVars(v.totalNrVars) { + depth(v.depth+1), totalNrVars(v.totalNrVars), me(nullptr) { nrVarsHere.push_back(0); nrVars.push_back(0); } @@ -184,8 +187,9 @@ namespace triagens { virtual bool enterSubquery (ExecutionBlock* super, ExecutionBlock* sub) { - auto vv = new VarOverview(*this); - sub->walk(vv); + shared_ptr vv(new VarOverview(*this)); + vv->setSharedPtr(&vv); + sub->walk(vv.get()); vv->reset(); return false; // do not walk into subquery } @@ -244,14 +248,15 @@ namespace triagens { break; } eb->_depth = depth; - eb->_varOverview = me; + eb->_varOverview = *me; } }; void staticAnalysis () { - auto v = new VarOverview(); - walk(v); + shared_ptr v(new VarOverview()); + v->setSharedPtr(&v); + walk(v.get()); v->reset(); }