mirror of https://gitee.com/bigwinds/arangodb
Fix handling of plans in explain()
This commit is contained in:
parent
5238686ee3
commit
36e8ab4608
|
@ -517,6 +517,7 @@ QueryResult Query::explain () {
|
||||||
enterState(PARSING);
|
enterState(PARSING);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
ExecutionPlan* plan = nullptr;
|
||||||
Parser parser(this);
|
Parser parser(this);
|
||||||
|
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
@ -539,8 +540,8 @@ QueryResult Query::explain () {
|
||||||
}
|
}
|
||||||
|
|
||||||
enterState(PLAN_INSTANCIATION);
|
enterState(PLAN_INSTANCIATION);
|
||||||
_plan = ExecutionPlan::instanciateFromAst(parser.ast());
|
plan = ExecutionPlan::instanciateFromAst(parser.ast());
|
||||||
if (_plan == nullptr) {
|
if (plan == nullptr) {
|
||||||
// oops
|
// oops
|
||||||
return QueryResult(TRI_ERROR_INTERNAL);
|
return QueryResult(TRI_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
@ -549,7 +550,7 @@ QueryResult Query::explain () {
|
||||||
enterState(PLAN_OPTIMIZATION);
|
enterState(PLAN_OPTIMIZATION);
|
||||||
triagens::aql::Optimizer opt(maxNumberOfPlans());
|
triagens::aql::Optimizer opt(maxNumberOfPlans());
|
||||||
// get enabled/disabled rules
|
// get enabled/disabled rules
|
||||||
opt.createPlans(_plan, getRulesFromOptions());
|
opt.createPlans(plan, getRulesFromOptions());
|
||||||
|
|
||||||
trx.commit();
|
trx.commit();
|
||||||
|
|
||||||
|
@ -571,13 +572,12 @@ QueryResult Query::explain () {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Now plan and all derived plans belong to the optimizer
|
// Now plan and all derived plans belong to the optimizer
|
||||||
_plan = opt.stealBest(); // Now we own the best one again
|
plan = opt.stealBest(); // Now we own the best one again
|
||||||
TRI_ASSERT(_plan != nullptr);
|
TRI_ASSERT(plan != nullptr);
|
||||||
|
|
||||||
result.json = _plan->toJson(parser.ast(), TRI_UNKNOWN_MEM_ZONE, verbosePlans()).steal();
|
result.json = plan->toJson(parser.ast(), TRI_UNKNOWN_MEM_ZONE, verbosePlans()).steal();
|
||||||
|
|
||||||
delete _plan;
|
delete plan;
|
||||||
_plan = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue