diff --git a/arangod/Aql/BasicBlocks.cpp b/arangod/Aql/BasicBlocks.cpp index e4ba786c72..5ab60902c8 100644 --- a/arangod/Aql/BasicBlocks.cpp +++ b/arangod/Aql/BasicBlocks.cpp @@ -349,10 +349,7 @@ int LimitBlock::getOrSkipSome(size_t atLeast, size_t atMost, bool skipping, if (_state == 0) { if (_fullCount) { - // properly initialize fullcount value, which has a default of -1 - if (_engine->_stats.fullCount == -1) { - _engine->_stats.fullCount = 0; - } + _engine->_stats.fullCount = 0; } if (_offset > 0) { @@ -405,13 +402,11 @@ int LimitBlock::getOrSkipSome(size_t atLeast, size_t atMost, bool skipping, while (true) { skipped = 0; AqlItemBlock* ignore = nullptr; - ExecutionBlock::getOrSkipSome(atLeast, atMost, skipping, ignore, - skipped); + ExecutionBlock::getOrSkipSome(atLeast, atMost, skipping, ignore, skipped); - if (ignore != nullptr) { - _engine->_stats.fullCount += static_cast(ignore->size()); - delete ignore; - } + TRI_ASSERT(ignore == nullptr || ignore->size() == skipped); + _engine->_stats.fullCount += skipped; + delete ignore; if (skipped == 0) { break; diff --git a/arangod/Aql/ExecutionNode.h b/arangod/Aql/ExecutionNode.h index 59add66ee4..4e648b4af6 100644 --- a/arangod/Aql/ExecutionNode.h +++ b/arangod/Aql/ExecutionNode.h @@ -834,7 +834,7 @@ class LimitNode : public ExecutionNode { _fullCount(false) {} LimitNode(ExecutionPlan* plan, size_t id, size_t limit) - : ExecutionNode(plan, id), _offset(0), _limit(limit), _fullCount(false) {} + : LimitNode(plan, id, 0, limit) {} LimitNode(ExecutionPlan*, arangodb::velocypack::Slice const& base); diff --git a/arangod/Aql/ExecutionStats.cpp b/arangod/Aql/ExecutionStats.cpp index a1a8c4ad93..674feec60d 100644 --- a/arangod/Aql/ExecutionStats.cpp +++ b/arangod/Aql/ExecutionStats.cpp @@ -92,5 +92,7 @@ ExecutionStats::ExecutionStats(VPackSlice const& slice) // note: fullCount is an optional attribute! if (slice.hasKey("fullCount")) { fullCount = slice.get("fullCount").getNumber(); + } else { + fullCount = 0; } }